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 | |
Kai Backman | 1c71ab1 | 2009-09-18 19:09:12 -0700 | [diff] [blame] | 6 | export E="" |
Rob Pike | 27fb2ab | 2008-06-06 12:57:00 -0700 | [diff] [blame] | 7 | case X"$GOARCH" in |
| 8 | Xamd64) |
| 9 | export A=6 |
| 10 | ;; |
Russ Cox | ead9f8b | 2009-05-31 12:35:11 -0700 | [diff] [blame] | 11 | X386) |
| 12 | export A=8 |
| 13 | ;; |
| 14 | Xarm) |
| 15 | export A=5 |
Kai Backman | df3a544 | 2010-04-15 12:47:49 +0300 | [diff] [blame] | 16 | export E=${GORUN:-qemu-arm -cpu cortex-a8} |
Russ Cox | ead9f8b | 2009-05-31 12:35:11 -0700 | [diff] [blame] | 17 | ;; |
Rob Pike | 27fb2ab | 2008-06-06 12:57:00 -0700 | [diff] [blame] | 18 | *) |
Russ Cox | ead9f8b | 2009-05-31 12:35:11 -0700 | [diff] [blame] | 19 | echo 1>&2 run: unsupported '$GOARCH' |
Rob Pike | 27fb2ab | 2008-06-06 12:57:00 -0700 | [diff] [blame] | 20 | exit 1 |
| 21 | esac |
| 22 | |
Russ Cox | 567673f | 2009-09-22 16:56:28 -0700 | [diff] [blame] | 23 | case X"$GOOS" in |
| 24 | Xnacl) |
Russ Cox | c6138ef | 2010-04-22 17:52:22 -0700 | [diff] [blame] | 25 | export E=${GORUN:-$GOROOT/misc/nacl/naclrun} |
Russ Cox | 567673f | 2009-09-22 16:56:28 -0700 | [diff] [blame] | 26 | esac |
| 27 | |
Rob Pike | 27fb2ab | 2008-06-06 12:57:00 -0700 | [diff] [blame] | 28 | export G=${A}g |
| 29 | export L=${A}l |
Russ Cox | fb40f88 | 2008-09-22 13:47:53 -0700 | [diff] [blame] | 30 | export GOTRACEBACK=0 |
Ian Lance Taylor | 74a52ee | 2009-11-02 13:17:12 -0800 | [diff] [blame] | 31 | export LANG=C |
Russ Cox | f3a9729 | 2009-11-12 14:55:26 -0800 | [diff] [blame] | 32 | unset GREP_OPTIONS # in case user has a non-standard set |
Rob Pike | 27fb2ab | 2008-06-06 12:57:00 -0700 | [diff] [blame] | 33 | |
| 34 | failed=0 |
| 35 | |
Kai Backman | 1c71ab1 | 2009-09-18 19:09:12 -0700 | [diff] [blame] | 36 | PATH=/bin:/usr/bin:/usr/local/bin:${GOBIN:-$HOME/bin}:`pwd` |
Ian Lance Taylor | 66b261a | 2008-09-19 14:39:49 -0700 | [diff] [blame] | 37 | |
Russ Cox | 410ba58 | 2009-06-17 13:21:01 -0700 | [diff] [blame] | 38 | RUNFILE=/tmp/gorun-$$-$USER |
| 39 | TMP1FILE=/tmp/gotest1-$$-$USER |
| 40 | TMP2FILE=/tmp/gotest2-$$-$USER |
Rob Pike | 3963fe3 | 2008-08-08 10:57:23 -0700 | [diff] [blame] | 41 | |
Russ Cox | 46eb0f7 | 2008-09-08 15:22:45 -0700 | [diff] [blame] | 42 | # don't run the machine out of memory: limit individual processes to 4GB. |
| 43 | # on thresher, 3GB suffices to run the tests; with 2GB, peano fails. |
| 44 | ulimit -v 4000000 |
| 45 | |
Russ Cox | da77679 | 2009-11-09 23:11:36 -0800 | [diff] [blame] | 46 | # no core files please |
| 47 | ulimit -c 0 |
| 48 | |
Russ Cox | ebd27d6 | 2009-10-09 11:18:32 -0700 | [diff] [blame] | 49 | true >pass.out >times.out |
Russ Cox | 567673f | 2009-09-22 16:56:28 -0700 | [diff] [blame] | 50 | |
Russ Cox | 2a01d72 | 2010-01-26 23:13:22 -0800 | [diff] [blame] | 51 | for dir in . ken chan interface nilptr syntax fixedbugs bugs |
Rob Pike | 27fb2ab | 2008-06-06 12:57:00 -0700 | [diff] [blame] | 52 | do |
Russ Cox | 1ff5897 | 2009-07-29 15:11:19 -0700 | [diff] [blame] | 53 | echo |
| 54 | echo '==' $dir'/' |
Russ Cox | 60ff8cc | 2009-10-20 08:27:14 -0700 | [diff] [blame] | 55 | for i in $(ls $dir/*.go 2>/dev/null) |
Rob Pike | ab34d15 | 2008-06-06 14:27:34 -0700 | [diff] [blame] | 56 | do |
Rob Pike | ab34d15 | 2008-06-06 14:27:34 -0700 | [diff] [blame] | 57 | export F=$(basename $i .go) |
| 58 | export D=$dir |
Russ Cox | 567673f | 2009-09-22 16:56:28 -0700 | [diff] [blame] | 59 | sed '/^\/\//!q' $i | sed 's@//@@; $d' |sed 's|./\$A.out|$E &|' >$RUNFILE |
Sergey 'SnakE' Gromov | 842d69b | 2009-11-30 15:07:57 -0800 | [diff] [blame] | 60 | if ! { time -p bash -c "bash $RUNFILE >$TMP1FILE 2>&1" ; } 2>$TMP2FILE |
Rob Pike | ab34d15 | 2008-06-06 14:27:34 -0700 | [diff] [blame] | 61 | then |
Rob Pike | 3963fe3 | 2008-08-08 10:57:23 -0700 | [diff] [blame] | 62 | echo |
| 63 | echo "===========" $i |
| 64 | cat $TMP1FILE |
Rob Pike | ab34d15 | 2008-06-06 14:27:34 -0700 | [diff] [blame] | 65 | echo >&2 fail: $i |
Rob Pike | f6d67c9 | 2009-10-13 22:48:03 -0700 | [diff] [blame] | 66 | elif test -s $TMP1FILE |
Rob Pike | 3963fe3 | 2008-08-08 10:57:23 -0700 | [diff] [blame] | 67 | then |
| 68 | echo |
| 69 | echo "===========" $i |
| 70 | cat $TMP1FILE |
Russ Cox | 869c3f4 | 2008-11-17 12:44:22 -0800 | [diff] [blame] | 71 | elif [ $dir = "bugs" ] |
| 72 | then |
| 73 | echo $i succeeded with no output. |
Russ Cox | 567673f | 2009-09-22 16:56:28 -0700 | [diff] [blame] | 74 | else |
| 75 | echo $i >>pass.out |
Rob Pike | ab34d15 | 2008-06-06 14:27:34 -0700 | [diff] [blame] | 76 | fi |
Rob Pike | f6d67c9 | 2009-10-13 22:48:03 -0700 | [diff] [blame] | 77 | echo $(awk 'NR==1{print $2}' $TMP2FILE) $D/$F >>times.out |
Rob Pike | ab34d15 | 2008-06-06 14:27:34 -0700 | [diff] [blame] | 78 | done |
Rob Pike | bf14ef6 | 2008-07-07 10:03:10 -0700 | [diff] [blame] | 79 | done | # clean up some stack noise |
Rob Pike | 3963fe3 | 2008-08-08 10:57:23 -0700 | [diff] [blame] | 80 | egrep -v '^(r[0-9a-z]+|[cfg]s) +0x' | |
Russ Cox | 32556ef | 2008-09-02 14:26:59 -0700 | [diff] [blame] | 81 | sed '/tmp.*Bus error/s/.*Bus/Bus/; /tmp.*Trace.BPT/s/.*Trace/Trace/ |
| 82 | s!'$RUNFILE'!$RUNFILE!g |
Russ Cox | 60ff8cc | 2009-10-20 08:27:14 -0700 | [diff] [blame] | 83 | s/^PC=0x[0-9a-f]*/pc: xxx/ |
Russ Cox | fb40f88 | 2008-09-22 13:47:53 -0700 | [diff] [blame] | 84 | s/^pc: 0x[0-9a-f]*/pc: xxx/ |
Russ Cox | 60ff8cc | 2009-10-20 08:27:14 -0700 | [diff] [blame] | 85 | s/PC=0x[0-9a-f]*/PC=xxx/ |
Russ Cox | fb40f88 | 2008-09-22 13:47:53 -0700 | [diff] [blame] | 86 | /^Trace\/breakpoint trap/d |
Russ Cox | b014be7 | 2009-06-05 10:59:37 -0700 | [diff] [blame] | 87 | /^Trace\/BPT trap/d |
Ian Lance Taylor | 07c5442 | 2008-11-11 10:01:51 -0800 | [diff] [blame] | 88 | /RUNFILE/ s/line 1: *[0-9]*/line 1: PID/ |
Kai Backman | 1c71ab1 | 2009-09-18 19:09:12 -0700 | [diff] [blame] | 89 | /^\$RUNFILE: line 1: PID Trace\/breakpoint trap/d |
Russ Cox | 6c19601 | 2010-04-05 12:51:09 -0700 | [diff] [blame] | 90 | /Segmentation fault/d |
Kai Backman | 1c71ab1 | 2009-09-18 19:09:12 -0700 | [diff] [blame] | 91 | /^qemu: uncaught target signal 11 (Segmentation fault) - exiting/d' > run.out |
Rob Pike | 126150d | 2008-06-06 13:28:03 -0700 | [diff] [blame] | 92 | |
Rob Pike | f6d67c9 | 2009-10-13 22:48:03 -0700 | [diff] [blame] | 93 | rm -f $RUNFILE $TMP1FILE $TMP2FILE *.$A $A.out |
Russ Cox | 3314f8c | 2009-07-29 15:30:54 -0700 | [diff] [blame] | 94 | diffmsg="" |
Rob Pike | 27fb2ab | 2008-06-06 12:57:00 -0700 | [diff] [blame] | 95 | if ! diff run.out golden.out |
| 96 | then |
Russ Cox | 3314f8c | 2009-07-29 15:30:54 -0700 | [diff] [blame] | 97 | diffmsg="; test output differs" |
Rob Pike | 27fb2ab | 2008-06-06 12:57:00 -0700 | [diff] [blame] | 98 | failed=1 |
| 99 | fi |
Rob Pike | 17ee781 | 2008-06-06 13:38:16 -0700 | [diff] [blame] | 100 | |
Russ Cox | 1ff5897 | 2009-07-29 15:11:19 -0700 | [diff] [blame] | 101 | notinbugs=$(sed '/^== bugs/q' run.out | grep -c '^BUG') |
| 102 | inbugs=$(sed '1,/^== bugs/d' run.out | grep -c '^BUG') |
| 103 | |
Russ Cox | 3314f8c | 2009-07-29 15:30:54 -0700 | [diff] [blame] | 104 | echo 2>&1 $inbugs known bugs';' $notinbugs unexpected bugs$diffmsg |
Rob Pike | 17ee781 | 2008-06-06 13:38:16 -0700 | [diff] [blame] | 105 | |
Russ Cox | 66cdc69 | 2010-02-10 15:01:02 -0800 | [diff] [blame] | 106 | if [ "$failed" != "0" ]; then |
| 107 | echo FAILED |
| 108 | fi |
| 109 | |
Rob Pike | 27fb2ab | 2008-06-06 12:57:00 -0700 | [diff] [blame] | 110 | exit $failed |