-
Notifications
You must be signed in to change notification settings - Fork 14
/
Makefile
executable file
·137 lines (99 loc) · 4.5 KB
/
Makefile
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
SHELL := /bin/bash
define TIMEFORMAT
%R real, %U user, %S sys
endef
export TIMEFORMAT
PYTHON := python3 -u
MYPYVY_OPTS := --seed=0 --log=info --timeout 10000 --print-cmdline
SRC_FILES := $(shell find src -name '*.py' -not -name '*parsetab*' -not -path '*/ply/*')
PYV_FILES := $(sort $(wildcard examples/*.pyv))
test: check check-imports unit typecheck verify verify.cvc4 trace updr pd sep
gh-test: check check-imports unit typecheck verify trace updr sep
style:
$(PYTHON) -m flake8 $(SRC_FILES) || true
grep the_program $(SRC_FILES) || true
check:
$(PYTHON) -m mypy --config-file ./mypy.ini $(SRC_FILES)
@echo
check-imports: $(patsubst %.py, %.importable, $(SRC_FILES))
src/%.importable: src/%.py check
@cd src; $(PYTHON) -c "import $(shell basename -s .py $<)" || { echo "file $< is not importable"; exit 1; }
unit: check check-imports
$(PYTHON) -m unittest discover -s src -v
@echo
prelude: check check-imports unit
@echo ========================= Starting mypyvy tests =========================
@echo
typecheck: $(patsubst %.pyv, %.typecheck, $(PYV_FILES))
verify: $(patsubst %.pyv, %.verify, $(PYV_FILES))
verify.cvc4: $(patsubst %.pyv, %.verify.cvc4, $(PYV_FILES))
trace: $(patsubst %.pyv, %.trace, $(PYV_FILES))
updr: examples/lockserv.updr examples/sharded_kv.updr
runmypyvy = time ( $(PYTHON) src/mypyvy.py $(1) $(MYPYVY_OPTS) $(2) > $(3).out && \
echo $$'\n'`head -n 1 $(3).out`$$'\n'`tail -n 1 $(3).out` )
runmypyvy_grep = time ( $(PYTHON) src/mypyvy.py $(1) $(MYPYVY_OPTS) $(2) > $(3).out && \
echo $$'\n'`head -n 1 $(3).out` && \
grep $(4) $(3).out )
%.typecheck: %.pyv prelude
$(PYTHON) src/mypyvy.py typecheck $(MYPYVY_OPTS) $< > [email protected]
@#curl -s -H 'Content-Type: application/json' -X POST -d "{\"filename\": \"$<\"}" http://localhost:5000/typecheck | jq -e .success
%.verify: %.pyv prelude
$(call runmypyvy, verify --exit-0, $<, $@)
@# curl -s -H 'Content-Type: application/json' -X POST -d "{\"filename\": \"$<\", \"options\": [\"--seed=0\", \"--timeout=10000\"]}" http://localhost:5000/verify | jq -e '.success or (has("reason") and (.reason == "Verification error" or .reason == "Verification returned unknown"))'
%.verify.cvc4: %.pyv prelude
$(call runmypyvy, verify --exit-0 --cvc4, $<, $@)
%.trace: %.pyv prelude
$(call runmypyvy, trace, $<, $@)
%.updr: %.pyv prelude
$(call runmypyvy, updr, $<, $@)
pd: prelude
# primal-dual-houdini
# should take about 1 minute
$(call runmypyvy_grep, \
pd-primal-dual-houdini --clear-cache --no-restarts --no-all-subclauses --induction-width=1 --cpus 2, \
examples/ring_leader_election_single_sort.pyv, \
examples/ring_leader_election_single_sort.primal-dual-houdini, \
"Proved safety!")
# should take about 2 minutes
$(call runmypyvy_grep, \
pd-primal-dual-houdini --clear-cache --no-restarts --no-all-subclauses --induction-width=1 --cpus 2, \
examples/sharded_kv.pyv, \
examples/sharded_kv.prima-dual-houdini, \
"Fixed point of induction width reached without a safety proof!")
pd-long: prelude
# primal-dual-houdini for problems that take a long time
# should take about 6 minutes
$(call runmypyvy_grep, \
pd-primal-dual-houdini --clear-cache --no-restarts --no-all-subclauses --induction-width=1 --cpus 2, \
examples/ring_leader_election.pyv, \
examples/ring_leader_election.primal-dual-houdini, \
"Proved safety!")
# can take upto 2 hours
$(call runmypyvy_grep, \
pd-primal-dual-houdini --clear-cache --no-restarts --no-all-subclauses --induction-width=1 --cpus 2, \
examples/toy_leader_consensus_forall.pyv, \
examples/toy_leader_consensus_forall.primal-dual-houdini, \
"Proved safety!")
# can take a few hours
$(call runmypyvy_grep, \
pd-primal-dual-houdini --clear-cache --no-restarts --no-all-subclauses --induction-width=1 --cpus 2, \
examples/lockserv.pyv, \
examples/lockserv.primal-dual-houdini, \
-E "Proved safety!$|Fixed point of induction width reached without a safety proof!$")
sep: \
examples/ring_leader_election.sep \
examples/ring_leader_election_single_sort.sep \
examples/lockserv.sep \
examples/toy_leader_consensus_forall.sep \
%.sep: %.pyv prelude
time ( $(PYTHON) src/mypyvy.py sep $(MYPYVY_OPTS) $< > [email protected] && \
echo && head -n 1 [email protected] && \
grep "Successfully learned a total" [email protected] )
nightly:
python3 script/nightly.py
clear-cache:
rm -iv examples/*.cache
clean:
rm -fv examples/*.out
rm -fr .mypy_cache/
.PHONY: style check run test verify verify-pd updr bench typecheck trace pd pd-old pd-long unit check-imports clear-cache nightly clean prelude gh-test