VM := ../../rv32-vm CC := ../../ccompiler STD_CC := gcc TESTS := $(wildcard *.c) # 定义所有测试目标 TEST_TARGETS := $(patsubst %.c, %_test, $(TESTS)) all: $(TEST_TARGETS) %_test: %.c @$(STD_CC) -g -o $@ $< @$(CC) $< flat.bin @./$@ ; ret_gcc=$$? @$(VM) flat.bin ; ret_vm=$$? @echo "Testing $@" @if [ $$ret_gcc -eq $$ret_vm ]; then \ echo "$@ passed"; \ else \ echo "$@ failed: GCC returned $$ret_gcc, VM returned $$ret_vm"; \ exit 1; \ fi clean: rm -f $(TEST_TARGETS) flat.bin .PHONY: all clean