Modify test files to account for reorg

This commit is contained in:
Peter Evans 2018-04-13 18:36:02 -05:00
parent 5db0c3b9c0
commit a43fe0d38e
25 changed files with 160 additions and 242 deletions

View File

@ -1,8 +1,8 @@
#include <criterion/criterion.h>
#include "apple2.bank.h"
#include "apple2.h"
#include "apple2.tests.h"
#include "apple2/apple2.h"
#include "apple2/bank.h"
#include "apple2/tests.h"
#include "vm_segment.h"
TestSuite(apple2_bank, .init = setup, .fini = teardown);

View File

@ -1,7 +1,7 @@
#include <criterion/criterion.h>
#include "apple2.h"
#include "mos6502.enums.h"
#include "apple2/apple2.h"
#include "mos6502/enums.h"
#include "option.h"
#include "vm_di.h"

View File

@ -1,8 +1,8 @@
#include <criterion/criterion.h>
#include "apple2.dbuf.h"
#include "apple2.h"
#include "apple2.tests.h"
#include "apple2/apple2.h"
#include "apple2/dbuf.h"
#include "apple2/tests.h"
#include "vm_segment.h"
TestSuite(apple2_dbuf, .init = setup, .fini = teardown);

View File

@ -1,7 +1,7 @@
#include <criterion/criterion.h>
#include "apple2.dd.h"
#include "apple2.enc.h"
#include "apple2/dd.h"
#include "apple2/enc.h"
static apple2dd *drive;

View File

@ -1,8 +1,8 @@
#include <criterion/criterion.h>
#include "apple2.dec.h"
#include "apple2.enc.h"
#include "apple2.dd.h"
#include "apple2/dd.h"
#include "apple2/dec.h"
#include "apple2/enc.h"
/*
* This is the DOS 3.3 order; just to have something to use as a basis

View File

@ -1,6 +1,6 @@
#include <criterion/criterion.h>
#include "apple2.tests.h"
#include "apple2/tests.h"
/* Test(apple2_draw, pixel) */
/* Test(apple2_draw, pixel_lores) */

View File

@ -1,7 +1,7 @@
#include <criterion/criterion.h>
#include "apple2.dd.h"
#include "apple2.enc.h"
#include "apple2/dd.h"
#include "apple2/enc.h"
#include "vm_segment.h"
/*

View File

@ -1,7 +1,7 @@
#include <criterion/criterion.h>
#include "apple2.hires.h"
#include "apple2.tests.h"
#include "apple2/hires.h"
#include "apple2/tests.h"
TestSuite(apple2_hires, .init = setup, .fini = teardown);

View File

@ -1,7 +1,7 @@
#include <criterion/criterion.h>
#include "apple2.kb.h"
#include "apple2.tests.h"
#include "apple2/kb.h"
#include "apple2/tests.h"
TestSuite(apple2_kb, .init = setup, .fini = teardown);

View File

@ -1,7 +1,7 @@
#include <criterion/criterion.h>
#include "apple2.h"
#include "apple2.lores.h"
#include "apple2/apple2.h"
#include "apple2/lores.h"
/* Test(apple2_lores, draw) */

View File

@ -1,9 +1,9 @@
#include <criterion/criterion.h>
#include "apple2.bank.h"
#include "apple2.h"
#include "apple2.mem.h"
#include "apple2.tests.h"
#include "apple2/bank.h"
#include "apple2/apple2.h"
#include "apple2/mem.h"
#include "apple2/tests.h"
TestSuite(apple2_mem, .init = setup, .fini = teardown);

View File

@ -1,8 +1,8 @@
#include <criterion/criterion.h>
#include "apple2.h"
#include "apple2.pc.h"
#include "apple2.tests.h"
#include "apple2/apple2.h"
#include "apple2/pc.h"
#include "apple2/tests.h"
TestSuite(apple2_pc, .init = setup, .fini = teardown);

View File

@ -1,64 +1,59 @@
#include <criterion/criterion.h>
#include "apple2.h"
#include "apple2.reflect.h"
#include "apple2/apple2.h"
#include "apple2/event.h"
#include "vm_di.h"
#include "vm_reflect.h"
static apple2 *mach;
static vm_reflect *ref;
static void
setup()
{
ref = vm_reflect_create();
vm_di_set(VM_REFLECT, ref);
mach = apple2_create(100, 100);
vm_di_set(VM_MACHINE, mach);
vm_di_set(VM_CPU, mach->cpu);
apple2_reflect_init();
mach->paused = false;
mach->debug = false;
vm_di_set(VM_PAUSE_FUNC, NULL);
vm_di_set(VM_DEBUG_FUNC, NULL);
apple2_event_init();
}
static void
teardown()
{
vm_reflect_free(ref);
apple2_free(mach);
vm_di_set(VM_REFLECT, NULL);
vm_di_set(VM_MACHINE, NULL);
vm_di_set(VM_CPU, NULL);
vm_di_set(VM_PAUSE_FUNC, NULL);
vm_di_set(VM_DEBUG_FUNC, NULL);
}
TestSuite(apple2_reflect, .init = setup, .fini = teardown);
TestSuite(apple2_event, .init = setup, .fini = teardown);
Test(apple2_reflect, init)
Test(apple2_event, init)
{
cr_assert_neq(ref->cpu_info, NULL);
cr_assert_neq(ref->machine_info, NULL);
cr_assert_neq(ref->pause, NULL);
cr_assert_neq(ref->disasm, NULL);
cr_assert_neq(vm_di_get(VM_PAUSE_FUNC), NULL);
cr_assert_neq(vm_di_get(VM_DEBUG_FUNC), NULL);
}
/* Test(apple2_reflect, cpu_info) */
/* Test(apple2_reflect, machine_info) */
Test(apple2_reflect, pause)
Test(apple2_event, pause)
{
mach->paused = false;
vm_reflect_pause(NULL);
apple2_event_pause(mach);
cr_assert_eq(mach->paused, true);
vm_reflect_pause(NULL);
apple2_event_pause(mach);
cr_assert_eq(mach->paused, false);
}
Test(apple2_reflect, disasm)
Test(apple2_event, debug)
{
mach->disasm = false;
vm_reflect_disasm(NULL);
cr_assert_eq(mach->disasm, true);
vm_reflect_disasm(NULL);
cr_assert_eq(mach->disasm, false);
apple2_event_debug(mach);
cr_assert_eq(mach->paused, true);
cr_assert_eq(mach->debug, true);
apple2_event_debug(mach);
cr_assert_eq(mach->paused, true);
cr_assert_eq(mach->debug, true);
}

View File

@ -1,6 +1,6 @@
#include <criterion/criterion.h>
#include "apple2.text.h"
#include "apple2/text.h"
#include "objstore.h"
/*

View File

@ -1,8 +1,8 @@
#include <criterion/criterion.h>
#include "mos6502.h"
#include "mos6502.enums.h"
#include "mos6502.tests.h"
#include "mos6502/mos6502.h"
#include "mos6502/enums.h"
#include "mos6502/tests.h"
TestSuite(mos6502_addr, .init = setup, .fini = teardown);

View File

@ -1,8 +1,8 @@
#include <criterion/criterion.h>
#include "mos6502.h"
#include "mos6502.enums.h"
#include "mos6502.tests.h"
#include "mos6502/mos6502.h"
#include "mos6502/enums.h"
#include "mos6502/tests.h"
TestSuite(mos6502_arith, .init = setup, .fini = teardown);

View File

@ -1,8 +1,8 @@
#include <criterion/criterion.h>
#include "mos6502.h"
#include "mos6502.enums.h"
#include "mos6502.tests.h"
#include "mos6502/mos6502.h"
#include "mos6502/enums.h"
#include "mos6502/tests.h"
TestSuite(mos6502_bits, .init = setup, .fini = teardown);

View File

@ -1,8 +1,8 @@
#include <criterion/criterion.h>
#include "mos6502.h"
#include "mos6502.enums.h"
#include "mos6502.tests.h"
#include "mos6502/mos6502.h"
#include "mos6502/enums.h"
#include "mos6502/tests.h"
TestSuite(mos6502_branch, .init = setup, .fini = teardown);

View File

@ -1,8 +1,8 @@
#include <criterion/criterion.h>
#include "mos6502.h"
#include "mos6502.enums.h"
#include "mos6502.tests.h"
#include "mos6502/mos6502.h"
#include "mos6502/enums.h"
#include "mos6502/tests.h"
TestSuite(mos6502, .init = setup, .fini = teardown);

View File

@ -1,9 +1,9 @@
#include <criterion/criterion.h>
#include <unistd.h>
#include "mos6502.h"
#include "mos6502.dis.h"
#include "mos6502.enums.h"
#include "mos6502/mos6502.h"
#include "mos6502/dis.h"
#include "mos6502/enums.h"
/*
* BUFSIZ is the normal block-buffer size that a FILE stream would use

View File

@ -1,8 +1,8 @@
#include <criterion/criterion.h>
#include "mos6502.h"
#include "mos6502.enums.h"
#include "mos6502.tests.h"
#include "mos6502/mos6502.h"
#include "mos6502/enums.h"
#include "mos6502/tests.h"
TestSuite(mos6502_exec, .init = setup, .fini = teardown);

View File

@ -1,8 +1,8 @@
#include <criterion/criterion.h>
#include "mos6502.h"
#include "mos6502.enums.h"
#include "mos6502.tests.h"
#include "mos6502/mos6502.h"
#include "mos6502/enums.h"
#include "mos6502/tests.h"
TestSuite(mos6502_loadstor, .init = setup, .fini = teardown);

View File

@ -1,8 +1,8 @@
#include <criterion/criterion.h>
#include "mos6502.h"
#include "mos6502.enums.h"
#include "mos6502.tests.h"
#include "mos6502/mos6502.h"
#include "mos6502/enums.h"
#include "mos6502/tests.h"
TestSuite(mos6502_stat, .init = setup, .fini = teardown);

View File

@ -3,18 +3,16 @@
#include <stdio.h>
#include <stdlib.h>
#include "apple2.h"
#include "apple2.reflect.h"
#include "vm_debug.h"
#include "apple2/apple2.h"
#include "apple2/debug.h"
#include "apple2/event.h"
#include "vm_di.h"
#include "vm_reflect.h"
static char buf[BUFSIZ];
static FILE *stream = NULL;
static vm_debug_args args;
static apple2_debug_args args;
static apple2 *mach;
static vm_reflect *ref;
static void
setup()
@ -33,14 +31,11 @@ setup()
// Writing to stream will now write to buf
setvbuf(stream, buf, _IOFBF, BUFSIZ);
ref = vm_reflect_create();
vm_di_set(VM_REFLECT, ref);
mach = apple2_create(100, 100);
vm_di_set(VM_MACHINE, mach);
vm_di_set(VM_CPU, mach->cpu);
apple2_reflect_init();
apple2_event_init();
}
static void
@ -51,52 +46,52 @@ teardown()
apple2_free(mach);
vm_debug_unbreak_all();
apple2_debug_unbreak_all();
}
TestSuite(vm_debug, .init = setup, .fini = teardown);
TestSuite(apple2_debug, .init = setup, .fini = teardown);
/*
* I dunno what we'll end up printing! It'll change as we add commands,
* so we just test if we print _something_.
*/
Test(vm_debug, cmd_help)
Test(apple2_debug, cmd_help)
{
vm_debug_cmd_help(&args);
apple2_debug_cmd_help(&args);
cr_assert_neq(strlen(buf), 0);
}
Test(vm_debug, execute)
Test(apple2_debug, execute)
{
vm_debug_execute("help");
apple2_debug_execute("help");
cr_assert_neq(strlen(buf), 0);
}
Test(vm_debug, next_arg)
Test(apple2_debug, next_arg)
{
char *orig, *str = strdup("ok hey");
orig = str;
cr_assert_str_eq(vm_debug_next_arg(&str), "ok");
cr_assert_str_eq(vm_debug_next_arg(&str), "hey");
cr_assert_str_eq(apple2_debug_next_arg(&str), "ok");
cr_assert_str_eq(apple2_debug_next_arg(&str), "hey");
free(orig);
}
/*
* Right now, there's not a great way of testing vm_debug_prompt() since
* Right now, there's not a great way of testing apple2_debug_prompt() since
* it's dependent on stdin. Or, maybe there is with a hack, but I'd like
* to do something more appropriate in the future.
*
* Test(vm_debug, prompt)
* Test(apple2_debug, prompt)
*/
Test(vm_debug, addr)
Test(apple2_debug, addr)
{
cr_assert_eq(vm_debug_addr("faaa"), 0xfaaa);
cr_assert_eq(vm_debug_addr("123"), 0x123);
cr_assert_eq(vm_debug_addr("$34"), 0x34);
cr_assert_eq(vm_debug_addr("hey"), -1);
cr_assert_eq(apple2_debug_addr("faaa"), 0xfaaa);
cr_assert_eq(apple2_debug_addr("123"), 0x123);
cr_assert_eq(apple2_debug_addr("$34"), 0x34);
cr_assert_eq(apple2_debug_addr("hey"), -1);
}
/*
@ -104,95 +99,95 @@ Test(vm_debug, addr)
* function is statically declared, and we don't have access to test it
* here.
*
* Test(vm_debug, cmd_compar)
* Test(apple2_debug, cmd_compar)
*/
Test(vm_debug, find_cmd)
Test(apple2_debug, find_cmd)
{
vm_debug_cmd *cmd;
apple2_debug_cmd *cmd;
// Can we find anything?
cr_assert_neq(vm_debug_find_cmd("resume"), NULL);
cr_assert_neq(apple2_debug_find_cmd("resume"), NULL);
// Make sure NULL is returned for bad commands
cr_assert_eq(vm_debug_find_cmd("THIS_DOESNT_EXIST"), NULL);
cr_assert_eq(apple2_debug_find_cmd("THIS_DOESNT_EXIST"), NULL);
// Find a second command...
cmd = vm_debug_find_cmd("help");
cmd = apple2_debug_find_cmd("help");
cr_assert_neq(cmd, NULL);
// and see if we can find the short version
cr_assert_eq(vm_debug_find_cmd("h"), cmd);
cr_assert_eq(apple2_debug_find_cmd("h"), cmd);
}
Test(vm_debug, cmd_resume)
Test(apple2_debug, cmd_resume)
{
mach->paused = true;
vm_debug_cmd_resume(&args);
apple2_debug_cmd_resume(&args);
cr_assert_eq(mach->paused, false);
}
Test(vm_debug, cmd_printstate)
Test(apple2_debug, cmd_printstate)
{
vm_debug_cmd_printstate(&args);
apple2_debug_cmd_printstate(&args);
cr_assert_neq(strlen(buf), 0);
}
Test(vm_debug, cmd_printaddr)
Test(apple2_debug, cmd_printaddr)
{
args.addr1 = 123;
mos6502_set(mach->cpu, args.addr1, 127);
vm_debug_cmd_printaddr(&args);
apple2_debug_cmd_printaddr(&args);
cr_assert_str_eq(buf, "$7F\n");
}
Test(vm_debug, cmd_jump)
Test(apple2_debug, cmd_jump)
{
args.addr1 = 123;
vm_debug_cmd_jump(&args);
apple2_debug_cmd_jump(&args);
cr_assert_eq(mach->cpu->PC, 123);
}
Test(vm_debug, cmd_writeaddr)
Test(apple2_debug, cmd_writeaddr)
{
args.addr1 = 123;
args.addr2 = 0xf5;
vm_debug_cmd_writeaddr(&args);
apple2_debug_cmd_writeaddr(&args);
cr_assert_eq(mos6502_get(mach->cpu, args.addr1), args.addr2);
}
Test(vm_debug, cmd_writestate)
Test(apple2_debug, cmd_writestate)
{
args.addr1 = 111;
args.target = "a";
vm_debug_cmd_writestate(&args);
apple2_debug_cmd_writestate(&args);
cr_assert_eq(mach->cpu->A, args.addr2);
args.addr1 = 112;
args.target = "x";
vm_debug_cmd_writestate(&args);
apple2_debug_cmd_writestate(&args);
cr_assert_eq(mach->cpu->X, args.addr2);
args.addr1 = 113;
args.target = "y";
vm_debug_cmd_writestate(&args);
apple2_debug_cmd_writestate(&args);
cr_assert_eq(mach->cpu->Y, args.addr2);
args.addr1 = 114;
args.target = "p";
vm_debug_cmd_writestate(&args);
apple2_debug_cmd_writestate(&args);
cr_assert_eq(mach->cpu->P, args.addr2);
args.addr1 = 115;
args.target = "s";
vm_debug_cmd_writestate(&args);
apple2_debug_cmd_writestate(&args);
cr_assert_eq(mach->cpu->S, args.addr2);
}
Test(vm_debug, break)
Test(apple2_debug, break)
{
vm_debug_break(0x2);
apple2_debug_break(0x2);
mos6502_set(mach->cpu, 0, 0xEA);
mos6502_set(mach->cpu, 1, 0xEA);
@ -207,47 +202,47 @@ Test(vm_debug, break)
cr_assert_eq(mach->cpu->PC, 2);
}
Test(vm_debug, broke)
Test(apple2_debug, broke)
{
cr_assert_eq(vm_debug_broke(0x23), false);
vm_debug_break(0x23);
cr_assert_eq(vm_debug_broke(0x23), true);
cr_assert_eq(apple2_debug_broke(0x23), false);
apple2_debug_break(0x23);
cr_assert_eq(apple2_debug_broke(0x23), true);
}
Test(vm_debug, unbreak)
Test(apple2_debug, unbreak)
{
vm_debug_break(0x23);
apple2_debug_break(0x23);
cr_assert_eq(vm_debug_broke(0x23), true);
vm_debug_unbreak(0x23);
cr_assert_eq(vm_debug_broke(0x23), false);
cr_assert_eq(apple2_debug_broke(0x23), true);
apple2_debug_unbreak(0x23);
cr_assert_eq(apple2_debug_broke(0x23), false);
}
Test(vm_debug, cmd_break)
Test(apple2_debug, cmd_break)
{
args.addr1 = 123;
vm_debug_cmd_break(&args);
apple2_debug_cmd_break(&args);
cr_assert_eq(vm_debug_broke(123), true);
cr_assert_eq(apple2_debug_broke(123), true);
}
Test(vm_debug, cmd_unbreak)
Test(apple2_debug, cmd_unbreak)
{
args.addr1 = 123;
vm_debug_cmd_break(&args);
cr_assert_eq(vm_debug_broke(123), true);
vm_debug_cmd_unbreak(&args);
cr_assert_eq(vm_debug_broke(123), false);
apple2_debug_cmd_break(&args);
cr_assert_eq(apple2_debug_broke(123), true);
apple2_debug_cmd_unbreak(&args);
cr_assert_eq(apple2_debug_broke(123), false);
}
Test(vm_debug, unbreak_all)
Test(apple2_debug, unbreak_all)
{
vm_debug_break(55555);
vm_debug_unbreak_all();
cr_assert_eq(vm_debug_broke(55555), false);
apple2_debug_break(55555);
apple2_debug_unbreak_all();
cr_assert_eq(apple2_debug_broke(55555), false);
}
Test(vm_debug, cmd_step)
Test(apple2_debug, cmd_step)
{
// Just setting us up with some NOPs for the testing
mos6502_set(mach->cpu, 0, 0xEA);
@ -255,7 +250,7 @@ Test(vm_debug, cmd_step)
mos6502_set(mach->cpu, 2, 0xEA);
mos6502_set(mach->cpu, 3, 0xEA);
vm_debug_break(1);
apple2_debug_break(1);
mos6502_execute(mach->cpu);
cr_assert_eq(mach->cpu->PC, 1);
@ -264,32 +259,32 @@ Test(vm_debug, cmd_step)
cr_assert_eq(mach->cpu->PC, 1);
// Step should a) unbreak at PC, b) execute at PC
vm_debug_cmd_step(&args);
apple2_debug_cmd_step(&args);
cr_assert_eq(mach->cpu->PC, 2);
}
/* Test(vm_debug, cmd_quit) */
/* Test(apple2_debug, cmd_quit) */
Test(vm_debug, cmd_disassemble)
Test(apple2_debug, cmd_disassemble)
{
cr_assert_eq(mach->disasm, false);
vm_debug_cmd_disasm(&args);
apple2_debug_cmd_disasm(&args);
cr_assert_neq(strlen(buf), 0);
cr_assert_eq(mach->disasm, true);
vm_debug_cmd_disasm(&args);
apple2_debug_cmd_disasm(&args);
cr_assert_eq(mach->disasm, false);
}
Test(vm_debug, cmd_dblock)
Test(apple2_debug, cmd_dblock)
{
mos6502_set(mach->cpu, 0, 0xEA);
args.addr1 = 0;
args.addr2 = 1;
vm_debug_cmd_dblock(&args);
apple2_debug_cmd_dblock(&args);
cr_assert_neq(strlen(buf), 0);
}
Test(vm_debug, cmd_hdump)
Test(apple2_debug, cmd_hdump)
{
for (int i = 0; i < 16; i++) {
mos6502_set(mach->cpu, i, i + 0x30);
@ -298,7 +293,7 @@ Test(vm_debug, cmd_hdump)
args.addr1 = 0;
args.addr2 = 32;
vm_debug_cmd_hdump(&args);
apple2_debug_cmd_hdump(&args);
cr_assert_neq(strlen(buf), 0);
}

View File

@ -1,72 +0,0 @@
#include <criterion/criterion.h>
#include "apple2.h"
#include "vm_reflect.h"
static vm_reflect *ref;
static apple2 *mach;
/*
* This is a tiny function we can use that will satisfy the
* vm_reflect_fn type so we can test that all of those are working in
* the vm_reflect struct.
*/
static void
fun(vm_reflect *ref)
{
return;
}
static void
have_fun()
{
ref->cpu_info = fun;
ref->machine_info = fun;
ref->pause = fun;
ref->disasm = fun;
}
static void
setup()
{
mach = apple2_create(100, 100);
ref = vm_reflect_create(mach, mach->cpu, stdout);
}
static void
teardown()
{
vm_reflect_free(ref);
apple2_free(mach);
}
TestSuite(vm_reflect, .init = setup, .fini = teardown);
Test(vm_reflect, create)
{
cr_assert_neq(ref, NULL);
cr_assert_eq(ref->cpu_info, NULL);
cr_assert_eq(ref->machine_info, NULL);
cr_assert_eq(ref->pause, NULL);
cr_assert_eq(ref->disasm, NULL);
}
// Not much to do here
/* Test(vm_reflect, free) */
/*
* Because all of the reflect functions (aside from create/free) do the
* same thing, one test can stand in for all of them; hence the skips
* you see below.
*/
Test(vm_reflect, cpu_info)
{
// We should always try to have fun
have_fun();
cr_assert_eq(vm_reflect_cpu_info(ref), OK);
}
/* Test(vm_reflect, machine_info) */
/* Test(vm_reflect, pause) */
/* Test(vm_reflect, disasm) */