- add localsettings.texi which contains Stanford-local macros and variables
[pintos.git] / src / tests / Make.tests
blob76d63f676cd838f76ffc20a75508ad377428ddca
1 # -*- makefile -*-
3 include $(patsubst %,$(SRCDIR)/%/Make.tests,$(TEST_SUBDIRS))
5 PROGS = $(foreach subdir,$(TEST_SUBDIRS),$($(subdir)_PROGS))
6 TESTS = $(foreach subdir,$(TEST_SUBDIRS),$($(subdir)_TESTS))
7 EXTRA_GRADES = $(foreach subdir,$(TEST_SUBDIRS),$($(subdir)_EXTRA_GRADES))
9 OUTPUTS = $(addsuffix .output,$(TESTS) $(EXTRA_GRADES))
10 ERRORS = $(addsuffix .errors,$(TESTS) $(EXTRA_GRADES))
11 RESULTS = $(addsuffix .result,$(TESTS) $(EXTRA_GRADES))
13 ifdef PROGS
14 include ../../Makefile.userprog
15 endif
17 TIMEOUT = 60
19 clean::
20         rm -f $(OUTPUTS) $(ERRORS) $(RESULTS) 
22 grade:: results
23         $(SRCDIR)/tests/make-grade $(SRCDIR) $< $(GRADING_FILE) | tee $@
25 check:: results
26         @cat $<
27         @COUNT="`egrep '^(pass|FAIL) ' $< | wc -l | sed 's/[    ]//g;'`"; \
28         FAILURES="`egrep '^FAIL ' $< | wc -l | sed 's/[         ]//g;'`"; \
29         if [ $$FAILURES = 0 ]; then                                       \
30                 echo "All $$COUNT tests passed.";                         \
31         else                                                              \
32                 echo "$$FAILURES of $$COUNT tests failed.";               \
33                 exit 1;                                                   \
34         fi
36 results: $(RESULTS)
37         @for d in $(TESTS) $(EXTRA_GRADES); do                  \
38                 if echo PASS | cmp -s $$d.result -; then        \
39                         echo "pass $$d";                        \
40                 else                                            \
41                         echo "FAIL $$d";                        \
42                 fi;                                             \
43         done > $@
45 outputs:: $(OUTPUTS)
47 $(foreach prog,$(PROGS),$(eval $(prog).output: $(prog)))
48 $(foreach test,$(TESTS),$(eval $(test).output: $($(test)_PUTFILES)))
49 $(foreach test,$(TESTS),$(eval $(test).output: TEST = $(test)))
51 # Prevent an environment variable VERBOSE from surprising us.
52 VERBOSE =
54 TESTCMD = pintos -v -k -T $(TIMEOUT)
55 TESTCMD += $(SIMULATOR)
56 TESTCMD += $(PINTOSOPTS)
57 ifeq ($(filter userprog, $(KERNEL_SUBDIRS)), userprog)
58 TESTCMD += --fs-disk=$(FSDISK)
59 TESTCMD += $(foreach file,$(PUTFILES),-p $(file) -a $(notdir $(file)))
60 endif
61 ifeq ($(filter vm, $(KERNEL_SUBDIRS)), vm)
62 TESTCMD += --swap-disk=4
63 endif
64 TESTCMD += -- -q 
65 TESTCMD += $(KERNELFLAGS)
66 ifeq ($(filter userprog, $(KERNEL_SUBDIRS)), userprog)
67 TESTCMD += -f
68 endif
69 TESTCMD += $(if $($(TEST)_ARGS),run '$(*F) $($(TEST)_ARGS)',run $(*F))
70 TESTCMD += < /dev/null
71 TESTCMD += 2> $(TEST).errors $(if $(VERBOSE),|tee,>) $(TEST).output
72 %.output: os.dsk
73         $(TESTCMD)
75 %.result: %.ck %.output
76         perl -I$(SRCDIR) $< $* $@