Allow generating multiple Breker tests per constraint file

This commit is contained in:
Jordan Carlin 2025-02-23 01:00:18 -08:00
parent 433763e6ee
commit caa4d27a99
No known key found for this signature in database

View file

@ -1,3 +1,6 @@
NUM_TESTS ?= 1 # Number of tests to generate for each constraint file
# General Makefile settings
SHELL := /bin/bash SHELL := /bin/bash
# Breker/Trek paths and variables # Breker/Trek paths and variables
@ -21,26 +24,29 @@ LINK_FLAGS := -nostartfiles
CFLAGS := -Wa,-alhs -Wa,-L -mcmodel=medany -Og -DSINGLE_CPU CFLAGS := -Wa,-alhs -Wa,-L -mcmodel=medany -Og -DSINGLE_CPU
WIDTH := 64 WIDTH := 64
# Find all constraint files and generate tests for each one # Find all constraint files and generate NUM_TESTS tests for each one
TESTS = $(patsubst $(CONSTRAINTS_DIR)/%.yaml,$(TESTDIR)/%,$(CONSTRAINT_FILES)) TESTS = $(foreach yaml,$(CONSTRAINT_FILES),$(foreach n,$(shell seq 1 $(NUM_TESTS)),$(patsubst $(CONSTRAINTS_DIR)/%.yaml,$(TESTDIR)/%_$(n),$(yaml))))
.PHONY: all clean .PHONY: all clean
all: $(TESTS) all: $(TESTS)
# Generate c tests # Generate c tests
$(TESTDIR)/%: $(CONSTRAINTS_DIR)/%.yaml | $(TESTDIR) $(TESTDIR)/%: | $(TESTDIR)
$(TREKSVIP) -p $< -p $(CUSTOMER_YAML) -o $@/$* -e pss_top.entry $(eval CONSTRAINT_FILE := $(shell echo $* | sed 's/_[0-9]*$$//'))
$(MAKE) $@/$*.elf.memfile $(TREKSVIP) -p $(CONSTRAINTS_DIR)/$(CONSTRAINT_FILE).yaml -p $(CUSTOMER_YAML) -o $@/$* -e pss_top.entry
$(MAKE) $@/$*.elf
# Compile c code # Compile c code
.PRECIOUS: %.elf .PRECIOUS: $(TESTDIR)/%.elf
%.elf: %.c $(TESTDIR)/%.elf: $(TESTDIR)/%.c
riscv64-unknown-elf-gcc $(MARCH) $(MABI) $(CFLAGS) $(LINK_FLAGS) -T$(LINKER) -I$(START_LIB_DIR) $(START_LIB) -g -o $@ $< > /dev/null riscv64-unknown-elf-gcc $(MARCH) $(MABI) $(CFLAGS) $(LINK_FLAGS) -T$(LINKER) -I$(START_LIB_DIR) $(START_LIB) -g -o $@ $< > /dev/null
$(MAKE) $@.objdump
# Convert elf to hex # Convert elf to hex
%.elf.memfile: %.elf $(TESTDIR)/%.elf.objdump: $(TESTDIR)/%.elf
riscv64-unknown-elf-objdump -D $< > $<.objdump riscv64-unknown-elf-objdump -D $< > $@
riscv64-unknown-elf-elf2hex --bit-width $(WIDTH) --input $< --output $@ # riscv64-unknown-elf-elf2hex --bit-width $(WIDTH) --input $< --output $@
extractFunctionRadix.sh $<.objdump # extractFunctionRadix.sh $<.objdump
# View the model graph TODO: What does this do? Move to another makefile? # View the model graph TODO: What does this do? Move to another makefile?
%.view_graph: $(CONSTRAINTS_DIR)/%.yaml %.view_graph: $(CONSTRAINTS_DIR)/%.yaml