From 0496ffac85e663ba4c9a14d2d4eb300a3c017ae2 Mon Sep 17 00:00:00 2001 From: Dave Hibberd Date: Sat, 13 Apr 2024 21:27:52 +0100 Subject: New upstream version 20240413 --- tests/Python3_Driver_Testing.md | 12 ++-- tests/__pycache__/base.cpython-310.pyc | Bin 5292 -> 5360 bytes .../test_brute_force.cpython-310-pytest-7.1.3.pyc | Bin 5055 -> 5396 bytes .../test_edges.cpython-310-pytest-7.1.3.pyc | Bin 7389 -> 7373 bytes tests/base.py | 8 +++ tests/images/Alinco_DR735T.img | Bin 0 -> 66093 bytes tests/images/Baofeng_GM-5RH.img | Bin 0 -> 33845 bytes tests/py3_driver_testers.txt | 3 + tests/test_edges.py | 1 - tests/unit/__pycache__/base.cpython-310.pyc | Bin 962 -> 1110 bytes .../test_alinco_clone.cpython-310-pytest-7.1.3.pyc | Bin 4993 -> 6437 bytes .../test_bitwise.cpython-310-pytest-7.1.3.pyc | Bin 15690 -> 17015 bytes .../test_chirp_common.cpython-310-pytest-7.1.3.pyc | Bin 31358 -> 31375 bytes ...t_wxui_radiothread.cpython-310-pytest-7.1.3.pyc | Bin 4770 -> 6529 bytes tests/unit/base.py | 4 ++ tests/unit/test_alinco_clone.py | 45 ++++++++++++- tests/unit/test_bitwise.py | 10 +++ tests/unit/test_chirp_common.py | 1 + tests/unit/test_wxui_radiothread.py | 72 +++++++++++++++++++++ 19 files changed, 149 insertions(+), 7 deletions(-) create mode 100644 tests/images/Alinco_DR735T.img create mode 100644 tests/images/Baofeng_GM-5RH.img (limited to 'tests') diff --git a/tests/Python3_Driver_Testing.md b/tests/Python3_Driver_Testing.md index a7864a1..68276b9 100644 --- a/tests/Python3_Driver_Testing.md +++ b/tests/Python3_Driver_Testing.md @@ -16,6 +16,7 @@ | Alinco_DR135T | [Implied by Alinco_DR235T](#user-content-Alinco_DR235T) | 12-Dec-2022 | Yes | 0.04% | | Alinco_DR235T | [@kk7ds](https://github.com/kk7ds) | 12-Dec-2022 | Yes | 0.02% | | Alinco_DR435T | [Implied by Alinco_DR235T](#user-content-Alinco_DR235T) | 12-Dec-2022 | Yes | 0.02% | +| Alinco_DR735T | [@jacobcalvert](https://github.com/jacobcalvert) | 03-April-2024 | Yes | | | AnyTone_5888UV | [@kk7ds](https://github.com/kk7ds) | 9-Dec-2022 | Yes | 0.14% | | AnyTone_5888UVIII | [@bschuler42](https://github.com/bschuler42) | 9-Jan-2023 | Yes | 0.04% | | AnyTone_778UV | [Implied by Retevis_RT95](#user-content-Retevis_RT95) | 13-Nov-2022 | Yes | 0.17% | @@ -60,8 +61,10 @@ | Baofeng_BF-T8 | [@KC9HI](https://github.com/KC9HI) | 30-Nov-2022 | Yes | 0.42% | | Baofeng_BF-V8A | [@KC9HI](https://github.com/KC9HI) | 28-Nov-2022 | Yes | 0.03% | | Baofeng_F-11 | [Implied by Baofeng_UV-5R](#user-content-Baofeng_UV-5R) | 18-Nov-2022 | Yes | 0.12% | +| Baofeng_GM-5RH | [@KC9HI](https://github.com/KC9HI) | 21-Mar-2024 | Yes | | | Baofeng_GT-3WP | [@KC9HI](https://github.com/KC9HI) | 3-Dec-2022 | Yes | 0.43% | | Baofeng_GT-5R | [@KC9HI](https://github.com/KC9HI) | 18-Nov-2022 | Yes | 0.68% | +| Baofeng_K5-Plus | | | Yes | | | Baofeng_UV-13Pro | [@vdwel](https://github.com/vdwel) | 21-Feb-2024 | Yes | | | Baofeng_UV-17 | [@vdwel](https://github.com/vdwel) | 27-Nov-2023 | Yes | | | Baofeng_UV-17Pro | [@vdwel](https://github.com/vdwel) | 27-Nov-2023 | Yes | | @@ -113,6 +116,7 @@ | Icom_IC-7100 | Mike W | 16-Feb-2023 | Yes | 0.06% | | Icom_IC-7200 | [@kk7ds](https://github.com/kk7ds) | 22-Oct-2022 | Yes | | | Icom_IC-7300 | [@kk7ds](https://github.com/kk7ds) | 22-Oct-2022 | Yes | 0.03% | +| Icom_IC-7400 | | | Yes | | | Icom_IC-746 | [Reported working](https://chirp.danplanet.com/issues/10346) | 3-Feb-2023 | Yes | | | Icom_IC-7610 | [@kk7ds](https://github.com/kk7ds) | 24-Oct-2022 | Yes | 0.00% | | Icom_IC-910 | [@mfncooper](https://github.com/mfncooper) | 1-Oct-2021 | Yes | 0.00% | @@ -231,7 +235,7 @@ | LUITON_LT-580_VHF | [@KC9HI](https://github.com/KC9HI) | 8-Dec-2022 | Yes | 0.01% | | LUITON_LT-588UV | [@KC9HI](https://github.com/KC9HI) | 11-Nov-2022 | Yes | 0.01% | | LUITON_LT-725UV | [@KC9HI](https://github.com/KC9HI) | 11-Dec-2022 | Yes | 0.02% | -| Lanchonlh_HG-UV98 | | | Yes | 0.00% | +| Lanchonlh_HG-UV98 | [Reported working](https://chirp.danplanet.com/issues/11179) | 23-Feb-2024 | Yes | 0.00% | | Leixen_VV-898 | [Implied by Jetstream_JT270MH](#user-content-Jetstream_JT270MH) | 13-Dec-2022 | Yes | 0.16% | | Leixen_VV-898E | | | Yes | 0.02% | | Leixen_VV-898E_Dual_Bank | [Implied by Leixen_VV-898S_Dual_Bank](#user-content-Leixen_VV-898S_Dual_Bank) | 10-Feb-2024 | Yes | | @@ -452,11 +456,11 @@ | Zastone_ZT-X6 | [Implied by Retevis_RT22](#user-content-Retevis_RT22) | 9-Dec-2022 | Yes | 0.11% | ## Stats -**Drivers:** 449 +**Drivers:** 453 -**Tested:** 87% (395/54) (93% of usage stats) +**Tested:** 87% (398/55) (93% of usage stats) -**Byte clean:** 91% (410/39) +**Byte clean:** 91% (414/39) ## Meaning of this testing diff --git a/tests/__pycache__/base.cpython-310.pyc b/tests/__pycache__/base.cpython-310.pyc index 888e3bc..c2ea0fe 100644 Binary files a/tests/__pycache__/base.cpython-310.pyc and b/tests/__pycache__/base.cpython-310.pyc differ diff --git a/tests/__pycache__/test_brute_force.cpython-310-pytest-7.1.3.pyc b/tests/__pycache__/test_brute_force.cpython-310-pytest-7.1.3.pyc index cebda28..5390656 100644 Binary files a/tests/__pycache__/test_brute_force.cpython-310-pytest-7.1.3.pyc and b/tests/__pycache__/test_brute_force.cpython-310-pytest-7.1.3.pyc differ diff --git a/tests/__pycache__/test_edges.cpython-310-pytest-7.1.3.pyc b/tests/__pycache__/test_edges.cpython-310-pytest-7.1.3.pyc index 963e1f1..263d58e 100644 Binary files a/tests/__pycache__/test_edges.cpython-310-pytest-7.1.3.pyc and b/tests/__pycache__/test_edges.cpython-310-pytest-7.1.3.pyc differ diff --git a/tests/base.py b/tests/base.py index 0cf8d36..093bede 100644 --- a/tests/base.py +++ b/tests/base.py @@ -132,6 +132,14 @@ class DriverTest(unittest.TestCase): def assertEqualMem(self, a, b, ignore=None): if a.tmode == "Cross": tx_mode, rx_mode = a.cross_mode.split("->") + if ignore is None: + ignore = [] + + if a.duplex == b.duplex == 'off': + # If we're asking for duplex=off, we should not obsess over the + # driver keeping track of our offset, as it may use the offset + # field to manage the TX behavior + ignore.append('offset') a_vals = {} b_vals = {} diff --git a/tests/images/Alinco_DR735T.img b/tests/images/Alinco_DR735T.img new file mode 100644 index 0000000..a63b742 Binary files /dev/null and b/tests/images/Alinco_DR735T.img differ diff --git a/tests/images/Baofeng_GM-5RH.img b/tests/images/Baofeng_GM-5RH.img new file mode 100644 index 0000000..77ba742 Binary files /dev/null and b/tests/images/Baofeng_GM-5RH.img differ diff --git a/tests/py3_driver_testers.txt b/tests/py3_driver_testers.txt index d4a1d05..e2fbfe2 100644 --- a/tests/py3_driver_testers.txt +++ b/tests/py3_driver_testers.txt @@ -22,6 +22,7 @@ Alinco_DR06T,+Alinco_DR235T,12-Dec-2022 Alinco_DR135T,+Alinco_DR235T,12-Dec-2022 Alinco_DR235T,@kk7ds,12-Dec-2022 Alinco_DR435T,+Alinco_DR235T,12-Dec-2022 +Alinco_DR735T,@jacobcalvert,03-April-2024 Anysecu_UV-A37,@KC9HI,5-Jun-2023 Anysecu_WP-9900,@KC9HI,11-Nov-2022 Anysecu_AC-580,+Radioddity_GS-5B,17-Mar-2023 @@ -66,6 +67,7 @@ Baofeng_BF-T20FRS,@KC9HI,17-Dec-2023 Baofeng_BF-T8,@KC9HI,30-Nov-2022 Baofeng_BF-V8A,@KC9HI,28-Nov-2022 Baofeng_F-11,+Baofeng_UV-5R,18-Nov-2022 +Baofeng_GM-5RH,@KC9HI,21-Mar-2024 Baofeng_GT-3WP,@KC9HI,3-Dec-2022 Baofeng_GT-5R,@KC9HI,18-Nov-2022 Baofeng_UV-3R,@yarda,26-Sep-2022 @@ -201,6 +203,7 @@ Kenwood_TK-860,+Kenwood_TK-760,5-Dec-2022 Kenwood_TK-862,+Kenwood_TK-760,5-Dec-2022 Kenwood_TK-868,+Kenwood_TK-760,5-Dec-2022 Kenwood_TS-2000,ZS6CRW,10-Jan-2022 +Lanchonlh_HG-UV98,#11179,23-Feb-2024 Leixen_VV-898,+Jetstream_JT270MH,13-Dec-2022 Leixen_VV-898S,@READ10,19-Dec-2022 Leixen_VV-898S_Dual_Bank,#4069,10-Feb-2024 diff --git a/tests/test_edges.py b/tests/test_edges.py index a186e18..86174ed 100644 --- a/tests/test_edges.py +++ b/tests/test_edges.py @@ -188,7 +188,6 @@ class TestBitwiseStrict(base.DriverTest): def test_bitwise_unnecessary_seek(self, mock_assert): super().setUp() - @pytest.mark.xfail(strict=False) @mock.patch.object(bitwise.LOG, 'error') def test_bitwise_errors(self, mock_log): super().setUp() diff --git a/tests/unit/__pycache__/base.cpython-310.pyc b/tests/unit/__pycache__/base.cpython-310.pyc index a5f2379..7fcc6bd 100644 Binary files a/tests/unit/__pycache__/base.cpython-310.pyc and b/tests/unit/__pycache__/base.cpython-310.pyc differ diff --git a/tests/unit/__pycache__/test_alinco_clone.cpython-310-pytest-7.1.3.pyc b/tests/unit/__pycache__/test_alinco_clone.cpython-310-pytest-7.1.3.pyc index f9c396a..9811cb6 100644 Binary files a/tests/unit/__pycache__/test_alinco_clone.cpython-310-pytest-7.1.3.pyc and b/tests/unit/__pycache__/test_alinco_clone.cpython-310-pytest-7.1.3.pyc differ diff --git a/tests/unit/__pycache__/test_bitwise.cpython-310-pytest-7.1.3.pyc b/tests/unit/__pycache__/test_bitwise.cpython-310-pytest-7.1.3.pyc index 3efe7a5..109a28e 100644 Binary files a/tests/unit/__pycache__/test_bitwise.cpython-310-pytest-7.1.3.pyc and b/tests/unit/__pycache__/test_bitwise.cpython-310-pytest-7.1.3.pyc differ diff --git a/tests/unit/__pycache__/test_chirp_common.cpython-310-pytest-7.1.3.pyc b/tests/unit/__pycache__/test_chirp_common.cpython-310-pytest-7.1.3.pyc index b47cb93..e4719f6 100644 Binary files a/tests/unit/__pycache__/test_chirp_common.cpython-310-pytest-7.1.3.pyc and b/tests/unit/__pycache__/test_chirp_common.cpython-310-pytest-7.1.3.pyc differ diff --git a/tests/unit/__pycache__/test_wxui_radiothread.cpython-310-pytest-7.1.3.pyc b/tests/unit/__pycache__/test_wxui_radiothread.cpython-310-pytest-7.1.3.pyc index 1c758c2..38b9af1 100644 Binary files a/tests/unit/__pycache__/test_wxui_radiothread.cpython-310-pytest-7.1.3.pyc and b/tests/unit/__pycache__/test_wxui_radiothread.cpython-310-pytest-7.1.3.pyc differ diff --git a/tests/unit/base.py b/tests/unit/base.py index 72c554a..a9e938c 100644 --- a/tests/unit/base.py +++ b/tests/unit/base.py @@ -12,6 +12,10 @@ class BaseTest(unittest.TestCase): __builtins__['_'] = lambda s: s self.mocks = [] + def use(self, m): + self.mocks.append(m) + m.start() + def tearDown(self): for m in self.mocks: m.stop() diff --git a/tests/unit/test_alinco_clone.py b/tests/unit/test_alinco_clone.py index 5df6bcc..c5e28ca 100644 --- a/tests/unit/test_alinco_clone.py +++ b/tests/unit/test_alinco_clone.py @@ -19,7 +19,7 @@ import unittest from unittest import mock from chirp import directory -from chirp.drivers import alinco +from chirp.drivers import alinco, alinco_dr735t from chirp import memmap @@ -35,6 +35,29 @@ class FakeAlincoSerial: """Zero the mmap before an upload""" self.image = memmap.MemoryMapBytes(b'\x00' * len(self.image)) + def _handle_rw_dr735tn(self, data): + if b'R' in data: + addr_idx = data.index(b'R')-4 + elif b'W' in data: + addr_idx = data.index(b'W')-4 + else: + raise Exception('Unable to handle RW command %r' % data) + addr = int(data[addr_idx: addr_idx+4], 16) + cmd = chr(data[addr_idx+4]) + + if cmd == 'R': + bin_chunk = self.image[addr:addr+64] + hex_chunk = binascii.hexlify(bin_chunk) + assert (len(hex_chunk) == 128) + self.readbuf.append(hex_chunk) + self.readbuf.append(b'\r\n') + + if cmd == 'W': + hex_chunk = data[addr_idx+5:addr_idx+128+5].decode() + bin_chunk = binascii.unhexlify(hex_chunk) + self.image[addr] = bin_chunk + self.readbuf.append(b'OK\r\n') + def _handle_rw(self, data): if b'R' in data: cmdindex = data.index(b'R') @@ -87,8 +110,23 @@ class FakeAlincoSerial: self.readbuf.append(ident_ack) elif data.startswith(b'AL~F'): self._handle_rw(data) - elif data.startswith(b'AL~E'): + elif data.startswith(b'AL~E') and self.ident != b"DR735TN": self.readbuf.append(b'OK' * 10) + elif data.startswith(b'AL~WHO'): + # radio responds with model to WHO + self.ident = b"DR735TN" + # expect back "DR735TN\r\nOK\r\n" + self.readbuf.append(self.ident+b"\r\n") + elif data.startswith(b'AL~DR735J'): + # this is somehow making the radio writeable... + self.readbuf.append(b'OK\r\n') + + elif data.startswith(b'AL~RESET') and self.ident == b"DR735TN": + self.readbuf.append(b'OK\r\n') + + elif data.startswith(b'AL~EEPEL'): + self._handle_rw_dr735tn(data) + else: raise Exception('Unable to handle %r' % data) @@ -134,6 +172,9 @@ class AlincoCloneTest(unittest.TestCase): def test_dr235(self): self._test_alinco(alinco.DR235Radio) + def test_dr735(self): + self._test_alinco(alinco_dr735t.AlincoDR735T) + def test_dj175(self): # The 175 has a slightly different download string, so test it # specifically diff --git a/tests/unit/test_bitwise.py b/tests/unit/test_bitwise.py index 9f40dcc..3ace170 100644 --- a/tests/unit/test_bitwise.py +++ b/tests/unit/test_bitwise.py @@ -192,6 +192,16 @@ class TestBitType(BaseTest): obj.foo[i] = i % 2 self.assertEqual(data.get_packed(), b"\x55\x55\x55") + def test_lbit_array(self): + defn = "lbit foo[24];" + data = memmap.MemoryMapBytes(bytes(b"\x00\x20\x80")) + obj = bitwise.parse(defn, data) + for i, v in [(0, False), (13, True), (23, True)]: + self.assertEqual(bool(obj.foo[i]), v) + for i in range(0, 24): + obj.foo[i] = i % 2 + self.assertEqual(data.get_packed(), b"\xAA\xAA\xAA") + def test_bit_array_fail(self): self.assertRaises(ValueError, bitwise.parse, "bit foo[23];", b"000") diff --git a/tests/unit/test_chirp_common.py b/tests/unit/test_chirp_common.py index d0f22f9..9fe90ff 100644 --- a/tests/unit/test_chirp_common.py +++ b/tests/unit/test_chirp_common.py @@ -765,6 +765,7 @@ class TestOverrideRules(base.BaseTest): 'Retevis_RB17P', 'Baofeng_UV-17ProGPS', 'Baofeng_5RM', + 'Baofeng_K5-Plus', ] def _test_radio_override_immutable_policy(self, rclass): diff --git a/tests/unit/test_wxui_radiothread.py b/tests/unit/test_wxui_radiothread.py index 1088b81..aedd7c8 100644 --- a/tests/unit/test_wxui_radiothread.py +++ b/tests/unit/test_wxui_radiothread.py @@ -1,7 +1,10 @@ +import os import sys import time from unittest import mock +import ddt + sys.modules['wx'] = wx = mock.MagicMock() sys.modules['wx.lib'] = mock.MagicMock() sys.modules['wx.lib.scrolledpanel'] = mock.MagicMock() @@ -14,6 +17,7 @@ sys.modules['chirp.wxui.developer'] = mock.MagicMock() # wx to be present for these tests from tests.unit import base # noqa from chirp.wxui import clone # noqa +from chirp.wxui import config # noqa from chirp.wxui import radiothread # noqa @@ -151,3 +155,71 @@ class TestClone(base.BaseTest): 'COM17: Some other device'], [clone.port_label(p) for p in sorted(ports, key=clone.port_sort_key)]) + + +class TestException(Exception): + pass + + +@ddt.ddt +class TestStartup(base.BaseTest): + def setUp(self): + super().setUp() + self.use(mock.patch('os.path')) + self.use(mock.patch('os.makedirs')) + self.use(mock.patch('chirp.wxui.CONF')) + self.args = mock.MagicMock() + self.args.install_desktop_app = False + self.args.no_install_desktop_app = False + from chirp.wxui import maybe_install_desktop, CONF + self.maybe_install_desktop = maybe_install_desktop + self.conf = CONF + + @ddt.data( + # No arguments, no file, no previous, answer no + [False, False, False, False, False], + # No arguments, no file, no previous, answer yes + [False, False, False, False, True], + # No arguments, no file, previous yes, no prompt + [False, False, False, True, None], + # No arguments, exists, previous no, no prompt + [False, False, True, False, None], + # Opt out, no file, no prompt + [False, True, False, None, None], + # Opt in, no file, previous yes, still prompt + [True, False, False, True, True], + # Opt in, exists, previous no, no prompt'), + [True, False, True, False, None], + ) + @ddt.unpack + def test_linux_desktop_file(self, optin, optout, exists, last, answ): + self.args.install_desktop_app = optin + self.args.no_install_desktop_app = optout + os.path.exists.return_value = exists + self.conf.get_bool.return_value = last + wx.MessageBox.return_value = wx.YES if answ else wx.NO + os.makedirs.side_effect = TestException + wx.MessageBox.reset_mock() + + if answ is True: + # If we made it through all the checks, and thus prompted the user, + # make sure we get to the makedirs part if expected + self.assertRaises(TestException, + self.maybe_install_desktop, self.args) + elif answ is False: + # If we were supposed to make it to the prompt but answer no, + # make sure we did + self.maybe_install_desktop(self.args) + self.assertFalse(os.makedirs.called) + self.assertTrue(wx.MessageBox.called) + else: + # If we were not supposed to make it to the prompt, make sure we + # didn't, nor did we do any create actions + self.maybe_install_desktop(self.args) + self.assertFalse(os.makedirs.called) + self.assertFalse(wx.MessageBox.called) + + def test_linux_desktop_file_exists(self): + os.path.exists.return_value = True + self.maybe_install_desktop(self.args) + self.assertFalse(os.makedirs.called) -- cgit v1.2.3