From 1e5555f66dbc97c82ff7f13989d378873828bdf0 Mon Sep 17 00:00:00 2001 From: Toby Jaffey Date: Sat, 13 Dec 2025 17:27:24 +0000 Subject: [PATCH] Unify all tests to use same common makefile includes --- test/basic_syscalls/Makefile | 35 ++---------------------------- test/basic_syscalls/rom/Makefile | 15 ++----------- test/common/makefile-rom.common | 14 ++++++++++++ test/common/makefile.common | 36 +++++++++++++++++++++++++++++++ test/custom_syscall/Makefile | 35 ++---------------------------- test/custom_syscall/rom/Makefile | 15 ++----------- test/extram/Makefile | 35 ++---------------------------- test/extram/rom/Makefile | 15 ++----------- test/meter/Makefile | 35 ++---------------------------- test/meter/rom/Makefile | 16 ++------------ test/stackoverflow/Makefile | 37 ++++---------------------------- test/stackoverflow/rom/Makefile | 16 ++------------ test/syscall_args/Makefile | 35 ++---------------------------- test/syscall_args/rom/Makefile | 15 ++----------- 14 files changed, 76 insertions(+), 278 deletions(-) create mode 100644 test/common/makefile-rom.common create mode 100644 test/common/makefile.common diff --git a/test/basic_syscalls/Makefile b/test/basic_syscalls/Makefile index 6533b02..dc44dd1 100644 --- a/test/basic_syscalls/Makefile +++ b/test/basic_syscalls/Makefile @@ -1,33 +1,2 @@ -C_COMPILER=gcc - -UNITY_ROOT=../unity - -CFLAGS=-std=c99 -CFLAGS += -Wall -CFLAGS += -Werror -CFLAGS += -DUVM32_MEMORY_SIZE=16384 - -SUITE_NAME=tests - -TARGET_BASE1=test1 -TARGET1 = $(TARGET_BASE1) -SRC_FILES1=$(UNITY_ROOT)/src/unity.c test/${SUITE_NAME}.c test/test_runners/${SUITE_NAME}_Runner.c ../../uvm32/uvm32.c -INC_DIRS=-I$(UNITY_ROOT)/src -I../../uvm32/ -I../../common -Irom - -.PHONY: rom - -default: $(SRC_FILES1) rom - @$(C_COMPILER) $(CFLAGS) $(INC_DIRS) $(SYMBOLS) $(SRC_FILES1) rom/rom-header.c -o $(TARGET1) - @ ./$(TARGET1) - -rom: - @(cd rom && make) - -test/test_runners/${SUITE_NAME}_Runner.c: test/${SUITE_NAME}.c - @mkdir -p test/test_runners - @ruby $(UNITY_ROOT)/auto/generate_test_runner.rb test/${SUITE_NAME}.c test/test_runners/${SUITE_NAME}_Runner.c - -clean: - rm -rf $(TARGET1) test/test_runners - (cd rom && make clean) - +TOPDIR=../.. +include ${TOPDIR}/test/common/makefile.common diff --git a/test/basic_syscalls/rom/Makefile b/test/basic_syscalls/rom/Makefile index c85effd..4cd3f50 100644 --- a/test/basic_syscalls/rom/Makefile +++ b/test/basic_syscalls/rom/Makefile @@ -1,13 +1,2 @@ -TOPDIR=../../../ -PROJECT:=$(shell basename ${PWD}) -SRCS=${PROJECT}.c ${TOPDIR}/apps/common/crt0.S -all: all_common - @# Convert ROM to C file and header - @xxd -i ${PROJECT}.bin > ${PROJECT}-header.c - @echo "extern unsigned char ${PROJECT}_bin[]; extern int ${PROJECT}_bin_len;" > ${PROJECT}-header.h - -test: test_common -clean: clean_common - rm -f ${PROJECT}-header.h ${PROJECT}-header.c - -include ${TOPDIR}/apps/common/makefile.common +TOPDIR=../../.. +include ${TOPDIR}/test/common/makefile-rom.common diff --git a/test/common/makefile-rom.common b/test/common/makefile-rom.common new file mode 100644 index 0000000..77d5026 --- /dev/null +++ b/test/common/makefile-rom.common @@ -0,0 +1,14 @@ +TOPDIR=../../../ +PROJECT:=$(shell basename ${PWD}) +SRCS=${PROJECT}.c ${TOPDIR}/apps/common/crt0.S +OPT=-O0 +all: all_common + @# Convert ROM to C file and header + @xxd -i ${PROJECT}.bin > ${PROJECT}-header.c + @echo "extern unsigned char ${PROJECT}_bin[]; extern int ${PROJECT}_bin_len;" > ${PROJECT}-header.h + +test: test_common +clean: clean_common + rm -f ${PROJECT}-header.h ${PROJECT}-header.c + +include ${TOPDIR}/apps/common/makefile.common diff --git a/test/common/makefile.common b/test/common/makefile.common new file mode 100644 index 0000000..715c70d --- /dev/null +++ b/test/common/makefile.common @@ -0,0 +1,36 @@ +C_COMPILER=gcc + +UNITY_ROOT=../unity + +UVM32_MEMORY_SIZE ?= 16384 + +CFLAGS +=-std=c99 +CFLAGS += -Wall +CFLAGS += -Werror + +CFLAGS += -DUVM32_MEMORY_SIZE=${UVM32_MEMORY_SIZE} + +SUITE_NAME=tests + +TARGET_BASE1=test1 +TARGET1 = $(TARGET_BASE1) +SRC_FILES1=$(UNITY_ROOT)/src/unity.c test/${SUITE_NAME}.c test/test_runners/${SUITE_NAME}_Runner.c ../../uvm32/uvm32.c +INC_DIRS=-I$(UNITY_ROOT)/src -I../../uvm32/ -I../../common -Irom + +.PHONY: rom + +default: $(SRC_FILES1) rom + $(C_COMPILER) $(CFLAGS) $(INC_DIRS) $(SYMBOLS) $(SRC_FILES1) rom/rom-header.c -o $(TARGET1) + @./$(TARGET1) + +rom: + @(cd rom && make) + +test/test_runners/${SUITE_NAME}_Runner.c: test/${SUITE_NAME}.c + @mkdir -p test/test_runners + @ruby $(UNITY_ROOT)/auto/generate_test_runner.rb test/${SUITE_NAME}.c test/test_runners/${SUITE_NAME}_Runner.c + +clean: + rm -rf $(TARGET1) test/test_runners + (cd rom && make clean) + diff --git a/test/custom_syscall/Makefile b/test/custom_syscall/Makefile index 6533b02..dc44dd1 100644 --- a/test/custom_syscall/Makefile +++ b/test/custom_syscall/Makefile @@ -1,33 +1,2 @@ -C_COMPILER=gcc - -UNITY_ROOT=../unity - -CFLAGS=-std=c99 -CFLAGS += -Wall -CFLAGS += -Werror -CFLAGS += -DUVM32_MEMORY_SIZE=16384 - -SUITE_NAME=tests - -TARGET_BASE1=test1 -TARGET1 = $(TARGET_BASE1) -SRC_FILES1=$(UNITY_ROOT)/src/unity.c test/${SUITE_NAME}.c test/test_runners/${SUITE_NAME}_Runner.c ../../uvm32/uvm32.c -INC_DIRS=-I$(UNITY_ROOT)/src -I../../uvm32/ -I../../common -Irom - -.PHONY: rom - -default: $(SRC_FILES1) rom - @$(C_COMPILER) $(CFLAGS) $(INC_DIRS) $(SYMBOLS) $(SRC_FILES1) rom/rom-header.c -o $(TARGET1) - @ ./$(TARGET1) - -rom: - @(cd rom && make) - -test/test_runners/${SUITE_NAME}_Runner.c: test/${SUITE_NAME}.c - @mkdir -p test/test_runners - @ruby $(UNITY_ROOT)/auto/generate_test_runner.rb test/${SUITE_NAME}.c test/test_runners/${SUITE_NAME}_Runner.c - -clean: - rm -rf $(TARGET1) test/test_runners - (cd rom && make clean) - +TOPDIR=../.. +include ${TOPDIR}/test/common/makefile.common diff --git a/test/custom_syscall/rom/Makefile b/test/custom_syscall/rom/Makefile index c85effd..4cd3f50 100644 --- a/test/custom_syscall/rom/Makefile +++ b/test/custom_syscall/rom/Makefile @@ -1,13 +1,2 @@ -TOPDIR=../../../ -PROJECT:=$(shell basename ${PWD}) -SRCS=${PROJECT}.c ${TOPDIR}/apps/common/crt0.S -all: all_common - @# Convert ROM to C file and header - @xxd -i ${PROJECT}.bin > ${PROJECT}-header.c - @echo "extern unsigned char ${PROJECT}_bin[]; extern int ${PROJECT}_bin_len;" > ${PROJECT}-header.h - -test: test_common -clean: clean_common - rm -f ${PROJECT}-header.h ${PROJECT}-header.c - -include ${TOPDIR}/apps/common/makefile.common +TOPDIR=../../.. +include ${TOPDIR}/test/common/makefile-rom.common diff --git a/test/extram/Makefile b/test/extram/Makefile index 6533b02..dc44dd1 100644 --- a/test/extram/Makefile +++ b/test/extram/Makefile @@ -1,33 +1,2 @@ -C_COMPILER=gcc - -UNITY_ROOT=../unity - -CFLAGS=-std=c99 -CFLAGS += -Wall -CFLAGS += -Werror -CFLAGS += -DUVM32_MEMORY_SIZE=16384 - -SUITE_NAME=tests - -TARGET_BASE1=test1 -TARGET1 = $(TARGET_BASE1) -SRC_FILES1=$(UNITY_ROOT)/src/unity.c test/${SUITE_NAME}.c test/test_runners/${SUITE_NAME}_Runner.c ../../uvm32/uvm32.c -INC_DIRS=-I$(UNITY_ROOT)/src -I../../uvm32/ -I../../common -Irom - -.PHONY: rom - -default: $(SRC_FILES1) rom - @$(C_COMPILER) $(CFLAGS) $(INC_DIRS) $(SYMBOLS) $(SRC_FILES1) rom/rom-header.c -o $(TARGET1) - @ ./$(TARGET1) - -rom: - @(cd rom && make) - -test/test_runners/${SUITE_NAME}_Runner.c: test/${SUITE_NAME}.c - @mkdir -p test/test_runners - @ruby $(UNITY_ROOT)/auto/generate_test_runner.rb test/${SUITE_NAME}.c test/test_runners/${SUITE_NAME}_Runner.c - -clean: - rm -rf $(TARGET1) test/test_runners - (cd rom && make clean) - +TOPDIR=../.. +include ${TOPDIR}/test/common/makefile.common diff --git a/test/extram/rom/Makefile b/test/extram/rom/Makefile index c85effd..4cd3f50 100644 --- a/test/extram/rom/Makefile +++ b/test/extram/rom/Makefile @@ -1,13 +1,2 @@ -TOPDIR=../../../ -PROJECT:=$(shell basename ${PWD}) -SRCS=${PROJECT}.c ${TOPDIR}/apps/common/crt0.S -all: all_common - @# Convert ROM to C file and header - @xxd -i ${PROJECT}.bin > ${PROJECT}-header.c - @echo "extern unsigned char ${PROJECT}_bin[]; extern int ${PROJECT}_bin_len;" > ${PROJECT}-header.h - -test: test_common -clean: clean_common - rm -f ${PROJECT}-header.h ${PROJECT}-header.c - -include ${TOPDIR}/apps/common/makefile.common +TOPDIR=../../.. +include ${TOPDIR}/test/common/makefile-rom.common diff --git a/test/meter/Makefile b/test/meter/Makefile index 6533b02..dc44dd1 100644 --- a/test/meter/Makefile +++ b/test/meter/Makefile @@ -1,33 +1,2 @@ -C_COMPILER=gcc - -UNITY_ROOT=../unity - -CFLAGS=-std=c99 -CFLAGS += -Wall -CFLAGS += -Werror -CFLAGS += -DUVM32_MEMORY_SIZE=16384 - -SUITE_NAME=tests - -TARGET_BASE1=test1 -TARGET1 = $(TARGET_BASE1) -SRC_FILES1=$(UNITY_ROOT)/src/unity.c test/${SUITE_NAME}.c test/test_runners/${SUITE_NAME}_Runner.c ../../uvm32/uvm32.c -INC_DIRS=-I$(UNITY_ROOT)/src -I../../uvm32/ -I../../common -Irom - -.PHONY: rom - -default: $(SRC_FILES1) rom - @$(C_COMPILER) $(CFLAGS) $(INC_DIRS) $(SYMBOLS) $(SRC_FILES1) rom/rom-header.c -o $(TARGET1) - @ ./$(TARGET1) - -rom: - @(cd rom && make) - -test/test_runners/${SUITE_NAME}_Runner.c: test/${SUITE_NAME}.c - @mkdir -p test/test_runners - @ruby $(UNITY_ROOT)/auto/generate_test_runner.rb test/${SUITE_NAME}.c test/test_runners/${SUITE_NAME}_Runner.c - -clean: - rm -rf $(TARGET1) test/test_runners - (cd rom && make clean) - +TOPDIR=../.. +include ${TOPDIR}/test/common/makefile.common diff --git a/test/meter/rom/Makefile b/test/meter/rom/Makefile index f831a3b..4cd3f50 100644 --- a/test/meter/rom/Makefile +++ b/test/meter/rom/Makefile @@ -1,14 +1,2 @@ -TOPDIR=../../../ -PROJECT:=$(shell basename ${PWD}) -SRCS=${PROJECT}.c ${TOPDIR}/apps/common/crt0.S -OPT=-O0 # don't let optimiser remove stall loop -all: all_common - @# Convert ROM to C file and header - @xxd -i ${PROJECT}.bin > ${PROJECT}-header.c - @echo "extern unsigned char ${PROJECT}_bin[]; extern int ${PROJECT}_bin_len;" > ${PROJECT}-header.h - -test: test_common -clean: clean_common - rm -f ${PROJECT}-header.h ${PROJECT}-header.c - -include ${TOPDIR}/apps/common/makefile.common +TOPDIR=../../.. +include ${TOPDIR}/test/common/makefile-rom.common diff --git a/test/stackoverflow/Makefile b/test/stackoverflow/Makefile index 9df5a9b..1c5e8ea 100644 --- a/test/stackoverflow/Makefile +++ b/test/stackoverflow/Makefile @@ -1,33 +1,4 @@ -C_COMPILER=gcc - -UNITY_ROOT=../unity - -CFLAGS=-std=c99 -CFLAGS += -Wall -CFLAGS += -Werror -CFLAGS += -DUVM32_MEMORY_SIZE=512 - -SUITE_NAME=tests - -TARGET_BASE1=test1 -TARGET1 = $(TARGET_BASE1) -SRC_FILES1=$(UNITY_ROOT)/src/unity.c test/${SUITE_NAME}.c test/test_runners/${SUITE_NAME}_Runner.c ../../uvm32/uvm32.c -INC_DIRS=-I$(UNITY_ROOT)/src -I../../uvm32/ -I../../common -Irom - -.PHONY: rom - -default: $(SRC_FILES1) rom - @$(C_COMPILER) $(CFLAGS) $(INC_DIRS) $(SYMBOLS) $(SRC_FILES1) rom/rom-header.c -o $(TARGET1) - @ ./$(TARGET1) - -rom: - @(cd rom && make) - -test/test_runners/${SUITE_NAME}_Runner.c: test/${SUITE_NAME}.c - @mkdir -p test/test_runners - @ruby $(UNITY_ROOT)/auto/generate_test_runner.rb test/${SUITE_NAME}.c test/test_runners/${SUITE_NAME}_Runner.c - -clean: - rm -rf $(TARGET1) test/test_runners - (cd rom && make clean) - +TOPDIR=../.. +UVM32_MEMORY_SIZE=512 +CFLAGS=-DUVM32_STACK_PROTECTION +include ${TOPDIR}/test/common/makefile.common diff --git a/test/stackoverflow/rom/Makefile b/test/stackoverflow/rom/Makefile index e5a6ad0..4cd3f50 100644 --- a/test/stackoverflow/rom/Makefile +++ b/test/stackoverflow/rom/Makefile @@ -1,14 +1,2 @@ -TOPDIR=../../../ -PROJECT:=$(shell basename ${PWD}) -SRCS=${PROJECT}.c ${TOPDIR}/apps/common/crt0.S -OPT=-O0 # don't optimise -all: all_common - @# Convert ROM to C file and header - @xxd -i ${PROJECT}.bin > ${PROJECT}-header.c - @echo "extern unsigned char ${PROJECT}_bin[]; extern int ${PROJECT}_bin_len;" > ${PROJECT}-header.h - -test: test_common -clean: clean_common - rm -f ${PROJECT}-header.h ${PROJECT}-header.c - -include ${TOPDIR}/apps/common/makefile.common +TOPDIR=../../.. +include ${TOPDIR}/test/common/makefile-rom.common diff --git a/test/syscall_args/Makefile b/test/syscall_args/Makefile index 6533b02..dc44dd1 100644 --- a/test/syscall_args/Makefile +++ b/test/syscall_args/Makefile @@ -1,33 +1,2 @@ -C_COMPILER=gcc - -UNITY_ROOT=../unity - -CFLAGS=-std=c99 -CFLAGS += -Wall -CFLAGS += -Werror -CFLAGS += -DUVM32_MEMORY_SIZE=16384 - -SUITE_NAME=tests - -TARGET_BASE1=test1 -TARGET1 = $(TARGET_BASE1) -SRC_FILES1=$(UNITY_ROOT)/src/unity.c test/${SUITE_NAME}.c test/test_runners/${SUITE_NAME}_Runner.c ../../uvm32/uvm32.c -INC_DIRS=-I$(UNITY_ROOT)/src -I../../uvm32/ -I../../common -Irom - -.PHONY: rom - -default: $(SRC_FILES1) rom - @$(C_COMPILER) $(CFLAGS) $(INC_DIRS) $(SYMBOLS) $(SRC_FILES1) rom/rom-header.c -o $(TARGET1) - @ ./$(TARGET1) - -rom: - @(cd rom && make) - -test/test_runners/${SUITE_NAME}_Runner.c: test/${SUITE_NAME}.c - @mkdir -p test/test_runners - @ruby $(UNITY_ROOT)/auto/generate_test_runner.rb test/${SUITE_NAME}.c test/test_runners/${SUITE_NAME}_Runner.c - -clean: - rm -rf $(TARGET1) test/test_runners - (cd rom && make clean) - +TOPDIR=../.. +include ${TOPDIR}/test/common/makefile.common diff --git a/test/syscall_args/rom/Makefile b/test/syscall_args/rom/Makefile index c85effd..4cd3f50 100644 --- a/test/syscall_args/rom/Makefile +++ b/test/syscall_args/rom/Makefile @@ -1,13 +1,2 @@ -TOPDIR=../../../ -PROJECT:=$(shell basename ${PWD}) -SRCS=${PROJECT}.c ${TOPDIR}/apps/common/crt0.S -all: all_common - @# Convert ROM to C file and header - @xxd -i ${PROJECT}.bin > ${PROJECT}-header.c - @echo "extern unsigned char ${PROJECT}_bin[]; extern int ${PROJECT}_bin_len;" > ${PROJECT}-header.h - -test: test_common -clean: clean_common - rm -f ${PROJECT}-header.h ${PROJECT}-header.c - -include ${TOPDIR}/apps/common/makefile.common +TOPDIR=../../.. +include ${TOPDIR}/test/common/makefile-rom.common