-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
103 lines (82 loc) · 3.31 KB
/
Makefile
File metadata and controls
103 lines (82 loc) · 3.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
.PHONY: all
all: build run
.PHONY: build
build: build-fuzzer build-testbench pre-commit-hook build-generate
GODIRS=./cmd ./pkg ./internal
_GODIRS=./cmd/... ./pkg/... ./internal/...
GOBUILDFILES=$(shell find $(GODIRS) -name '*.go' -not -path './cmd/*' -not -name '*_test.go')
GOTESTFILES=$(shell find $(GODIRS) -name '*_test.go')
ALLGOFILES=$(shell find $(GODIRS) -name '*.go')
SVFILES=$(shell find snippets -name '*.sv')
.PHONY: pre-commit-hook
pre-commit-hook: .pre-commit
@chmod +x .pre-commit
@ln -sf ../../.pre-commit .git/hooks/pre-commit
@echo "Pre-commit hook installed"
.PHONY: build-fuzzer
build-fuzzer: pfuzz
pfuzz: cmd/pfuzz/main.go $(GOBUILDFILES)
go build -o pfuzz cmd/pfuzz/main.go
.PHONY: build-testbench
build-testbench: testbench
testbench: cmd/testbench/main.go $(GOBUILDFILES)
go build -o testbench cmd/testbench/main.go
.PHONY: build-generate
build-generate: generate
generate: cmd/generate/main.go $(GOBUILDFILES)
go build -o generate cmd/generate/main.go
.test-go.log: pfuzz $(GOTESTFILES)
@echo "Running Go tests..."
@go test -parallel 1 -timeout 120s ./...
@touch .test-go.log
.PHONY: tests
tests: .test-go.log
.PHONY: lint
lint: .lint.log
.lint.log: $(ALLGOFILES) $(SVFILES)
@echo "Running linters..."
@golangci-lint run $(_GODIRS) --timeout 20s --color=always --fix
@find snippets -name '*.sv' -exec ./scripts/fix-indent.sh {} \;
@touch .lint.log
.PHONY: clean
clean:
rm -rf dist mismatches debug_logs *.json
.PHONY: purge
purge: clean
rm -f pfuzz patterns mismatch_*.txt
.PHONY: help
help:
@echo "Available targets:"
@echo " make - Build and run basic fuzzer"
@echo " make build - Build all tools"
@echo " make run - Run fuzzer"
@echo " make tests - Run all tests"
@echo " make clean - Remove temporary files"
@echo " make purge - Remove all generated files and executables"
@echo " make patterns - Analyze patterns in mismatches"
@echo " make test-module FILE=path/to/module.sv - Test a specific module"
@echo ""
@echo "Example usage:"
@echo " make - Run default fuzzer"
@echo " make run OPTS=\"-n 100 -strategy simple -vvv\" - Run with custom options"
@echo " make tests - Run all test cases"
@echo " make test-module FILE=testfiles/sv/simple_adder.sv - Test a specific module"
# Allow passing custom options to the fuzzer
ifneq ($(OPTS),)
run: clean
./pfuzz $(OPTS)
endif
.PHONY: checkSnippets
checkSnippets:
for i in snippets/*.sv ; do ss=$$(pfuzz -strategy smart -check-file -vv -file $$i 2>/dev/null) ; if [ $$? -eq 0 ]; then echo "[+] success" $$i ; else echo "[-] failure" $$i; fi ; done
.PHONY: addValidSnippets
addValidSnippets:
for i in $$(git status -s | grep -Eo 'snippets/V3\w+\.sv'); do ss=$$(pfuzz -strategy smart -check-file -vv -file $$i 2>/dev/null) ; if [ $$? -eq 0 ]; then echo "[+] success" $$i && git add $$i ; else echo "[-] failure" $$i; fi ; done
.PHONY: isolated
isolated:
for i in snippets/*.sv ; do ss=$(pfuzz rewrite-as-snippets -strategy smart -vv -file $i) ;if [ $? -eq 0 ]; then echo "[+] success" $i ; else echo "[-] failure" $i; fi ; done
.PHONY: removeKnown
removeKnown:
rm -r `find mismatches -name '*_inj_o_done*' -exec dirname {} \;`
rm -r `find mismatches -name '*_inj_data_reg*' -exec dirname {} \;`
rm -r `find mismatches -name '*_inj_count_out_*.hex' -exec dirname {} \;`