-
Notifications
You must be signed in to change notification settings - Fork 0
/
test-p-ok.sh
executable file
·91 lines (74 loc) · 1.04 KB
/
test-p-ok.sh
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
86
87
88
89
90
91
#! /bin/sh
# UCLA CS 111 Lab 1 - Test that valid syntax is processed correctly.
tmp=$0-$$.tmp
mkdir "$tmp" || exit
(
cd "$tmp" || exit
cat >test.sh <<'EOF'
true
g++ -c foo.c
: : :
cat < /etc/passwd | tr a-z A-Z | sort -u || echo sort failed!
a b<c > d
cat < /etc/passwd | tr a-z A-Z | sort -u > out || echo sort failed!
a&&b||
c &&
d | e && f|
g<h
# This is a weird example: nobody would ever want to run this.
a<b>c|d<e>f|g<h>i
EOF
cat >test.exp <<'EOF'
# 1
true
# 2
g++ -c foo.c
# 3
: : :
# 4
cat</etc/passwd \
|
tr a-z A-Z \
|
sort -u \
||
echo sort failed!
# 5
a b<c>d
# 6
cat</etc/passwd \
|
tr a-z A-Z \
|
sort -u>out \
||
echo sort failed!
# 7
a \
&&
b \
||
c \
&&
d \
|
e \
&&
f \
|
g<h
# 8
a<b>c \
|
d<e>f \
|
g<h>i
EOF
../timetrash -p test.sh >test.out 2>test.err || exit
diff -u test.exp test.out || exit
test ! -s test.err || {
cat test.err
exit 1
}
) || exit
rm -fr "$tmp"