diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6ee361f..ed8a5dd 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -30,3 +30,10 @@ test_bb_spi: script: - cd hw/fpga/simulation/modelsim/ - vsim -do "do bb_spi_testbench.do" + +test-sw: + stage: test + image: bslathi19/cc65-pipeline + script: + - cd sw/ + - make test diff --git a/sw/.gitignore b/sw/.gitignore index 9b97224..3e1502e 100644 --- a/sw/.gitignore +++ b/sw/.gitignore @@ -31,6 +31,7 @@ lists/ # Executables *.exe +*.bin *.out *.app *.i*86 diff --git a/sw/Makefile b/sw/Makefile index d330e0c..37f22c5 100644 --- a/sw/Makefile +++ b/sw/Makefile @@ -1,20 +1,36 @@ CC=cl65 CFLAGS=-t none -I. --cpu "65C02" +test: CFLAGS=-t sim65c02 -I. LDFLAGS=-C link.ld -m $(NAME).map +SIM=sim65 +SIMARGS=-v -c -x 1000000 NAME=bootrom +TEST_BIN=test.bin BIN=$(NAME).bin HEX=$(NAME).hex LISTS=lists +TESTS=tests SRCS=$(wildcard *.s) $(wildcard *.c) OBJS+=$(patsubst %.s,%.o,$(filter %s,$(SRCS))) OBJS+=$(patsubst %.c,%.o,$(filter %c,$(SRCS))) +TEST_SRCS=$(wildcard $(TESTS)/*.s) $(wildcard $(TESTS)/*.c) +TEST_OBJS+=$(patsubst %.s,%.o,$(filter %s,$(TEST_SRCS))) +TEST_OBJS+=$(patsubst %.c,%.o,$(filter %c,$(TEST_SRCS))) +TEST_OBJS+=$(filter-out boot.o,$(filter-out main.o,$(OBJS))) + all: $(HEX) +test: $(TEST_BIN) + $(SIM) $(SIMARGS) $(TEST_BIN) + +$(TEST_BIN): $(OBJS) $(TEST_OBJS) + $(CC) $(CFLAGS) $(TEST_OBJS) -o $@ + $(HEX): $(BIN) objcopy --input-target=binary --output-target=ihex $(BIN) $(HEX) @@ -30,8 +46,10 @@ $(BIN): $(OBJS) $(LISTS): mkdir $(LISTS) + mkdir $(LISTS)/$(TESTS) .PHONY: clean clean: - rm -rf $(OBJS) $(BIN) $(HEX) $(LISTS) + rm -rf $(OBJS) $(BIN) $(HEX) $(LISTS) $(NAME).map + rm -rf $(TEST_OBJS) $(TEST_BIN) diff --git a/sw/tests/test_main.c b/sw/tests/test_main.c new file mode 100644 index 0000000..e3da992 --- /dev/null +++ b/sw/tests/test_main.c @@ -0,0 +1,10 @@ +#include +#include + +int main(void) +{ + printf("Starting spi_write_byte test...\n"); + spi_write_byte(0xa5); + printf("Done!\n"); + return 0; +} \ No newline at end of file