diff --git a/.gitignore b/.gitignore index b3b5627..bdf39ee 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,4 @@ roms/* crater crater-dev tests/runner -tests/asm/full/*.gg +tests/asm/*.gg diff --git a/makefile b/makefile index fdd9618..6793148 100644 --- a/makefile +++ b/makefile @@ -42,7 +42,7 @@ all: $(BNRY) clean: $(RM) $(BUILD) $(PROGRAM) $(PROGRAM)$(DEVEXT) - $(MAKE) -C tests clean + @$(MAKE) -C tests clean $(DIRS): $(MKDIR) $@ diff --git a/tests/asm/full/empty.asm b/tests/asm/empty.asm similarity index 100% rename from tests/asm/full/empty.asm rename to tests/asm/empty.asm diff --git a/tests/asm/full/roms.tar.gz b/tests/asm/full/roms.tar.gz deleted file mode 100644 index 0c2c3e8..0000000 Binary files a/tests/asm/full/roms.tar.gz and /dev/null differ diff --git a/tests/asm/full/manifest b/tests/asm/manifest similarity index 100% rename from tests/asm/full/manifest rename to tests/asm/manifest diff --git a/tests/asm/roms.tar.gz b/tests/asm/roms.tar.gz new file mode 100644 index 0000000..7714e89 Binary files /dev/null and b/tests/asm/roms.tar.gz differ diff --git a/tests/makefile b/tests/makefile index b2da06d..fb7b410 100644 --- a/tests/makefile +++ b/tests/makefile @@ -10,7 +10,7 @@ all: $(COMPONENTS) clean: $(RM) $(RUNNER) - rm asm/full/*.gg + $(RM) asm/*.gg $(RUNNER): $(RUNNER).c $(CC) $(FLAGS) $< -o $@ @@ -21,7 +21,7 @@ $(COMPONENTS): $(RUNNER) asm: asm-unarchive asm-archive: - tar -czf asm/full/roms.tar.gz asm/full/*.gg + tar -czf asm/roms.tar.gz asm/*.gg asm-unarchive: - tar -xf asm/full/roms.tar.gz + tar -xf asm/roms.tar.gz diff --git a/tests/runner.c b/tests/runner.c index 40b5cb5..341ed80 100644 --- a/tests/runner.c +++ b/tests/runner.c @@ -10,8 +10,8 @@ #include "../src/logging.h" #include "../src/util.h" -#define ASM_FULL "asm/full/" -#define ASM_OUTFILE ASM_FULL ".output.gg" +#define ASM_PREFIX "asm/" +#define ASM_OUTFILE ASM_PREFIX ".output.gg" /* Helper macros for reporting test passings/failures */ @@ -106,14 +106,14 @@ static bool diff_files(const char *expected_path, const char *actual_path) Run a single ASM->ROM test, converting the given source file to a temporary output file, compared against the reference file. */ -static bool run_full_asm_test(const char *src_file, const char *ref_file) +static bool run_asm_test(const char *src_file, const char *ref_file) { - char *cmd_prefix = "../crater --assemble " ASM_FULL; + char *cmd_prefix = "../crater --assemble " ASM_PREFIX; char *cmd = cr_malloc(sizeof(char) * (strlen(cmd_prefix) + strlen(ASM_OUTFILE) + strlen(src_file)) + 2); // Construct the command by concatenating: - // ../crater --assemble asm/full/ asm/full/.output.gg + // ../crater --assemble asm/ asm/.output.gg stpcpy(stpcpy(stpcpy(cmd, cmd_prefix), src_file), " " ASM_OUTFILE); unlink(ASM_OUTFILE); system(cmd); @@ -122,19 +122,48 @@ static bool run_full_asm_test(const char *src_file, const char *ref_file) // Construct the full reference file path in a temporary variable and diff // it with the output file: char *ref_path = malloc(sizeof(char) * - (strlen(ASM_FULL) + strlen(ref_file) + 1)); - stpcpy(stpcpy(ref_path, ASM_FULL), ref_file); + (strlen(ASM_PREFIX) + strlen(ref_file) + 1)); + stpcpy(stpcpy(ref_path, ASM_PREFIX), ref_file); bool diff = diff_files(ref_path, ASM_OUTFILE); free(ref_path); return diff; } +/* --------------------------- Main test runners --------------------------- */ + +/* + Run tests for the Z80 CPU. +*/ +static bool test_cpu() +{ + // TODO + return true; +} + +/* + Run tests for the VDP. +*/ +static bool test_vdp() +{ + // TODO + return true; +} + +/* + Run tests for the SN76489 PSG. +*/ +static bool test_psg() +{ + // TODO + return true; +} + /* - Run all "full"/"complete" ASM->ROM tests. + Run tests for the assembler. */ -static bool run_full_asm_tests() +static bool test_asm() { - FILE *fp = fopen(ASM_FULL "manifest", "r"); + FILE *fp = fopen(ASM_PREFIX "manifest", "r"); if (!fp) { ERROR_ERRNO("couldn't open manifest file") return false; @@ -160,7 +189,7 @@ static bool run_full_asm_tests() } *(split++) = '\0'; - if (!run_full_asm_test(line, split)) { + if (!run_asm_test(line, split)) { fprintf(stderr, "test: %s -> %s\n", line, split); return false; } @@ -173,41 +202,6 @@ static bool run_full_asm_tests() } /* - Run tests for the Z80 CPU. -*/ -static bool test_cpu() -{ - // TODO - return true; -} - -/* - Run tests for the VDP. -*/ -static bool test_vdp() -{ - // TODO - return true; -} - -/* - Run tests for the SN76489 PSG. -*/ -static bool test_psg() -{ - // TODO - return true; -} - -/* - Run tests for the assembler. -*/ -static bool test_asm() -{ - return run_full_asm_tests(); -} - -/* Run tests for the disassembler. */ static bool test_dis()