1
0
mirror of https://github.com/rkujawa/rk65c02.git synced 2024-12-12 10:30:23 +00:00

Add test case for breakpoint functions.

This commit is contained in:
Radosław Kujawa 2017-02-15 19:57:16 +01:00
parent 6afb4531d5
commit 0653d7428d
2 changed files with 60 additions and 1 deletions

View File

@ -5,7 +5,7 @@ VASM=vasm6502_std
VASMFLAGS=-Fbin -c02
UTILS=utils.o
TESTS=test_bus test_emulation test_stepping test_assemble test_interrupt
TESTS=test_bus test_emulation test_stepping test_assemble test_interrupt test_debug
TESTROMS:=$(addsuffix .rom,$(basename $(wildcard *.s)))
all : $(TESTS) $(TESTROMS)
@ -25,6 +25,9 @@ test_assemble : test_assemble.o $(UTILS) $(RK6502LIB)
test_interrupt: test_interrupt.o $(UTILS) $(RK6502LIB)
$(CC) -o $@ $(LDFLAGS) $< $(UTILS) $(RK6502LIB)
test_debug: test_debug.o $(UTILS) $(RK6502LIB)
$(CC) -o $@ $(LDFLAGS) $< $(UTILS) $(RK6502LIB)
%.rom : %.s
$(VASM) $(VASMFLAGS) -o $@ $<

56
test/test_debug.c Normal file
View File

@ -0,0 +1,56 @@
#include <atf-c.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include "bus.h"
#include "rk65c02.h"
#include "instruction.h"
#include "debug.h"
#include "utils.h"
ATF_TC_WITHOUT_HEAD(breakpoint);
ATF_TC_BODY(breakpoint, tc)
{
rk65c02emu_t e;
bus_t b;
assembler_t a;
b = bus_init();
a = assemble_init(&b, ROM_LOAD_ADDR);
e = rk65c02_init(&b);
e.regs.PC = ROM_LOAD_ADDR;
ATF_REQUIRE(assemble_single_implied(&a, "nop")); /* 0xC000 */
ATF_REQUIRE(assemble_single_implied(&a, "nop"));
ATF_REQUIRE(assemble_single_implied(&a, "nop")); /* 0xC002 */
ATF_REQUIRE(assemble_single_implied(&a, "nop"));
ATF_REQUIRE(assemble_single(&a, "stp", IMPLIED, 0, 0));
ATF_REQUIRE(debug_breakpoint_add(&e, 0xC002));
rk65c02_start(&e);
ATF_CHECK(e.state == STOPPED);
ATF_CHECK(e.stopreason == BREAKPOINT);
ATF_CHECK(e.regs.PC == 0xC002);
ATF_REQUIRE(debug_breakpoint_remove(&e, 0xC002));
rk65c02_start(&e);
ATF_CHECK(e.state == STOPPED);
ATF_CHECK(e.stopreason == STP);
ATF_CHECK(e.regs.PC == 0xC005);
}
ATF_TP_ADD_TCS(tp)
{
ATF_TP_ADD_TC(tp, breakpoint);
return (atf_no_error());
}