Use qemu where appropriate and available.
[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 run-tests-grade
28 cd $@/src/$(PROJECT) && $(MAKE) check && make 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)
41 endef
42
43 PROJECT = $@
44
45 threads::
46         $(mk-sandbox)
47         $(compile)
48         $(run-tests) TESTS=tests/threads/alarm-single
49         $(clean)
50
51 userprog vm filesys::
52         $(mk-sandbox)
53         $(compile)
54         $(clean)
55
56 FAST_SIM := $(if $(shell which qemu),--qemu)
57 export PINTOSOPTS
58
59 p1: PROJECT = threads
60 p1::
61         $(mk-sandbox)
62         $(apply-patch) < ../solutions/p1.patch
63         $(run-tests-grade)
64         $(clean)
65
66 p2: PROJECT = userprog
67 p2: PINTOSOPTS = $(FAST_SIM)
68 p2::
69         $(mk-sandbox)
70         $(apply-patch) < ../solutions/p2.patch
71         $(run-tests-grade)
72         $(clean)
73
74 p3: PROJECT = vm
75 p3: PINTOSOPTS = $(FAST_SIM)
76 p3::
77         $(mk-sandbox)
78         $(apply-patch) < ../solutions/p3.patch
79         $(run-tests-grade)
80         $(clean)
81
82 p4: PROJECT = filesys
83 p4: PINTOSOPTS = $(FAST_SIM)
84 p4::
85         $(mk-sandbox)
86         $(apply-patch) < ../solutions/p4.patch
87         $(run-tests-grade)
88         $(clean)