From 3d369f28632de767c5abaa395ee417799cd569d5 Mon Sep 17 00:00:00 2001 From: Daniel Serpell Date: Sun, 4 Aug 2024 00:35:30 -0400 Subject: [PATCH] Pass command line arguments to compiler in the testsuite. This allows testing the command line parsing in the testsuite. --- tests.mak | 1 + testsuite/mini65 | 2 +- testsuite/src/fbtest.c | 25 +++++++++++++++---------- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/tests.mak b/tests.mak index 12ccae1..ac08f26 100644 --- a/tests.mak +++ b/tests.mak @@ -24,6 +24,7 @@ RUNTEST=build/bin/fbtest$(HOST_EXT) MINI65_SRC=\ atari.c\ + ataridos.c\ atcio.c\ atsio.c\ dosfname.c\ diff --git a/testsuite/mini65 b/testsuite/mini65 index 1d88b9b..661609b 160000 --- a/testsuite/mini65 +++ b/testsuite/mini65 @@ -1 +1 @@ -Subproject commit 1d88b9b9542c751b6fea2ca08f3f0d0e6e18f2de +Subproject commit 661609bf8fc4388fb9e9702ebf1566ff0150a979 diff --git a/testsuite/src/fbtest.c b/testsuite/src/fbtest.c index 634da63..7f782f2 100644 --- a/testsuite/src/fbtest.c +++ b/testsuite/src/fbtest.c @@ -89,7 +89,7 @@ static int str_get_char(void) // Runs atari XEX file capturing the output static int run_atari_prog(const char *progname, char *output, size_t *output_len, const char *input, size_t input_len, uint64_t max_cycles, - int is_rom) + int is_rom, const char *cmdline) { // Init input/output str_in = input; @@ -105,6 +105,12 @@ static int run_atari_prog(const char *progname, char *output, size_t *output_len return -1; // sim65_set_debug(s, sim65_debug_trace); atari_init(s, str_get_char, str_put_char, 1); + // Add command line + atari_dos_add_cmdline(s, progname); + if (cmdline) + atari_dos_add_cmdline(s, cmdline); + // Set DOS path + atari_dos_set_root(s, output_dir); // Use 0 as left-margin value, to normalize results unsigned char val = 0; sim65_add_data_ram(s, 0x52, &val, 1); // LMARGN @@ -143,12 +149,6 @@ static int run_atari_prog(const char *progname, char *output, size_t *output_len return x; } -static int run_atari_xex(const char *xexname, char *output, size_t *output_len, - const char *input, size_t input_len, uint64_t max_cycles) -{ - return run_atari_prog(xexname, output, output_len, input, input_len, max_cycles, 0); -} - // Run's an XEX file testing if the output matches the expected output int run_test_xex(const char *fname, const char *input, const char *expected_out, uint64_t max_cycles, int rom) @@ -156,7 +156,7 @@ int run_test_xex(const char *fname, const char *input, const char *expected_out, size_t len = strlen(expected_out) + 128; char *out = calloc(len + 1, 1); - int e = run_atari_prog(fname, out, &len, input, strlen(input), max_cycles, rom); + int e = run_atari_prog(fname, out, &len, input, strlen(input), max_cycles, rom, 0); if (!e) { // Check @@ -225,8 +225,13 @@ static int compile_native(const char *atbname, const char *xexname, const char * char *err = 0; size_t len = 2047; unlink(xexname); - sprintf(cmd, "%s\x9b%s\x9b\x9b", atbname, xexname); - int e = run_atari_xex(fb_atari_compiler, out, &len, cmd, strlen(cmd), MAX_FPC_CYCLES); + // Remove output dir from paths + const size_t l = strlen(output_dir); + if (strncmp(atbname, output_dir, l) || strncmp(xexname, output_dir, l)) + sprintf(cmd, "%s %s", atbname, xexname); + else + sprintf(cmd, "%s %s", atbname + l, xexname + l); + int e = run_atari_prog(fb_atari_compiler, out, &len, 0, 0, MAX_FPC_CYCLES, 0, cmd); if (e) fprintf(stderr, "%s: can't execute compiler.\n", fb_atari_compiler);