|
3 | 3 | # SPDX-License-Identifier: Apache-2.0
|
4 | 4 |
|
5 | 5 | import argparse
|
| 6 | +import os |
6 | 7 | from pathlib import Path
|
7 | 8 | from unittest.mock import patch, call
|
8 | 9 |
|
9 | 10 | import pytest
|
10 | 11 |
|
11 | 12 | from runners.stm32cubeprogrammer import STM32CubeProgrammerBinaryRunner
|
12 |
| -from conftest import RC_KERNEL_HEX, RC_KERNEL_ELF |
13 |
| - |
| 13 | +from conftest import RC_KERNEL_HEX, RC_KERNEL_ELF, RC_KERNEL_BIN |
14 | 14 |
|
15 | 15 | CLI_PATH = Path("STM32_Programmer_CLI")
|
16 | 16 | """Default CLI path used in tests."""
|
|
436 | 436 | "--connect",
|
437 | 437 | "port=swd",
|
438 | 438 | "--download",
|
439 |
| - RC_KERNEL_HEX, |
| 439 | + RC_KERNEL_BIN, |
440 | 440 | "0x80000000",
|
441 | 441 | "0x1",
|
442 | 442 | "--start",
|
|
447 | 447 | )
|
448 | 448 | """Test cases."""
|
449 | 449 |
|
| 450 | +os_path_isfile = os.path.isfile |
| 451 | + |
| 452 | +def os_path_isfile_patch(filename): |
| 453 | + if filename == RC_KERNEL_BIN: |
| 454 | + return True |
| 455 | + return os_path_isfile(filename) |
450 | 456 |
|
451 | 457 | @pytest.mark.parametrize("tc", TEST_CASES)
|
452 | 458 | @patch("runners.stm32cubeprogrammer.platform.system")
|
|
455 | 461 | @patch.dict("runners.stm32cubeprogrammer.os.environ", ENVIRON)
|
456 | 462 | @patch("runners.core.ZephyrBinaryRunner.require")
|
457 | 463 | @patch("runners.stm32cubeprogrammer.STM32CubeProgrammerBinaryRunner.check_call")
|
| 464 | +@patch("os.path.isfile", side_effect=os_path_isfile_patch) |
458 | 465 | def test_stm32cubeprogrammer_init(
|
| 466 | + os_path_isfile_patch, |
459 | 467 | check_call, require, path_exists, path_home, system, tc, runner_config
|
460 | 468 | ):
|
461 | 469 | """Tests that ``STM32CubeProgrammerBinaryRunner`` class can be initialized
|
@@ -494,7 +502,9 @@ def test_stm32cubeprogrammer_init(
|
494 | 502 | @patch.dict("runners.stm32cubeprogrammer.os.environ", ENVIRON)
|
495 | 503 | @patch("runners.core.ZephyrBinaryRunner.require")
|
496 | 504 | @patch("runners.stm32cubeprogrammer.STM32CubeProgrammerBinaryRunner.check_call")
|
| 505 | +@patch("os.path.isfile", side_effect=os_path_isfile_patch) |
497 | 506 | def test_stm32cubeprogrammer_create(
|
| 507 | + os_path_isfile_patch, |
498 | 508 | check_call, require, path_exists, path_home, system, tc, runner_config
|
499 | 509 | ):
|
500 | 510 | """Tests that ``STM32CubeProgrammerBinaryRunner`` class can be created using
|
|
0 commit comments