Browse Source

Merge full ASM tests into regular ASM tests.

master
Ben Kurtovic 8 years ago
parent
commit
3f12049ee5
8 changed files with 45 additions and 51 deletions
  1. +1
    -1
      .gitignore
  2. +1
    -1
      makefile
  3. +0
    -0
      tests/asm/empty.asm
  4. BIN
     
  5. +0
    -0
      tests/asm/manifest
  6. BIN
     
  7. +3
    -3
      tests/makefile
  8. +40
    -46
      tests/runner.c

+ 1
- 1
.gitignore View File

@@ -4,4 +4,4 @@ roms/*
crater crater
crater-dev crater-dev
tests/runner tests/runner
tests/asm/full/*.gg
tests/asm/*.gg

+ 1
- 1
makefile View File

@@ -42,7 +42,7 @@ all: $(BNRY)


clean: clean:
$(RM) $(BUILD) $(PROGRAM) $(PROGRAM)$(DEVEXT) $(RM) $(BUILD) $(PROGRAM) $(PROGRAM)$(DEVEXT)
$(MAKE) -C tests clean
@$(MAKE) -C tests clean


$(DIRS): $(DIRS):
$(MKDIR) $@ $(MKDIR) $@


tests/asm/full/empty.asm → tests/asm/empty.asm View File


BIN
View File


tests/asm/full/manifest → tests/asm/manifest View File


BIN
View File


+ 3
- 3
tests/makefile View File

@@ -10,7 +10,7 @@ all: $(COMPONENTS)


clean: clean:
$(RM) $(RUNNER) $(RM) $(RUNNER)
rm asm/full/*.gg
$(RM) asm/*.gg


$(RUNNER): $(RUNNER).c $(RUNNER): $(RUNNER).c
$(CC) $(FLAGS) $< -o $@ $(CC) $(FLAGS) $< -o $@
@@ -21,7 +21,7 @@ $(COMPONENTS): $(RUNNER)
asm: asm-unarchive asm: asm-unarchive


asm-archive: asm-archive:
tar -czf asm/full/roms.tar.gz asm/full/*.gg
tar -czf asm/roms.tar.gz asm/*.gg


asm-unarchive: asm-unarchive:
tar -xf asm/full/roms.tar.gz
tar -xf asm/roms.tar.gz

+ 40
- 46
tests/runner.c View File

@@ -10,8 +10,8 @@
#include "../src/logging.h" #include "../src/logging.h"
#include "../src/util.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 */ /* 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 Run a single ASM->ROM test, converting the given source file to a temporary
output file, compared against the reference file. 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) * char *cmd = cr_malloc(sizeof(char) *
(strlen(cmd_prefix) + strlen(ASM_OUTFILE) + strlen(src_file)) + 2); (strlen(cmd_prefix) + strlen(ASM_OUTFILE) + strlen(src_file)) + 2);


// Construct the command by concatenating: // 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); stpcpy(stpcpy(stpcpy(cmd, cmd_prefix), src_file), " " ASM_OUTFILE);
unlink(ASM_OUTFILE); unlink(ASM_OUTFILE);
system(cmd); 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 // Construct the full reference file path in a temporary variable and diff
// it with the output file: // it with the output file:
char *ref_path = malloc(sizeof(char) * 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); bool diff = diff_files(ref_path, ASM_OUTFILE);
free(ref_path); free(ref_path);
return diff; 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) { if (!fp) {
ERROR_ERRNO("couldn't open manifest file") ERROR_ERRNO("couldn't open manifest file")
return false; return false;
@@ -160,7 +189,7 @@ static bool run_full_asm_tests()
} }


*(split++) = '\0'; *(split++) = '\0';
if (!run_full_asm_test(line, split)) {
if (!run_asm_test(line, split)) {
fprintf(stderr, "test: %s -> %s\n", line, split); fprintf(stderr, "test: %s -> %s\n", line, split);
return false; 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. Run tests for the disassembler.
*/ */
static bool test_dis() static bool test_dis()


Loading…
Cancel
Save