|
|
@@ -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/<src_file> asm/full/.output.gg |
|
|
|
// ../crater --assemble asm/<src_file> 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() |
|
|
|