diff --git a/test_programs/Makefile b/test_programs/Makefile index 662a888..ad2c039 100644 --- a/test_programs/Makefile +++ b/test_programs/Makefile @@ -6,8 +6,16 @@ include $(TOPDIR)/Makefile.config # dumps: $(MAKE) dumps -C riscv_instructions/ - mkdir -p ${TOPDIR}/target - find . -name '*.dump' -exec mv {} ${TOPDIR}/target \; + mkdir -p ${TOPDIR}/target/dumps/ + find . -name '*.dump' -exec mv {} ${TOPDIR}/target/dumps/ \; + +user_lib: + $(MAKE) -C userlib/ + +tests: user_lib + $(MAKE) tests -C riscv_instructions/ + mkdir -p ${TOPDIR}/target/guac/ + find . -name '*.guac' -exec mv {} ${TOPDIR}/target/guac/ \; clean: rm -rf $(TOPDIR)/target \ No newline at end of file diff --git a/test_programs/Makefile.tests b/test_programs/Makefile.tests new file mode 100644 index 0000000..681d31f --- /dev/null +++ b/test_programs/Makefile.tests @@ -0,0 +1,38 @@ +include $(TOPDIR)/Makefile.config +USERLIB = $(TOPDIR)/userlib +INCPATH += -I$(TOPDIR) -I$(USERLIB) +LDFLAGS = $(RISCV_LDFLAGS) -T $(USERLIB)/ldscript.lds +ASFLAGS = $(RISCV_ASFLAGS) $(INCPATH) +CFLAGS = $(RISCV_CFLAGS) $(INCPATH) + +# Rules +%.o: %.s + $(RISCV_AS) $(ASFLAGS) -c $< + +%.o: %.c + $(RISCV_GCC) $(CFLAGS) -c $< + +%.dump: %.o + $(RISCV_OBJCOPY) -j .text -O $(DUMP_FORMAT) $< $@ + +%.guac: %.o + $(RISCV_LD) $(LDFLAGS) $+ -o $@ + +# Dependencies +.%.d: %.s + @echo Generating dependencies for $< + @$(SHELL) -ec '$(GCC) -x assembler-with-cpp -M $(ASFLAGS) $< \ + | sed '\''s/\($*\)\.o[ :]*/\1.o $@ : /g'\'' > $@; \ + [ -s $@ ] || rm -f $@' + +.%.d: %.c + @echo Generating dependencies for $< + @$(SHELL) -ec '$(GCC) -M $(CFLAGS) $< \ + | sed '\''s/\($*\)\.o[ :]*/\1.o $@ : /g'\'' > $@; \ + [ -s $@ ] || rm -f $@' + +# Targets +#clean: +# rm -rf *.o 2> /dev/null +# rm -rf *.dump 2> /dev/null +# rm -rf *.guac 2> /dev/null \ No newline at end of file diff --git a/test_programs/riscv_instructions/Makefile b/test_programs/riscv_instructions/Makefile index c134d5f..22a1303 100644 --- a/test_programs/riscv_instructions/Makefile +++ b/test_programs/riscv_instructions/Makefile @@ -1,4 +1,9 @@ dumps: make dumps -C boolean_logic/ make dumps -C jump_instructions/ - make dumps -C simple_arithmetics/ \ No newline at end of file + make dumps -C simple_arithmetics/ + +tests: + make tests -C boolean_logic/ + make tests -C jump_instructions/ + make tests -C simple_arithmetics/ \ No newline at end of file diff --git a/test_programs/riscv_instructions/boolean_logic/Makefile b/test_programs/riscv_instructions/boolean_logic/Makefile index 2150f14..5f738e9 100644 --- a/test_programs/riscv_instructions/boolean_logic/Makefile +++ b/test_programs/riscv_instructions/boolean_logic/Makefile @@ -1,4 +1,9 @@ TOPDIR = ../.. -include $(TOPDIR)/Makefile.dumps +include $(TOPDIR)/Makefile.tests -dumps: comparisons.dump if.dump switch.dump \ No newline at end of file +dumps: comparisons.dump if.dump switch.dump + +tests: comparisons.guac if.guac switch.guac + +# Dependances +$(PROGRAMS): % : $(USERLIB)/sys.o $(USERLIB)/libnachos.o %.o \ No newline at end of file diff --git a/test_programs/riscv_instructions/jump_instructions/Makefile b/test_programs/riscv_instructions/jump_instructions/Makefile index 75b887b..ce69447 100644 --- a/test_programs/riscv_instructions/jump_instructions/Makefile +++ b/test_programs/riscv_instructions/jump_instructions/Makefile @@ -1,4 +1,6 @@ TOPDIR = ../.. -include $(TOPDIR)/Makefile.dumps +include $(TOPDIR)/Makefile.tests -dumps: jump.dump ret.dump \ No newline at end of file +dumps: jump.dump ret.dump + +tests: jump.guac ret.guac \ No newline at end of file diff --git a/test_programs/riscv_instructions/simple_arithmetics/Makefile b/test_programs/riscv_instructions/simple_arithmetics/Makefile index d775b97..623b297 100644 --- a/test_programs/riscv_instructions/simple_arithmetics/Makefile +++ b/test_programs/riscv_instructions/simple_arithmetics/Makefile @@ -1,4 +1,6 @@ TOPDIR = ../.. -include $(TOPDIR)/Makefile.dumps +include $(TOPDIR)/Makefile.tests -dumps: unsigned_addition.dump unsigned_division.dump unsigned_multiplication.dump unsigned_substraction.dump \ No newline at end of file +dumps: unsigned_addition.dump unsigned_division.dump unsigned_multiplication.dump unsigned_substraction.dump + +tests: unsigned_addition.guac unsigned_division.guac unsigned_multiplication.guac unsigned_substraction.guac \ No newline at end of file diff --git a/test_programs/riscv_instructions/simple_arithmetics/unsigned_addition.c b/test_programs/riscv_instructions/simple_arithmetics/unsigned_addition.c index 05a7829..f1c005a 100644 --- a/test_programs/riscv_instructions/simple_arithmetics/unsigned_addition.c +++ b/test_programs/riscv_instructions/simple_arithmetics/unsigned_addition.c @@ -1,3 +1,6 @@ +#include "userlib/syscall.h" +#include "userlib/libnachos.h" + // EXPECTS TWO VARIABLES WITH A VALUE OF UNSIGNED 1 int main() { unsigned int x = 0;