diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 7372e8778..34bc236fb 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 af65b64e9..1bf6a0d23 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"))