diff --git a/test/Kyuafile b/test/Kyuafile index 4d88baa..a3614c1 100644 --- a/test/Kyuafile +++ b/test/Kyuafile @@ -5,6 +5,7 @@ test_suite('rk65c02-tests') atf_test_program{name='test_assemble'} atf_test_program{name='test_bus'} atf_test_program{name='test_debug'} +--atf_test_program{name='test_device_serial'} atf_test_program{name='test_emulation'} atf_test_program{name='test_interrupt'} atf_test_program{name='test_stepping'} diff --git a/test/Makefile b/test/Makefile index c7e9d27..80845f3 100644 --- a/test/Makefile +++ b/test/Makefile @@ -5,7 +5,7 @@ VASM=vasm6502_std VASMFLAGS=-Fbin -c02 UTILS=utils.o -TESTS=test_bus test_emulation test_stepping test_assemble test_interrupt test_debug +TESTS=test_bus test_emulation test_stepping test_assemble test_interrupt test_debug test_device_serial TESTROMS:=$(addsuffix .rom,$(basename $(wildcard *.s))) all : $(TESTS) $(TESTROMS) @@ -28,6 +28,9 @@ test_interrupt: test_interrupt.o $(UTILS) $(RK6502LIB) test_debug: test_debug.o $(UTILS) $(RK6502LIB) $(CC) -o $@ $(LDFLAGS) $< $(UTILS) $(RK6502LIB) +test_device_serial: test_device_serial.o $(UTILS) $(RK6502LIB) + $(CC) -o $@ $(LDFLAGS) $< $(UTILS) $(RK6502LIB) + %.rom : %.s $(VASM) $(VASMFLAGS) -o $@ $< diff --git a/test/test_device_serial.c b/test/test_device_serial.c new file mode 100644 index 0000000..aa6eaa8 --- /dev/null +++ b/test/test_device_serial.c @@ -0,0 +1,66 @@ +#include + +#include +#include + +#include + +#include "rk65c02.h" +#include "bus.h" +#include "utils.h" +#include "device_serial.h" + +ATF_TC_WITHOUT_HEAD(device_serial_init); +ATF_TC_BODY(device_serial_init, tc) +{ + bus_t b; + device_mapping_t *dm; + device_t *d, *d_ser; + + b = bus_init_with_default_devs(); + + bus_device_add(&b, device_serial_init(), 0xE000); + + bus_device_dump(&b); + + LL_FOREACH(b.dm_head, dm) { + d = dm->dev; + + if (dm->addr == 0xE000) + d_ser = d; + } + + ATF_CHECK(strcmp("Serial", d_ser->name) == 0); + + bus_finish(&b); +} + +ATF_TC_WITHOUT_HEAD(device_serial_write1); +ATF_TC_BODY(device_serial_write1, tc) +{ + bus_t b; + rk65c02emu_t e; + + b = bus_init_with_default_devs(); + + bus_device_add(&b, device_serial_init(), 0xE000); + bus_device_dump(&b); + + e = rk65c02_init(&b); + + ATF_REQUIRE(rom_start(&e, "test_device_serial_write1.rom", tc)); + + // start thread reading from txpipe + + /* clean up serial etc. */ + bus_finish(&b); +} + +ATF_TP_ADD_TCS(tp) +{ + ATF_TP_ADD_TC(tp, device_serial_init); + ATF_TP_ADD_TC(tp, device_serial_write1); + + return (atf_no_error()); +} + diff --git a/test/test_device_serial_write1.s b/test/test_device_serial_write1.s new file mode 100644 index 0000000..799928d --- /dev/null +++ b/test/test_device_serial_write1.s @@ -0,0 +1,6 @@ +start: lda #0x61 + sta 0xE000 + lda #0x0A + sta 0xE000 + stp +