Make tests public. Rewrite most tests. Add tests.
[pintos-anon] / tests / Makefile
1 TESTS = threads p1 userprog p2 vm p3 filesys p4
2
3 PATH := $(shell pwd)/../src/utils:$(PATH)
4
5 all:
6         @echo "This Makefile has only \`check' targets."
7
8 check:
9         $(MAKE) -C .. distclean
10         for d in $(TESTS); do $(MAKE) $$d || exit 1; done
11         @echo All tests passed.
12
13 clean:
14         rm -rf $(TESTS)
15
16 SUBMAKEFLAGS = -s
17
18 define mk-sandbox
19 rm -rf $@ && mkdir $@ && cp -R ../src $@/src
20 cd $@/src && $(MAKE) clean $(SUBMAKEFLAGS)
21 endef
22
23 define run-tests
24 cd $@/src/$(PROJECT) && make check
25 endef
26
27 define compile
28 cd $@/src/$(PROJECT) && make
29 endef
30
31 define clean
32 rm -rf $@
33 endef
34
35 define apply-patch
36 (cd $@ && patch -p0)
37 endef
38
39 PROJECT = $@
40
41 threads::
42         $(mk-sandbox)
43         $(compile)
44         $(run-tests) TESTS=tests/threads/alarm-single
45         $(clean)
46
47 userprog vm filesys::
48         $(mk-sandbox)
49         $(compile)
50         $(clean)
51
52 p1: PROJECT = threads
53 p1::
54         $(mk-sandbox)
55         $(apply-patch) < ../solutions/p1.patch
56         $(run-tests)
57         $(clean)
58
59 p2: PROJECT = userprog
60 p2::
61         $(mk-sandbox)
62         $(apply-patch) < ../solutions/p2.patch
63         $(run-tests)
64         $(clean)
65
66 p3: PROJECT = vm
67 p3::
68         $(mk-sandbox)
69         $(apply-patch) < ../solutions/p3.patch
70         $(run-tests)
71         $(clean)
72
73 p4: PROJECT = filesys
74 p4::
75         $(mk-sandbox)
76         $(apply-patch) < ../solutions/p4.patch
77         $(run-tests)
78         $(clean)