non-threaded RTS: don't assume deadlock if there are signal handlers to run
[ghc.git] / validate
1 #!/bin/sh
2
3 # Flags:
4 #   --no-clean:       don't make clean first, just carry on from
5 #                     a previous interrupted validation run
6 #   --testsuite-only: don't build the compiler, just run
7 #                     the test suite
8 #   --hpc:            build stage2 with -fhpc, and see how much of the
9 #                     compiler the test suite covers.
10 #                     2008-07-01: 63% slower than the default.
11 #                     HTML generated here: testsuite/hpc_output/hpc_index.html
12 #   --fast:           Default. Opposite to --slow.
13 #   --slow:           Build stage2 with -DDEBUG.
14 #                     2008-07-01: 14% slower than the default.
15
16 set -e
17
18 no_clean=0
19 testsuite_only=0
20 hpc=NO
21 slow=NO
22
23 while [ $# -gt 0 ]
24 do
25     case "$1" in
26     --no-clean)
27         no_clean=1
28         ;;
29     --testsuite-only)
30         testsuite_only=1
31         ;;
32     --hpc)
33         hpc=YES
34         ;;
35     --slow)
36         slow=YES
37         ;;
38     --fast)
39         slow=NO
40         ;;
41     *)
42         echo "Bad argument: $1" >&2
43         exit 1;;
44     esac
45     shift
46 done
47
48 if [ $testsuite_only -eq 0 ]; then
49
50 if [ $no_clean -eq 0 ] && [ -f mk/config.mk ]; then
51     make distclean
52 fi
53
54 case $OSTYPE in
55     cygwin|msys) config_args=--build=i386-unknown-mingw32
56         if [ -f c:/mingw/bin/gcc.exe ]
57         then
58             config_args="$config_args --with-gcc=c:/mingw/bin/gcc"
59         fi
60         ;;
61 esac
62
63 if [ "$CPUS" = "" ]; then
64     threads=2
65 else
66     threads=`expr $CPUS + 1`
67 fi
68
69 sh boot
70 ./configure "--prefix=`pwd`/inst" $config_args
71
72 thisdir=`utils/pwd/pwd forwardslash`
73
74 make Validating=YES -j$threads ValidateHpc=$hpc ValidateSlow=$slow
75 fi # testsuite-only
76
77 if [ "$hpc" = YES ]
78 then
79     # XXX With threads we'd need to give a different tix file to each thread
80     #     and then sum them up at the end
81     threads=1
82     HPCTIXFILE=$thisdir/testsuite/hpc_output/ghc.tix
83     export HPCTIXFILE
84     rm -f $HPCTIXFILE
85 fi
86
87 make Validating=YES -C testsuite/tests/ghc-regress fast stage=2 CLEANUP=1 THREADS=$threads 2>&1 | tee testlog
88
89 if [ "$hpc" = YES ]
90 then
91     utils/hpc/hpc markup --hpcdir=. --srcdir=compiler --srcdir=testsuite/hpc_output --destdir=testsuite/hpc_output testsuite/hpc_output/ghc.tix
92 fi
93
94 echo "-------------------------------------------------------------------"
95 if
96     grep '\<0 caused framework failures' testlog >/dev/null 2>/dev/null &&
97     grep '\<0 unexpected passes' testlog >/dev/null 2>/dev/null &&
98     grep '\<0 unexpected failures' testlog >/dev/null 2>/dev/null ; then
99     if [ $testsuite_only -eq 0 ] && [ $no_clean -eq 0 ]
100     then
101         cat <<EOF
102 Congratulations!  This tree has passed minimal testing.
103
104 NOTE: If you have made changes that may cause failures not tested for by
105 the minimal testing procedure, please do further testing as necessary.
106
107 When you are satisfied that you haven't broken anything, go ahead and
108 push/send your patches.
109 EOF
110     else
111         cat <<EOF
112 I didn't find any problems, but this wasn't a complete validate run,
113 so be careful!
114
115 NOTE: If you have made changes that may cause failures not tested for by
116 the minimal testing procedure, please do further testing as necessary.
117 EOF
118    fi
119 else
120     cat <<EOF
121 Oops!  Looks like you have some unexpected test results or framework failures.
122 Please fix them before pushing/sending patches.
123 EOF
124 fi
125 echo "-------------------------------------------------------------------"
126