Commit graph

6 commits

Author SHA1 Message Date
Henrik Brix Andersen bf598848b1 scripts: west: commands: tests: dfu_util: fix test under Python 3.12
Use "call_args_list" from unittest.mock instead of "called_with" for
verifying the arguments supplied to the dfu-util west runner.

This aligns the assert with the rest of the test case and fixes the
dfu-util west runner test when running under Python 3.12.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2023-10-26 07:17:10 +02:00
Jamie McCrae ec7044437e treewide: Disable automatic argparse argument shortening
Disables allowing the python argparse library from automatically
shortening command line arguments, this prevents issues whereby
a new command is added and code that wrongly uses the shortened
command of an existing argument which is the same as the new
command being added will silently change script behaviour.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-01-26 20:12:36 +09:00
Martí Bolívar 778a18cb1a runners: tests: don't patch BuildConfiguration
Instead of mocking out the BuildConfiguration class, just create its
input file and let the real class do the work.

This in turn exposes a bug in the way the board name is being pulled
out of the BuildConfiguration, which we fix to keep the tests passing.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-05-03 09:55:33 -05:00
Martí Bolívar 09f55767b1 runners: tests: fix os.path.isfile patch
Copy a fix from test_nrfjprog.py to the other runner test suites. The
current code will enter an infinite recursion if you hit the path
where os.path.isfile is called, since it's been patched to
os_path_isfile_patch in the calling context. The fix is to cache the
'real' version in the parent scope and call it directly as a fallback.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-05-03 09:55:33 -05:00
Martí Bolívar 3204554841 scripts: runners: error on missing non-elf outputs
The RunnerConfig class stores the locations of the Zephyr output files
in various formats (elf, hex, bin). A longstanding issue with the
representation is that these might not exist if the corresponding
Kconfig options are not set. For example, if
CONFIG_BUILD_OUTPUT_BIN=n, there is no .bin file.

Change this so the type system knows these are Optional[str], not str.

Fix the runners that use non-ELF outputs so they check for the
existence of the relevant file before using it, mostly using a new
ZephyrBinaryRunner.ensure_output helper.

I'm not going to bother with checking for the ELF file itself; that's
always there as far as I can tell.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-02-02 14:01:22 -05:00
Marti Bolivar c24e044c6e scripts: runners: check for required programs
Add self.require() checks before running commands. Increase test
coverage, including for this feature, while we are here.

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
2019-06-17 15:06:21 +02:00