From 94aaf25cb2496494e9e7673ec281643afe13ee92 Mon Sep 17 00:00:00 2001 From: "-T.K.-" Date: Sun, 8 Sep 2024 15:33:06 -0700 Subject: [PATCH] FIX: fix Python output file location --- tests/CMakeLists.txt | 2 +- tests/spiflash.py | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 7372e87780..34bc236fb0 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -92,7 +92,7 @@ add_executable(symmetric symmetric.c) # Add custom command to generate spiflash.img from spiflash.py add_custom_command( OUTPUT ${CMAKE_BINARY_DIR}/spiflash.img - COMMAND python3 ${CMAKE_SOURCE_DIR}/spiflash.py + COMMAND python3 ${CMAKE_SOURCE_DIR}/spiflash.py --outfile ${CMAKE_BINARY_DIR}/spiflash.img DEPENDS ${CMAKE_SOURCE_DIR}/spiflash.py COMMENT "Generating spiflash.img" ) diff --git a/tests/spiflash.py b/tests/spiflash.py index af65b64e9a..1bf6a0d235 100755 --- a/tests/spiflash.py +++ b/tests/spiflash.py @@ -1,10 +1,16 @@ #!/usr/bin/env python3 - # Generates a binary file that the SPI test uses -outfile = "spiflash.img" +import argparse + +if __name__ == "__main__": + parser = argparse.ArgumentParser(description="Generate a binary file for SPI test") + parser.add_argument("--outfile", type=str, default="spiflash.img", help="Output file") + args = parser.parse_args() + + outfile = args.outfile -with open(outfile, 'wb') as f: - for i in range(0,0x100000,4): - check = 0xdeadbeef - i - f.write(check.to_bytes(4,'little')) + with open(outfile, "wb") as f: + for i in range(0,0x100000,4): + check = 0xdeadbeef - i + f.write(check.to_bytes(4, "little"))