f8cd3579f69aad5289f9d69fa9ec96e3076c0f29
[pintos-anon] / tests / Makefile
1 TESTS = examples 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 define mk-sandbox
17 rm -rf $@ && mkdir $@ && cp -R ../src $@/src
18 cd $@/src && $(MAKE) -s clean
19 endef
20
21 define run-tests
22 cd $@/src/$(PROJECT) && time $(MAKE) check
23 endef
24
25 define grade-tests
26 cd $@/src/$(PROJECT) && $(MAKE) grade
27 cd $@/src/$(PROJECT) && grep -q PERFECT build/grade
28 cd $@/src/$(PROJECT) && grep -qv warning build/grade
29 endef
30
31 define compile
32 cd $@/src/$(PROJECT) && $(MAKE)
33 endef
34
35 define clean
36 rm -rf $@
37 endef
38
39 define apply-patch
40 (cd $@ && patch -p0) < ../solutions/$@.patch
41 endef
42
43 PROJECT = $@
44 p1: PROJECT = threads
45 p2: PROJECT = userprog
46 p3: PROJECT = vm
47 p4: PROJECT = filesys
48
49 # Tests that just compile the provided code.
50 threads::
51         $(mk-sandbox)
52         $(compile)
53         $(run-tests) TESTS=tests/threads/alarm-single
54         $(clean)
55 examples userprog vm filesys::
56         $(mk-sandbox)
57         $(compile)
58         $(clean)
59
60 # Tests for the reference solutions.
61 p1 p2 p3 p4::
62         $(mk-sandbox)
63         $(apply-patch)
64         $(run-tests)
65         $(grade-tests)
66         $(clean)