Commit graph

17 commits

Author SHA1 Message Date
Dan Smith
62d8eb31d2 Fix 8.33kHz step calculation
This fixes the step-based frequency rounding function that Yaesu
(and a few other) radios use to determine the real frequency from the
partial one stored in memory. It also improves 8.33kHz step detection
by allowing for more remainders which are possible when more digits
are entered.

This also fixes the is_8_33() function considering 25kHz-aligned
channels to be 8.33kHz, which is not correct.

Fixes #12214
2025-10-20 15:23:20 -07:00
Dan Smith
c4d1ec32ec Enable validate_all_steps test for all, except some failing drivers 2025-02-04 19:52:50 -08:00
Dan Smith
f8dbe754f7 Fix test_dtcs and test_cross skipping
This test has been wrong for a long time, basically never properly
asserting DTCS values for drivers. The three drivers fixed immediately
before this commit should have been caught by this test, but were not
because it was always skipping the dtcs field.

Related to #11506
2024-08-31 07:03:47 -07:00
Dan Smith
985b78aa4f Make assertEqualMem() ignore offset if duplex=off
If duplex is 'off' we don't need to obsess over the offset value,
which is unused anyway. Some drivers may not be able to store an
offset if duplex=off and/or may use the offset for signaling of that
fact.
2024-03-21 16:17:10 -07:00
Dan Smith
3e672bba22 Add a way to test for compat bytes usage
A lot of radios are still relying on get_raw() returning a str instead
of a bytes. This adds an environment flag that can be used to run
without that compatibility layer to smoke out those offending drivers.
2023-11-07 16:02:52 -08:00
Dan Smith
ad73f0b53f Check mem.extra structure when comparing memories
This makes us include the *structure* of mem.extra in the
assertEqualMems() check to make sure it doesn't change before and after
a modification.
2023-11-05 10:58:51 -08:00
Dan Smith
2fce6f97d9 Refactor the calculation of required steps
This makes required_step() consider the supported steps when deciding
what to return as required. If not provided, the original set of steps
is used. It also makes validate_memory() provide the radio's supported
list and better reproduces the underlying check's error message.

This allows us to handle radios that don't support 5.0kHz
steps, which is generally assumed to be a safe default. It also allows
calculation of required steps below 2.5 for some that were in use in
the tree already.

Related to #10439
2023-03-12 15:09:58 -07:00
Dan Smith
5ad747a0bd Style cleanups for tests/ 2023-03-10 18:07:04 -08:00
Dan Smith
86180359b1 Improve TS480 tuning_step fix
This basically reverts the ts480 part of ba88b54f to restore its
ability to select the finer tuning_step values for modes like sideband.
It adds validate_memory() to reject the memories with invalid mode
and step combinations. This also changes get_mem() in the test base
class to march through the steps as it walks up the bands and memory
channels.
2023-02-23 16:01:43 -08:00
Dan Smith
ba88b54f4a Make required_step find 10kHz before 5kHz
This makes our required_step() function find 10kHz as a suitable
tuning step before 5kHz because of one radio (ft90) that has a bug
related to 5kHz and thus does not support it.

This also makes us set the tuning_step of our test memory to the first
supported one, which may not be the default of 5kHz. The TS480 driver
does some monkeywork with the tuning_step that changes per mode, which
isn't really compatible with the tests or the UI, so this also
makes a change there to just keep things working. But, more attention
is needed there.
2023-02-22 20:37:15 -08:00
Dan Smith
6c5391d561 Try a test frequency from each valid band
This makes us walk all the valid_bands looking for a frequency within
to test with. This will allow drivers to expose multiple bands for
RX-only and TRX capabilities, even if they are adjacent.

Further, if a memory validates with only warnings, set and get the
memory on the radio to resolve any corrections it may need to enforce,
such as mandatory TX frequency corrections, TX inhibit, or anything
else.
2023-02-17 18:32:44 -08:00
Dan Smith
8084170d46 Fix up tests.base.get_mem() for some radios
We were failing to delete mem.extra for radios that return memories
without an extra field even set, which caused us to not use the
first memory as a candidate. Also, don't refuse one of the virgin
memories if only warnings are raised from validate, and only use the
non-virgin one if it has immutable fields.
2023-02-03 16:03:03 -08:00
Dan Smith
78cb6a7f81 Fix test infrastructure for radios with subdevs
When I refactored the tests I did so in a way that made testing sub-
devices not work properly and as such, those were mostly not getting
run. This fixes that by handling them much more like the UI does,
which is instantiating the parent radio, getting the sub devices
and grabbing the specific one we should be using, all sourced from
a single point and the test image.

Related to #10323
2023-01-27 17:05:25 -08:00
Dan Smith
448e8ff91d Add GMRS channels to bandplan_na
This makes it possible to have the assertMemEqual() helper ignore
non-matching fields if they're marked as immutable *and* the freq
is set to one of the GMRS frequencies that has special rules.
2023-01-21 14:56:50 -08:00
Dan Smith
e91bd6b47f Make tests more tolerant of highly immutable mems
This makes us try to use the first memory in the image for testing
instead of constructing a completely new one, so that we have an idea
of immutable fields for highly-constrained radios like those with
fixed channels.

Related to #10288
2023-01-21 14:56:50 -08:00
Dan Smith
7f1493ec0d Mock out time functions in clone tests
The previous test runner mocked out the time functions to defeat
wait looping in the clone test. The broken-out test classes are
much better positioned to do that only for the clone tests (where it
matters) and with much less complexity. So, this re-implements that
shortcut on top of the new stuff.
2023-01-12 15:31:20 -08:00
Dan Smith
06176e6202 Massive driver test refactor
This has been a long time coming. Our tests have always been a bit
weird because when we added them, there weren't great ways of loading
dynamic test classes with the runners at the time. That is now much
better. With everyone running tests via tox and the unittest framework,
we can move our tests out of the adapter and into proper test cases.
We still need the custom loader to generate classes based on test
images, but it's majorly simpler and uses the hooks available.

With this, each test case is broken into proper scenarios so that
each can be run (and fail) independently. We also don't need all the
wrapper and logging stuff, which means exceptions are reported where
they actually happen, and as such, debugging what is failing should
be much easier.

The content is mostly the same, although the detect test is tightend
a bit, just because it needed rewriting anyway. That uncovered the
bug in the test images fixed a few patches ago.
2023-01-12 15:31:20 -08:00