2009-11-18 10:11:17 -07:00
|
|
|
#!/usr/bin/env bash
|
2008-09-17 13:14:52 -06:00
|
|
|
# Copyright 2009 The Go Authors. All rights reserved.
|
|
|
|
# Use of this source code is governed by a BSD-style
|
|
|
|
# license that can be found in the LICENSE file.
|
|
|
|
|
2010-03-30 11:34:57 -06:00
|
|
|
set -e
|
|
|
|
|
2010-12-13 13:50:57 -07:00
|
|
|
eval $(gomake --no-print-directory -f ../../src/Make.inc go-env)
|
2009-06-05 11:59:55 -06:00
|
|
|
|
|
|
|
if [ -z "$O" ]; then
|
|
|
|
echo 'missing $O - maybe no Make.$GOARCH?' 1>&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
rm -f *.$O
|
2008-09-17 13:14:52 -06:00
|
|
|
|
2011-07-01 08:18:07 -06:00
|
|
|
if [ "$GOOS" = "windows" ];then
|
2011-08-29 13:38:12 -06:00
|
|
|
$GC -o file.$O file_windows.go
|
2011-07-01 08:18:07 -06:00
|
|
|
else
|
|
|
|
$GC file.go
|
|
|
|
fi
|
|
|
|
|
2008-09-17 13:14:52 -06:00
|
|
|
for i in \
|
|
|
|
helloworld.go \
|
|
|
|
helloworld3.go \
|
|
|
|
echo.go \
|
|
|
|
cat.go \
|
|
|
|
cat_rot13.go \
|
|
|
|
sum.go \
|
|
|
|
sort.go \
|
|
|
|
sortmain.go \
|
2009-01-09 16:16:31 -07:00
|
|
|
print.go \
|
|
|
|
print_string.go \
|
2008-09-17 13:14:52 -06:00
|
|
|
sieve.go \
|
|
|
|
sieve1.go \
|
|
|
|
server1.go \
|
2011-01-31 15:41:36 -07:00
|
|
|
strings.go \
|
2011-08-22 06:46:59 -06:00
|
|
|
eff_bytesize.go\
|
2011-08-20 17:46:19 -06:00
|
|
|
eff_qr.go \
|
2011-08-22 06:46:59 -06:00
|
|
|
eff_sequence.go\
|
2008-09-17 13:14:52 -06:00
|
|
|
; do
|
2010-08-30 13:40:56 -06:00
|
|
|
$GC $i
|
2008-09-17 13:14:52 -06:00
|
|
|
done
|
|
|
|
|
|
|
|
function testit {
|
2010-08-30 13:40:56 -06:00
|
|
|
$LD $1.$O
|
2009-06-05 11:59:55 -06:00
|
|
|
x=$(echo $(./$O.out $2 2>&1)) # extra echo canonicalizes
|
2008-09-17 13:14:52 -06:00
|
|
|
if [ "$x" != "$3" ]
|
|
|
|
then
|
|
|
|
echo $1 failed: '"'$x'"' is not '"'$3'"'
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
function testitpipe {
|
2010-08-30 13:40:56 -06:00
|
|
|
$LD $1.$O
|
2009-06-05 11:59:55 -06:00
|
|
|
x=$(echo $(./$O.out | $2 2>&1)) # extra echo canonicalizes
|
2008-09-17 13:14:52 -06:00
|
|
|
if [ "$x" != "$3" ]
|
|
|
|
then
|
|
|
|
echo $1 failed: '"'$x'"' is not '"'$3'"'
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
testit helloworld "" "Hello, world; or Καλημέρα κόσμε; or こんにちは 世界"
|
2009-06-01 23:14:39 -06:00
|
|
|
testit helloworld3 "" "hello, world can't open file; err=no such file or directory"
|
2008-09-17 13:14:52 -06:00
|
|
|
testit echo "hello, world" "hello, world"
|
|
|
|
testit sum "" "6"
|
2011-01-31 15:41:36 -07:00
|
|
|
testit strings "" ""
|
2008-09-17 13:14:52 -06:00
|
|
|
|
|
|
|
alphabet=abcdefghijklmnopqrstuvwxyz
|
|
|
|
rot13=nopqrstuvwxyzabcdefghijklm
|
|
|
|
echo $alphabet | testit cat "" $alphabet
|
|
|
|
echo $alphabet | testit cat_rot13 "--rot13" $rot13
|
|
|
|
echo $rot13 | testit cat_rot13 "--rot13" $alphabet
|
|
|
|
|
2009-09-14 18:20:29 -06:00
|
|
|
testit sortmain "" "Sunday Monday Tuesday Wednesday Thursday Friday Saturday"
|
2008-09-17 13:14:52 -06:00
|
|
|
|
2009-01-09 16:16:31 -07:00
|
|
|
testit print "" "18446744073709551615 -1 18446744073709551615 {77 Sunset Strip} [1 2 3 4] 18446744073709551615 {77 Sunset Strip} [1 2 3 4] 18446744073709551615 {77 Sunset Strip} [1 2 3 4]"
|
|
|
|
testit print_string "" "77 Sunset Strip"
|
|
|
|
|
2008-09-17 13:14:52 -06:00
|
|
|
testitpipe sieve "sed 10q" "2 3 5 7 11 13 17 19 23 29"
|
|
|
|
testitpipe sieve "sed 10q" "2 3 5 7 11 13 17 19 23 29"
|
|
|
|
|
2009-01-30 11:18:58 -07:00
|
|
|
# server hangs; don't run it, just compile it
|
2010-08-30 13:40:56 -06:00
|
|
|
$GC server.go
|
2008-09-17 13:14:52 -06:00
|
|
|
testit server1 "" ""
|
2009-01-06 16:49:27 -07:00
|
|
|
|
2011-08-22 06:46:59 -06:00
|
|
|
testit eff_bytesize "" "1.00YB 9.09TB"
|
|
|
|
testit eff_sequence "" "[-1 2 6 16 44]"
|
|
|
|
|
2009-06-05 11:59:55 -06:00
|
|
|
rm -f $O.out *.$O
|