-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakefile
More file actions
93 lines (82 loc) · 3.25 KB
/
makefile
File metadata and controls
93 lines (82 loc) · 3.25 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
# -------------------------------------------------
# Project configuration
# -------------------------------------------------
GOOS ?= $(shell go env GOOS)
GOROOT := $(shell go env GOROOT)
WASM_OUT := ./examples/public/flagon.wasm
WASM_JS := ./examples/public/wasm_exec.js
WASM_JS_SRC := $(firstword $(wildcard $(GOROOT)/lib/wasm/wasm_exec.js) $(wildcard $(GOROOT)/misc/wasm/wasm_exec.js))
ifeq ($(WASM_JS_SRC),)
$(error Could not find wasm_exec.js in $(GOROOT)/lib/wasm or $(GOROOT)/misc/wasm)
endif
# -------------------------------------------------
# Go environment
# -------------------------------------------------
ifeq ($(GOOS),windows)
SHELL := powershell.exe
SHELLFLAGS := -NoProfile -Command
ENV_WASM := $$env:GOOS='js'; $$env:GOARCH='wasm';
COPY_WASM_JS := Copy-Item '$(WASM_JS_SRC)' '$(WASM_JS)' -Force
WASM_BUILD_CMD := $(ENV_WASM) go build -o '$(WASM_OUT)' ./wasm
else
ENV_WASM := GOOS=js GOARCH=wasm
COPY_WASM_JS := cp '$(WASM_JS_SRC)' '$(WASM_JS)'
WASM_BUILD_CMD := $(ENV_WASM) go build -o '$(WASM_OUT)' ./wasm
endif
# -------------------------------------------------
# Fuzz test configuration
# -------------------------------------------------
FUZZ_TIME ?= 30s
FUZZ_TEST ?= FuzzCLIRun
# -------------------------------------------------
# Targets
# -------------------------------------------------
.PHONY: test fuzz fuzz-all wasm-env build-wasm
test:
ifeq ($(GOOS),windows)
cd cli; go test -fuzz=^$$;
cd lua; go test -fuzz=^$$;
else
cd cli && go test -fuzz='^$$'
cd lua && go test -fuzz='^$$'
endif
fuzz:
ifeq ($(GOOS),windows)
cd cli; go test -fuzz=$(FUZZ_TEST) -fuzztime=$(FUZZ_TIME);
cd lua; go test -fuzz=$(FUZZ_TEST) -fuzztime=$(FUZZ_TIME);
else
cd cli && go test -fuzz=$(FUZZ_TEST) -fuzztime=$(FUZZ_TIME)
cd lua && go test -fuzz=$(FUZZ_TEST) -fuzztime=$(FUZZ_TIME)
endif
fuzz-all:
ifeq ($(GOOS),windows)
cd cli; go test -fuzz=FuzzCLIRun -fuzztime=$(FUZZ_TIME);
cd cli; go test -fuzz=FuzzValidatePositionalArgs -fuzztime=$(FUZZ_TIME);
cd cli; go test -fuzz=FuzzFindSubcommand -fuzztime=$(FUZZ_TIME);
cd cli; go test -fuzz=FuzzCollides -fuzztime=$(FUZZ_TIME);
cd cli; go test -fuzz=FuzzContextFunctions -fuzztime=$(FUZZ_TIME);
cd cli; go test -fuzz=FuzzMiddlewareChain -fuzztime=$(FUZZ_TIME);
cd lua; go test -fuzz=FuzzLuaScriptExecution -fuzztime=$(FUZZ_TIME);
cd lua; go test -fuzz=FuzzDecodeCommand -fuzztime=$(FUZZ_TIME);
cd lua; go test -fuzz=FuzzLuaHandler -fuzztime=$(FUZZ_TIME);
cd lua; go test -fuzz=FuzzLuaMiddleware -fuzztime=$(FUZZ_TIME);
else
cd cli && go test -fuzz=FuzzCLIRun -fuzztime=$(FUZZ_TIME)
cd cli && go test -fuzz=FuzzValidatePositionalArgs -fuzztime=$(FUZZ_TIME)
cd cli && go test -fuzz=FuzzFindSubcommand -fuzztime=$(FUZZ_TIME)
cd cli && go test -fuzz=FuzzCollides -fuzztime=$(FUZZ_TIME)
cd cli && go test -fuzz=FuzzContextFunctions -fuzztime=$(FUZZ_TIME)
cd cli && go test -fuzz=FuzzMiddlewareChain -fuzztime=$(FUZZ_TIME)
cd lua && go test -fuzz=FuzzLuaScriptExecution -fuzztime=$(FUZZ_TIME)
cd lua && go test -fuzz=FuzzDecodeCommand -fuzztime=$(FUZZ_TIME)
cd lua && go test -fuzz=FuzzLuaHandler -fuzztime=$(FUZZ_TIME)
cd lua && go test -fuzz=FuzzLuaMiddleware -fuzztime=$(FUZZ_TIME)
endif
wasm-env:
ifeq ($(GOOS),windows)
$(SHELL) $(SHELLFLAGS) "$(COPY_WASM_JS)"
else
$(COPY_WASM_JS)
endif
build-wasm: wasm-env
$(WASM_BUILD_CMD)