Devon H. O'Dell | 553be84 | 2009-11-14 15:29:09 -0800 | [diff] [blame] | 1 | #!/usr/bin/env bash |
Rob Pike | 27fb2ab | 2008-06-06 12:57:00 -0700 | [diff] [blame] | 2 | # Copyright 2009 The Go Authors. All rights reserved. |
| 3 | # Use of this source code is governed by a BSD-style |
| 4 | # license that can be found in the LICENSE file. |
| 5 | |
Christian Himpel | 5c603db | 2010-08-30 15:40:56 -0400 | [diff] [blame] | 6 | eval $(gomake --no-print-directory -f ../src/Make.inc go-env) |
Russ Cox | da392d9 | 2010-08-18 10:08:49 -0400 | [diff] [blame] | 7 | |
Rob Pike | 27fb2ab | 2008-06-06 12:57:00 -0700 | [diff] [blame] | 8 | case X"$GOARCH" in |
| 9 | Xamd64) |
| 10 | export A=6 |
| 11 | ;; |
Russ Cox | ead9f8b | 2009-05-31 12:35:11 -0700 | [diff] [blame] | 12 | X386) |
| 13 | export A=8 |
| 14 | ;; |
| 15 | Xarm) |
| 16 | export A=5 |
Russ Cox | b11740f | 2010-09-21 22:41:32 -0400 | [diff] [blame] | 17 | export E="$GORUN" |
Russ Cox | ead9f8b | 2009-05-31 12:35:11 -0700 | [diff] [blame] | 18 | ;; |
Rob Pike | 27fb2ab | 2008-06-06 12:57:00 -0700 | [diff] [blame] | 19 | *) |
Russ Cox | ead9f8b | 2009-05-31 12:35:11 -0700 | [diff] [blame] | 20 | echo 1>&2 run: unsupported '$GOARCH' |
Rob Pike | 27fb2ab | 2008-06-06 12:57:00 -0700 | [diff] [blame] | 21 | exit 1 |
| 22 | esac |
| 23 | |
Russ Cox | 567673f | 2009-09-22 16:56:28 -0700 | [diff] [blame] | 24 | case X"$GOOS" in |
| 25 | Xnacl) |
Russ Cox | c6138ef | 2010-04-22 17:52:22 -0700 | [diff] [blame] | 26 | export E=${GORUN:-$GOROOT/misc/nacl/naclrun} |
Russ Cox | 567673f | 2009-09-22 16:56:28 -0700 | [diff] [blame] | 27 | esac |
| 28 | |
Rob Pike | 27fb2ab | 2008-06-06 12:57:00 -0700 | [diff] [blame] | 29 | export G=${A}g |
| 30 | export L=${A}l |
Russ Cox | fb40f88 | 2008-09-22 13:47:53 -0700 | [diff] [blame] | 31 | export GOTRACEBACK=0 |
Ian Lance Taylor | 74a52ee | 2009-11-02 13:17:12 -0800 | [diff] [blame] | 32 | export LANG=C |
Russ Cox | f3a9729 | 2009-11-12 14:55:26 -0800 | [diff] [blame] | 33 | unset GREP_OPTIONS # in case user has a non-standard set |
Rob Pike | 27fb2ab | 2008-06-06 12:57:00 -0700 | [diff] [blame] | 34 | |
| 35 | failed=0 |
| 36 | |
Christian Himpel | 5c603db | 2010-08-30 15:40:56 -0400 | [diff] [blame] | 37 | PATH=/bin:/usr/bin:/usr/local/bin:${GOBIN:-$GOROOT/bin}:`pwd` |
Ian Lance Taylor | 66b261a | 2008-09-19 14:39:49 -0700 | [diff] [blame] | 38 | |
Russ Cox | 410ba58 | 2009-06-17 13:21:01 -0700 | [diff] [blame] | 39 | RUNFILE=/tmp/gorun-$$-$USER |
| 40 | TMP1FILE=/tmp/gotest1-$$-$USER |
| 41 | TMP2FILE=/tmp/gotest2-$$-$USER |
Rob Pike | 3963fe3 | 2008-08-08 10:57:23 -0700 | [diff] [blame] | 42 | |
Russ Cox | 46eb0f7 | 2008-09-08 15:22:45 -0700 | [diff] [blame] | 43 | # don't run the machine out of memory: limit individual processes to 4GB. |
| 44 | # on thresher, 3GB suffices to run the tests; with 2GB, peano fails. |
Russ Cox | 5b1b2ba | 2011-02-09 14:38:33 -0500 | [diff] [blame] | 45 | ulimit -v 4000000 |
Russ Cox | 46eb0f7 | 2008-09-08 15:22:45 -0700 | [diff] [blame] | 46 | |
Russ Cox | da77679 | 2009-11-09 23:11:36 -0800 | [diff] [blame] | 47 | # no core files please |
| 48 | ulimit -c 0 |
| 49 | |
Russ Cox | ebd27d6 | 2009-10-09 11:18:32 -0700 | [diff] [blame] | 50 | true >pass.out >times.out |
Russ Cox | 567673f | 2009-09-22 16:56:28 -0700 | [diff] [blame] | 51 | |
Russ Cox | b7cb844 | 2010-09-22 15:30:42 +1000 | [diff] [blame] | 52 | exclude=false # exclude nothing |
| 53 | golden=golden.out |
| 54 | |
| 55 | filterout() { |
| 56 | grep '^'"$2"'$' $1 >/dev/null |
| 57 | } |
| 58 | |
Russ Cox | 2a01d72 | 2010-01-26 23:13:22 -0800 | [diff] [blame] | 59 | for dir in . ken chan interface nilptr syntax fixedbugs bugs |
Rob Pike | 27fb2ab | 2008-06-06 12:57:00 -0700 | [diff] [blame] | 60 | do |
Russ Cox | 1ff5897 | 2009-07-29 15:11:19 -0700 | [diff] [blame] | 61 | echo |
| 62 | echo '==' $dir'/' |
Russ Cox | 60ff8cc | 2009-10-20 08:27:14 -0700 | [diff] [blame] | 63 | for i in $(ls $dir/*.go 2>/dev/null) |
Russ Cox | b7cb844 | 2010-09-22 15:30:42 +1000 | [diff] [blame] | 64 | do ( |
| 65 | if $exclude $i; then |
| 66 | exit 0 # continues for loop |
| 67 | fi |
Rob Pike | ab34d15 | 2008-06-06 14:27:34 -0700 | [diff] [blame] | 68 | export F=$(basename $i .go) |
| 69 | export D=$dir |
Russ Cox | 33c4ff0 | 2010-09-19 23:28:32 -0400 | [diff] [blame] | 70 | sed '/^\/\//!q' $i | sed 's@//@@; $d' |sed 's|./\$A.out|$E &|g' >$RUNFILE |
Sergey 'SnakE' Gromov | 842d69b | 2009-11-30 15:07:57 -0800 | [diff] [blame] | 71 | if ! { time -p bash -c "bash $RUNFILE >$TMP1FILE 2>&1" ; } 2>$TMP2FILE |
Rob Pike | ab34d15 | 2008-06-06 14:27:34 -0700 | [diff] [blame] | 72 | then |
Rob Pike | 3963fe3 | 2008-08-08 10:57:23 -0700 | [diff] [blame] | 73 | echo |
| 74 | echo "===========" $i |
| 75 | cat $TMP1FILE |
Rob Pike | ab34d15 | 2008-06-06 14:27:34 -0700 | [diff] [blame] | 76 | echo >&2 fail: $i |
Kai Backman | 36057e7 | 2010-07-20 15:53:16 +0300 | [diff] [blame] | 77 | echo "# $i # fail" >>pass.out |
Rob Pike | f6d67c9 | 2009-10-13 22:48:03 -0700 | [diff] [blame] | 78 | elif test -s $TMP1FILE |
Rob Pike | 3963fe3 | 2008-08-08 10:57:23 -0700 | [diff] [blame] | 79 | then |
| 80 | echo |
| 81 | echo "===========" $i |
| 82 | cat $TMP1FILE |
Kai Backman | 36057e7 | 2010-07-20 15:53:16 +0300 | [diff] [blame] | 83 | if grep -q '^BUG' $TMP1FILE |
| 84 | then |
Kai Backman | d0b913fe | 2010-08-03 13:09:16 -0700 | [diff] [blame] | 85 | if [ $dir != bugs ] |
| 86 | then |
| 87 | echo >&2 bug: $i |
| 88 | fi |
Kai Backman | 36057e7 | 2010-07-20 15:53:16 +0300 | [diff] [blame] | 89 | echo "# $i # fail, BUG" >>pass.out |
| 90 | else |
| 91 | echo $i >>pass.out |
| 92 | fi |
Russ Cox | 869c3f4 | 2008-11-17 12:44:22 -0800 | [diff] [blame] | 93 | elif [ $dir = "bugs" ] |
| 94 | then |
| 95 | echo $i succeeded with no output. |
Russ Cox | 567673f | 2009-09-22 16:56:28 -0700 | [diff] [blame] | 96 | else |
| 97 | echo $i >>pass.out |
Rob Pike | ab34d15 | 2008-06-06 14:27:34 -0700 | [diff] [blame] | 98 | fi |
Rob Pike | f6d67c9 | 2009-10-13 22:48:03 -0700 | [diff] [blame] | 99 | echo $(awk 'NR==1{print $2}' $TMP2FILE) $D/$F >>times.out |
Russ Cox | b7cb844 | 2010-09-22 15:30:42 +1000 | [diff] [blame] | 100 | ) done |
Rob Pike | bf14ef6 | 2008-07-07 10:03:10 -0700 | [diff] [blame] | 101 | done | # clean up some stack noise |
Rob Pike | 3963fe3 | 2008-08-08 10:57:23 -0700 | [diff] [blame] | 102 | egrep -v '^(r[0-9a-z]+|[cfg]s) +0x' | |
Russ Cox | 32556ef | 2008-09-02 14:26:59 -0700 | [diff] [blame] | 103 | sed '/tmp.*Bus error/s/.*Bus/Bus/; /tmp.*Trace.BPT/s/.*Trace/Trace/ |
| 104 | s!'$RUNFILE'!$RUNFILE!g |
Russ Cox | 60ff8cc | 2009-10-20 08:27:14 -0700 | [diff] [blame] | 105 | s/^PC=0x[0-9a-f]*/pc: xxx/ |
Russ Cox | fb40f88 | 2008-09-22 13:47:53 -0700 | [diff] [blame] | 106 | s/^pc: 0x[0-9a-f]*/pc: xxx/ |
Russ Cox | 60ff8cc | 2009-10-20 08:27:14 -0700 | [diff] [blame] | 107 | s/PC=0x[0-9a-f]*/PC=xxx/ |
Russ Cox | fb40f88 | 2008-09-22 13:47:53 -0700 | [diff] [blame] | 108 | /^Trace\/breakpoint trap/d |
Russ Cox | b014be7 | 2009-06-05 10:59:37 -0700 | [diff] [blame] | 109 | /^Trace\/BPT trap/d |
Ian Lance Taylor | 07c5442 | 2008-11-11 10:01:51 -0800 | [diff] [blame] | 110 | /RUNFILE/ s/line 1: *[0-9]*/line 1: PID/ |
Kai Backman | 1c71ab1 | 2009-09-18 19:09:12 -0700 | [diff] [blame] | 111 | /^\$RUNFILE: line 1: PID Trace\/breakpoint trap/d |
Russ Cox | 33c4ff0 | 2010-09-19 23:28:32 -0400 | [diff] [blame] | 112 | /Fault in NaCl untrusted code/d |
Russ Cox | 6c19601 | 2010-04-05 12:51:09 -0700 | [diff] [blame] | 113 | /Segmentation fault/d |
Kai Backman | 1c71ab1 | 2009-09-18 19:09:12 -0700 | [diff] [blame] | 114 | /^qemu: uncaught target signal 11 (Segmentation fault) - exiting/d' > run.out |
Rob Pike | 126150d | 2008-06-06 13:28:03 -0700 | [diff] [blame] | 115 | |
Russ Cox | b7cb844 | 2010-09-22 15:30:42 +1000 | [diff] [blame] | 116 | rm -f $RUNFILE $TMP1FILE $TMP2FILE *.$A *.a $A.out |
Russ Cox | 3314f8c | 2009-07-29 15:30:54 -0700 | [diff] [blame] | 117 | diffmsg="" |
Russ Cox | b7cb844 | 2010-09-22 15:30:42 +1000 | [diff] [blame] | 118 | if ! diff $golden run.out |
Rob Pike | 27fb2ab | 2008-06-06 12:57:00 -0700 | [diff] [blame] | 119 | then |
Russ Cox | 3314f8c | 2009-07-29 15:30:54 -0700 | [diff] [blame] | 120 | diffmsg="; test output differs" |
Rob Pike | 27fb2ab | 2008-06-06 12:57:00 -0700 | [diff] [blame] | 121 | failed=1 |
| 122 | fi |
Rob Pike | 17ee781 | 2008-06-06 13:38:16 -0700 | [diff] [blame] | 123 | |
Russ Cox | 1ff5897 | 2009-07-29 15:11:19 -0700 | [diff] [blame] | 124 | notinbugs=$(sed '/^== bugs/q' run.out | grep -c '^BUG') |
| 125 | inbugs=$(sed '1,/^== bugs/d' run.out | grep -c '^BUG') |
| 126 | |
Russ Cox | 3314f8c | 2009-07-29 15:30:54 -0700 | [diff] [blame] | 127 | echo 2>&1 $inbugs known bugs';' $notinbugs unexpected bugs$diffmsg |
Rob Pike | 17ee781 | 2008-06-06 13:38:16 -0700 | [diff] [blame] | 128 | |
Russ Cox | 66cdc69 | 2010-02-10 15:01:02 -0800 | [diff] [blame] | 129 | if [ "$failed" != "0" ]; then |
| 130 | echo FAILED |
| 131 | fi |
| 132 | |
Rob Pike | 27fb2ab | 2008-06-06 12:57:00 -0700 | [diff] [blame] | 133 | exit $failed |