blob: 81781c9d235ee19f34ab7818bea2480ffdf5f2c8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
#!/usr/bin/env bash
# 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.
set -e
eval $(gomake --no-print-directory -f ../../src/Make.inc go-env)
if [ -z "$O" ]; then
echo 'missing $O - maybe no Make.$GOARCH?' 1>&2
exit 1
fi
rm -f *.$O
if [ "$GOOS" = "windows" ];then
$GC -o file.8 file_windows.go
else
$GC file.go
fi
for i in \
helloworld.go \
helloworld3.go \
echo.go \
cat.go \
cat_rot13.go \
sum.go \
sort.go \
sortmain.go \
print.go \
print_string.go \
sieve.go \
sieve1.go \
server1.go \
strings.go \
; do
$GC $i
done
function testit {
$LD $1.$O
x=$(echo $(./$O.out $2 2>&1)) # extra echo canonicalizes
if [ "$x" != "$3" ]
then
echo $1 failed: '"'$x'"' is not '"'$3'"'
fi
}
function testitpipe {
$LD $1.$O
x=$(echo $(./$O.out | $2 2>&1)) # extra echo canonicalizes
if [ "$x" != "$3" ]
then
echo $1 failed: '"'$x'"' is not '"'$3'"'
fi
}
testit helloworld "" "Hello, world; or Καλημέρα κόσμε; or こんにちは 世界"
testit helloworld3 "" "hello, world can't open file; err=no such file or directory"
testit echo "hello, world" "hello, world"
testit sum "" "6"
testit strings "" ""
alphabet=abcdefghijklmnopqrstuvwxyz
rot13=nopqrstuvwxyzabcdefghijklm
echo $alphabet | testit cat "" $alphabet
echo $alphabet | testit cat_rot13 "--rot13" $rot13
echo $rot13 | testit cat_rot13 "--rot13" $alphabet
testit sortmain "" "Sunday Monday Tuesday Wednesday Thursday Friday Saturday"
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"
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"
# server hangs; don't run it, just compile it
$GC server.go
testit server1 "" ""
rm -f $O.out *.$O
|