Also verify that running "make clean" deletes all the files in the
[pintos.git] / tests / Makefile
blobc2f8b018d3ebec2830bc09b9281f542db64dd7e8
1 TESTS = examples threads p1 userprog p2 vm p3 filesys p4
3 PATH := $(shell pwd)/../src/utils:$(PATH)
5 all:
6 @echo "This Makefile has only \`check' targets."
8 check:
9 $(MAKE) -C .. distclean
10 for d in $(TESTS); do $(MAKE) $$d || exit 1; done
11 @echo All tests passed.
13 clean:
14 rm -rf $(TESTS)
16 define mk-sandbox
17 rm -rf $@ && mkdir $@ && cp -R ../src $@/src
18 cd $@/src && $(MAKE) -s clean
19 endef
21 define run-tests
22 cd $@/src/$(PROJECT) && time $(MAKE) check
23 endef
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
31 define compile
32 cd $@/src/$(PROJECT) && $(MAKE)
33 endef
35 define test-clean
36 cd $@/src/$(PROJECT)/build && $(MAKE) clean
37 cd $@/src/$(PROJECT)/build && set `find -type f` > /dev/null && test $$# = 1
38 endef
40 define clean
41 rm -rf $@
42 endef
44 define apply-patch
45 (cd $@ && patch -p0) < ../solutions/$@.patch
46 endef
48 PROJECT = $@
49 p1: PROJECT = threads
50 p2: PROJECT = userprog
51 p3: PROJECT = vm
52 p4: PROJECT = filesys
54 # Tests that just compile the provided code.
55 threads::
56 $(mk-sandbox)
57 $(compile)
58 $(run-tests) TESTS=tests/threads/alarm-single
59 $(test-clean)
60 $(clean)
61 userprog vm filesys::
62 $(mk-sandbox)
63 $(compile)
64 $(test-clean)
65 $(clean)
66 examples::
67 $(mk-sandbox)
68 $(compile)
69 $(clean)
71 # Tests for the reference solutions.
72 p1 p2 p3 p4::
73 $(mk-sandbox)
74 $(apply-patch)
75 $(run-tests)
76 $(grade-tests)
77 $(test-clean)
78 $(clean)