summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/__pycache__/base.cpython-310.pycbin5375 -> 5465 bytes
-rw-r--r--tests/__pycache__/test_brute_force.cpython-310-pytest-7.1.3.pycbin6661 -> 6686 bytes
-rw-r--r--tests/base.py10
-rw-r--r--tests/driver_xfails.yaml36
-rw-r--r--tests/images/Radtel_RT-900.imgbin0 -> 62249 bytes
-rw-r--r--tests/images/Radtel_RT-900_BT.imgbin0 -> 62257 bytes
-rw-r--r--tests/images/Radtel_RT-910.imgbin0 -> 62249 bytes
-rw-r--r--tests/images/Radtel_RT-910_BT.imgbin0 -> 62257 bytes
-rw-r--r--tests/images/Radtel_RT-920.imgbin0 -> 62265 bytes
-rw-r--r--tests/images/Retevis_HA1G.imgbin0 -> 55545 bytes
-rw-r--r--tests/images/Retevis_HA1UV.imgbin0 -> 55569 bytes
-rw-r--r--tests/images/Retevis_MA1.imgbin0 -> 65485 bytes
-rw-r--r--tests/images/Vertex_Standard_FTL-2011.imgbin589 -> 0 bytes
-rw-r--r--tests/images/Vertex_Standard_VXA-700.imgbin4096 -> 0 bytes
-rw-r--r--tests/test_brute_force.py4
-rw-r--r--tests/unit/__pycache__/test_bitwise.cpython-310-pytest-7.1.3.pycbin18843 -> 22655 bytes
-rw-r--r--tests/unit/__pycache__/test_chirp_common.cpython-310-pytest-7.1.3.pycbin33055 -> 33883 bytes
-rw-r--r--tests/unit/test_bitwise.py114
-rw-r--r--tests/unit/test_chirp_common.py38
19 files changed, 165 insertions, 37 deletions
diff --git a/tests/__pycache__/base.cpython-310.pyc b/tests/__pycache__/base.cpython-310.pyc
index 0d22964..f1054ea 100644
--- a/tests/__pycache__/base.cpython-310.pyc
+++ b/tests/__pycache__/base.cpython-310.pyc
Binary files 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 7cd6a5e..4f6f2ab 100644
--- 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
Binary files differ
diff --git a/tests/base.py b/tests/base.py
index af29310..c6ed191 100644
--- a/tests/base.py
+++ b/tests/base.py
@@ -79,6 +79,16 @@ class DriverTest(unittest.TestCase):
attempt = 0
for band_lo, band_hi in self.rf.valid_bands:
m.freq = band_lo
+ if chirp_common.is_airband(m.freq):
+ # Air band requires special step handling.
+ # First see if we can pick a 2m frequency to avoid airband
+ # details.
+ if chirp_common.in_range(146520000, self.rf.valid_bands):
+ m.freq = 146520000
+ else:
+ # Nope, so go 25kHz up from the bottom of the band to
+ # avoid 8.33kHz issues
+ m.freq += 25000
if self.rf.valid_tuning_steps:
# If we have valid tuning steps, go one step above the
# bottom of the band. Select a different tuning_step each
diff --git a/tests/driver_xfails.yaml b/tests/driver_xfails.yaml
index 6064656..a60b646 100644
--- a/tests/driver_xfails.yaml
+++ b/tests/driver_xfails.yaml
@@ -13,50 +13,14 @@ BTECH_GMRS-20V2:
- class: TestCaseBruteForce
test: test_validate_all
reason: Improper application of the duplex policy
-BTECH_GMRS-V2:
- - class: TestCaseBruteForce
- test: test_validate_all
- reason: Improper application of the duplex policy
-BTECH_GMRS-50X1:
- - class: TestCaseBruteForce
- test: test_validate_all
- reason: Improper application of the duplex policy
BTECH_GMRS-50V2:
- class: TestCaseBruteForce
test: test_validate_all
reason: Improper application of the duplex policy
-BTECH_MURS-V2:
- - class: TestCaseBruteForce
- test: test_validate_all
- reason: Improper application of the duplex policy
Abbree_AR-730:
- class: TestCaseBruteForce
test: test_validate_all
reason: Broken name stored in memory 256?
-Radtel_RT-730:
- - class: TestCaseBruteForce
- test: test_validate_all
- reason: Improper application of the duplex policy
-Retevis_RB17P:
- - class: TestCaseBruteForce
- test: test_validate_all
- reason: Improper application of the duplex policy
-TIDRADIO_TD-H3:
- - class: TestCaseBruteForce
- test: test_validate_all
- reason: Memory 3 stored with TX outside TX range
-TIDRADIO_TD-H8:
- - class: TestCaseBruteForce
- test: test_validate_all
- reason: Memory 6 stored with TX outside TX range
-TIDRADIO_TD-H8-GMRS:
- - class: TestCaseBruteForce
- test: test_validate_all
- reason: Memory 31 stored with TX outside gmrs bands
-TIDRADIO_TD-H8-HAM:
- - class: TestCaseBruteForce
- test: test_validate_all
- reason: Memory 31 stored with TX outside ham bands
Yaesu_FT-90:
- class: TestCaseBruteForce
test: test_validate_all
diff --git a/tests/images/Radtel_RT-900.img b/tests/images/Radtel_RT-900.img
new file mode 100644
index 0000000..f397c04
--- /dev/null
+++ b/tests/images/Radtel_RT-900.img
Binary files differ
diff --git a/tests/images/Radtel_RT-900_BT.img b/tests/images/Radtel_RT-900_BT.img
new file mode 100644
index 0000000..6c890aa
--- /dev/null
+++ b/tests/images/Radtel_RT-900_BT.img
Binary files differ
diff --git a/tests/images/Radtel_RT-910.img b/tests/images/Radtel_RT-910.img
new file mode 100644
index 0000000..355c76c
--- /dev/null
+++ b/tests/images/Radtel_RT-910.img
Binary files differ
diff --git a/tests/images/Radtel_RT-910_BT.img b/tests/images/Radtel_RT-910_BT.img
new file mode 100644
index 0000000..235d21a
--- /dev/null
+++ b/tests/images/Radtel_RT-910_BT.img
Binary files differ
diff --git a/tests/images/Radtel_RT-920.img b/tests/images/Radtel_RT-920.img
new file mode 100644
index 0000000..7f6afe0
--- /dev/null
+++ b/tests/images/Radtel_RT-920.img
Binary files differ
diff --git a/tests/images/Retevis_HA1G.img b/tests/images/Retevis_HA1G.img
new file mode 100644
index 0000000..eaabb41
--- /dev/null
+++ b/tests/images/Retevis_HA1G.img
Binary files differ
diff --git a/tests/images/Retevis_HA1UV.img b/tests/images/Retevis_HA1UV.img
new file mode 100644
index 0000000..a989840
--- /dev/null
+++ b/tests/images/Retevis_HA1UV.img
Binary files differ
diff --git a/tests/images/Retevis_MA1.img b/tests/images/Retevis_MA1.img
new file mode 100644
index 0000000..dbe9632
--- /dev/null
+++ b/tests/images/Retevis_MA1.img
Binary files differ
diff --git a/tests/images/Vertex_Standard_FTL-2011.img b/tests/images/Vertex_Standard_FTL-2011.img
deleted file mode 100644
index 5eff340..0000000
--- a/tests/images/Vertex_Standard_FTL-2011.img
+++ /dev/null
Binary files differ
diff --git a/tests/images/Vertex_Standard_VXA-700.img b/tests/images/Vertex_Standard_VXA-700.img
deleted file mode 100644
index e0dbbc0..0000000
--- a/tests/images/Vertex_Standard_VXA-700.img
+++ /dev/null
Binary files differ
diff --git a/tests/test_brute_force.py b/tests/test_brute_force.py
index f3bd68f..0114868 100644
--- a/tests/test_brute_force.py
+++ b/tests/test_brute_force.py
@@ -197,11 +197,13 @@ class TestCaseBruteForce(base.DriverTest):
lo, hi = self.rf.memory_bounds
for i in range(lo, hi + 1):
m1 = self.radio.get_memory(i)
+ if m1.empty:
+ continue
errs, warns = chirp_common.split_validation_msgs(
self.radio.validate_memory(m1))
self.assertEqual([], errs,
('Radio has validation errors for memory %i '
- 'stored in sample image') % i)
+ 'stored in sample image: %s') % (i, m1))
@base.requires_feature('has_nostep_tuning', equal=False)
def test_validate_all_steps(self):
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 bdb9f73..0e83cfc 100644
--- 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
Binary files 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 95787cc..21ab85f 100644
--- 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
Binary files differ
diff --git a/tests/unit/test_bitwise.py b/tests/unit/test_bitwise.py
index c50c3fc..1e88194 100644
--- a/tests/unit/test_bitwise.py
+++ b/tests/unit/test_bitwise.py
@@ -395,6 +395,120 @@ class TestBitwiseStructTypes(BaseTest):
self.assertEqual(ord('1'), obj.foo[0].bar)
+class TestBitwiseUnionTypes(BaseTest):
+ def test_union_one_element(self):
+ defn = 'union { u8 bar; } foo;'
+ data = memmap.MemoryMapBytes(bytes(b'\x80'))
+ obj = bitwise.parse(defn, data)
+ self.assertEqual(128, obj.foo.bar)
+
+ def test_union_two_elements(self):
+ defn = 'union { u8 bar; u8 baz; } foo;'
+ data = memmap.MemoryMapBytes(bytes(b'\x80'))
+ obj = bitwise.parse(defn, data)
+ self.assertEqual(128, obj.foo.bar)
+ self.assertEqual(128, obj.foo.baz)
+ obj.foo.baz = 1
+ self.assertEqual(1, obj.foo.baz)
+ self.assertEqual(1, obj.foo.bar)
+ obj.foo.bar = 2
+ self.assertEqual(2, obj.foo.baz)
+ self.assertEqual(2, obj.foo.bar)
+
+ def test_empty_union(self):
+ defn = 'union { } foo;'
+ data = memmap.MemoryMapBytes(bytes(b'\x80'))
+ self.assertRaises(SyntaxError, bitwise.parse, defn, data)
+
+ def test_union_size_mismatch(self):
+ defn = 'union { u16 bar; u8 baz; } foo;'
+ data = memmap.MemoryMapBytes(bytes(b'\x80'))
+ self.assertRaises(bitwise.ParseError, bitwise.parse, defn, data)
+
+ def test_union_adjacent(self):
+ # Make sure that unions don't mess up adjacent fields
+ defn = 'u8 pre; union { u8 bar; u8 baz; } foo; u8 post;'
+ data = memmap.MemoryMapBytes(bytes(b'\x01\x02\x03'))
+ obj = bitwise.parse(defn, data)
+ self.assertEqual(1, obj.pre)
+ self.assertEqual(2, obj.foo.bar)
+ self.assertEqual(2, obj.foo.baz)
+ self.assertEqual(3, obj.post)
+ obj.pre = 4
+ obj.foo.baz = 5
+ obj.post = 6
+ self.assertEqual(4, obj.pre)
+ self.assertEqual(5, obj.foo.bar)
+ self.assertEqual(5, obj.foo.baz)
+ self.assertEqual(6, obj.post)
+
+ def test_complex_union(self):
+ defn = """u8 pre;
+ union {
+ u16 whole;
+ struct { u8 lo; u8 hi; } bytes;
+ union { u16 big; ul16 little; } endian;
+ bbcd digits[2];
+ } foo;
+ u8 post;
+ """
+ data = memmap.MemoryMapBytes(bytes(b'\x01\x02\x03\x04'))
+ obj = bitwise.parse(defn, data)
+
+ self.assertEqual(1, obj.pre)
+ self.assertEqual(4, obj.post)
+ self.assertEqual(0x0203, obj.foo.whole)
+ self.assertEqual(2, obj.foo.bytes.lo)
+ self.assertEqual(3, obj.foo.bytes.hi)
+ self.assertEqual(0x0203, obj.foo.endian.big)
+ self.assertEqual(0x0302, obj.foo.endian.little)
+ self.assertEqual(2, int(obj.foo.digits[0]))
+ self.assertEqual(3, int(obj.foo.digits[1]))
+
+ obj.foo.bytes.lo = 5
+ self.assertEqual(1, obj.pre)
+ self.assertEqual(4, obj.post)
+ self.assertEqual(0x0503, obj.foo.whole)
+ self.assertEqual(5, obj.foo.bytes.lo)
+ self.assertEqual(3, obj.foo.bytes.hi)
+ self.assertEqual(0x0503, obj.foo.endian.big)
+ self.assertEqual(0x0305, obj.foo.endian.little)
+ self.assertEqual(5, int(obj.foo.digits[0]))
+ self.assertEqual(3, int(obj.foo.digits[1]))
+
+ def test_union_array(self):
+ defn = 'union { u8 bar; u8 baz; } foo[2];'
+ data = memmap.MemoryMapBytes(bytes(b'\x01\x02'))
+ obj = bitwise.parse(defn, data)
+ self.assertEqual(1, obj.foo[0].bar)
+ self.assertEqual(1, obj.foo[0].baz)
+ self.assertEqual(2, obj.foo[1].bar)
+ self.assertEqual(2, obj.foo[1].baz)
+ obj.foo[0].bar = 3
+ obj.foo[1].baz = 4
+ self.assertEqual(3, obj.foo[0].bar)
+ self.assertEqual(3, obj.foo[0].baz)
+ self.assertEqual(4, obj.foo[1].bar)
+ self.assertEqual(4, obj.foo[1].baz)
+
+ def test_struct_size_with_union(self):
+ # Make sure to include a bitfield at the start of the union to
+ # confirm that we properly account for the union size separately.
+ defn = ('struct { u8 pre; union { u8 bar1:4, bar2:4; u8 baz; } foo; '
+ 'u8 post; } st;')
+ data = memmap.MemoryMapBytes(bytes(b'\x01\x02\x03'))
+ obj = bitwise.parse(defn, data)
+ # Make sure the union is counted as a single byte
+ self.assertEqual(8 * 3, obj.st.size())
+
+ # Make sure raw operations work across unions
+ obj.st.set_raw(b'\x00' * 3)
+ self.assertEqual(0, obj.st.foo.bar1)
+ obj.st.fill_raw(b'\xFF')
+ self.assertEqual(0x0F, obj.st.foo.bar1)
+ self.assertEqual(b'\xFF\xFF\xFF', obj.st.get_raw())
+
+
class TestBitwisePrintoffset(BaseTest):
@mock.patch.object(bitwise.LOG, 'debug')
def test_printoffset(self, mock_log):
diff --git a/tests/unit/test_chirp_common.py b/tests/unit/test_chirp_common.py
index 0edce51..e4c2556 100644
--- a/tests/unit/test_chirp_common.py
+++ b/tests/unit/test_chirp_common.py
@@ -310,6 +310,15 @@ class TestUtilityFunctions(base.BaseTest):
for s in invalid:
self.assertRaises(ValueError, chirp_common.parse_power, s)
+ def test_airband(self):
+ self.assertTrue(chirp_common.is_airband(108000000))
+ self.assertTrue(chirp_common.is_airband(108000000 + 25000))
+ self.assertTrue(chirp_common.is_airband(136000000 - 25000))
+ self.assertTrue(chirp_common.is_airband(136000000))
+
+ self.assertFalse(chirp_common.is_airband(108000000 - 1))
+ self.assertFalse(chirp_common.is_airband(137000000 + 1))
+
class TestSplitTone(base.BaseTest):
def _test_split_tone_decode(self, tx, rx, **vals):
@@ -552,6 +561,35 @@ class TestStepFunctions(base.BaseTest):
self.assertEqual(146520000,
chirp_common.fix_rounded_step(146520000))
+ def test_fix_rounded_step_833(self):
+ # 108.008 should be aligned to 8.33kHz step
+ self.assertEqual(
+ int(108000000 + (25000 / 3)),
+ chirp_common.fix_rounded_step(chirp_common.to_MHz(108.008)))
+
+ # 108.0 MHz should be left unchanged as it is 25kHz-aligned
+ self.assertFalse(chirp_common.is_8_33(
+ chirp_common.to_MHz(108)))
+ self.assertEqual(chirp_common.to_MHz(108),
+ chirp_common.fix_rounded_step(
+ chirp_common.to_MHz(108)))
+
+ # 108.025 MHz should be left unchanged
+ self.assertFalse(chirp_common.is_8_33(
+ chirp_common.to_MHz(108.025)))
+ self.assertEqual(chirp_common.to_MHz(108.025),
+ chirp_common.fix_rounded_step(
+ chirp_common.to_MHz(108.025)))
+
+ # Even though 146.008333 is a valid 8.33kHz step, we should
+ # not align it as such since it is not in airband
+ self.assertTrue(chirp_common.is_8_33(
+ chirp_common.to_MHz(146.008333)))
+ self.assertRaisesRegex(errors.InvalidDataError,
+ 'Unable to correct.*',
+ chirp_common.fix_rounded_step,
+ chirp_common.to_MHz(146.008333))
+
class TestImageMetadata(base.BaseTest):
def test_make_metadata(self):