Make tests public. Rewrite most tests. Add tests.
[pintos-anon] / src / tests / Make.tests
1 # -*- makefile -*-
2
3 include $(patsubst %,$(SRCDIR)/%/Make.tests,$(TEST_SUBDIRS))
4
5 PROGS = $(foreach subdir,$(TEST_SUBDIRS),$($(subdir)_PROGS))
6 TESTS = $(foreach subdir,$(TEST_SUBDIRS),$($(subdir)_TESTS))
7
8 include ../../Makefile.userprog
9
10 PINTOSFLAGS += -v $(foreach file,$(PUTFILES),-p $(file) -a $(notdir $(file)))
11 KERNELFLAGS += -q
12 PINTOS = pintos $(PINTOSOPTS) $(PINTOSFLAGS) -- $(KERNELFLAGS)
13
14 OUTPUTS = $(addsuffix .output,$(TESTS))
15 ERRORS = $(addsuffix .errors,$(TESTS))
16 RESULTS = $(addsuffix .result,$(TESTS))
17
18 clean::
19         rm -f $(OUTPUTS) $(ERRORS) $(RESULTS) 
20
21 grade:: ../rubric.txt results
22         @pass=;                                                 \
23         for d in $(TESTS); do                                   \
24                 if echo PASS | cmp -s $$d.result -; then        \
25                         pass="$$pass $$d";                      \
26                 fi                                              \
27         done;                                                   \
28         $(SRCDIR)/tests/make-grade $< $$pass
29
30 check:: results
31         @f=0;                                                   \
32         n=0;                                                    \
33         echo "Test summary:";                                   \
34         for d in $(TESTS); do                                   \
35                 if echo PASS | cmp -s $$d.result -; then        \
36                         echo "pass $$d";                        \
37                 else                                            \
38                         echo "FAIL $$d";                        \
39                         f=`expr $$f + 1`;                       \
40                 fi;                                             \
41                 n=`expr $$n + 1`;                               \
42         done;                                                   \
43         if [ $$f = 0 ]; then                                    \
44                 echo "All $$n tests passed.";                   \
45         else                                                    \
46                 echo "$$f of $$n tests failed.";                \
47                 exit 1;                                         \
48         fi
49
50 results:: $(RESULTS)
51 outputs:: $(OUTPUTS)
52
53 $(foreach prog,$(PROGS),$(eval $(prog).output: $(prog)))
54 $(foreach test,$(TESTS),$(eval $(test).output: $($(test)_PUTFILES)))
55 tests/%.output: RUNCMD = $(if $($*_ARGS),run '$(*F) $($*_ARGS)',run $(*F))
56 tests/%.output: RUNREDIR = 2>$*.errors $(if $(VERBOSE),|tee,>) $*.output
57 tests/%.output: RUNTEST = $(PINTOS) $(RUNCMD) $(RUNREDIR)
58 %.output: os.dsk
59         $(RUNTEST)
60
61 %.result: %.ck %.output
62         perl -I$(SRCDIR) $< $* $@