-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.sh
executable file
·197 lines (158 loc) · 6.7 KB
/
test.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
#!/bin/zsh
make re
printf "******Start of tests******\n\n"
printf "First test == no infile\n******************************\n"
printf "Should print errors:\n_________________________\n"
< LOL grep potato | wc -l > outfile
./pipex LOL "grep potato" "wc -l" outfile2
printf "_________________________\n"
printf "If nothing printed == good\n-> "
diff outfile outfile2
printf "\n******************************\n\n"
sleep 3
printf "Second test == no outfile\n******************************\n"
printf "\nShould not print:\n_________________________\n"
< infile grep potato | wc -l > LOL
./pipex infile "grep potato" "wc -l" LOL2
printf "_________________________\n"
printf "If nothing printed == good\n-> "
diff LOL LOL2
printf "\n******************************\n\n"
sleep 3
rm -f LOL LOL2
printf "Third test == wrong first command\n******************************\n"
printf "Should print errors:\n_________________________\n"
< infile LOL -lol | wc -l > outfile
./pipex infile "LOL -lol" "wc -l" outfile2
printf "_________________________\n"
printf "If nothing printed == good\n-> "
diff outfile outfile2
printf "\n******************************\n\n"
sleep 3
printf "Fourth test == 2 wrong commands\n******************************\n"
printf "Should print errors:\n_________________________\n"
< infile LOL -lol | cookie -dough > outfile
./pipex infile "LOL -lol" "cookie -dough" outfile2
printf "_________________________\n"
printf "If nothing printed == good\n-> "
diff outfile outfile2
printf "\n******************************\n\n"
sleep 3
printf "Fifth test == 2 wrong commands and bad infile\n******************************\n"
printf "Should print errors:\n_________________________\n"
< wtf LOL -lol | cookie -dough > outfile
./pipex wtf "LOL -lol" "cookie -dough" outfile2
printf "_________________________\n"
printf "If nothing printed == good\n-> "
diff outfile outfile2
printf "\n******************************\n\n"
sleep 3
printf "Sixth test == Good commands and files\n******************************\n"
printf "Should not output anything:\n_________________________\n"
< infile grep pancakes | wc -w > outfile
./pipex infile "grep pancakes" "wc -w" outfile2
printf "_________________________\n"
printf "If nothing printed == good\n-> "
diff outfile outfile2
printf "\n******************************\n\n"
sleep 3
printf "Seventh test == Three good commands and files\n******************************\n"
printf "Should not output anything:\n_________________________\n"
< infile grep pancakes | wc -w | wc -l > outfile
./pipex infile "grep pancakes" "wc -w" "wc -l" outfile2
printf "_________________________\n"
printf "If nothing printed == good\n-> "
diff outfile outfile2
printf "\n******************************\n\n"
sleep 3
printf "Eight test == 1st wrong command and good files\n******************************\n"
printf "Should output an error:\n_________________________\n"
< infile lol pancakes | wc -w | wc -l > outfile
./pipex infile "lol pancakes" "wc -w" "wc -l" outfile2
printf "_________________________\n"
printf "If nothing printed == good\n-> "
diff outfile outfile2
printf "\n******************************\n\n"
sleep 3
printf "Ninth test == 2nd wrong command and good files\n******************************\n"
printf "Should output an error:\n_________________________\n"
< infile grep pancakes | lol -w | wc -l > outfile
./pipex infile "grep pancakes" "lol -w" "wc -l" outfile2
printf "_________________________\n"
printf "If nothing printed == good\n-> "
diff outfile outfile2
printf "\n******************************\n\n"
sleep 3
printf "Tenth test == Third wrong command and good files\n******************************\n"
printf "Should output an error:\n_________________________\n"
< infile grep pancakes | wc -w | lol -l > outfile
./pipex infile "grep pancakes" "wc -w" "lol -l" outfile2
printf "_________________________\n"
printf "If nothing printed == good\n-> "
diff outfile outfile2
printf "\n******************************\n\n"
sleep 3
printf "Eleventh test == 3 wrong commands and good files\n******************************\n"
printf "Should output 3 errors:\n_________________________\n"
< infile lol pancakes | lol -w | lol -l > outfile
./pipex infile "lol pancakes" "lol -w" "lol -l" outfile2
printf "_________________________\n"
printf "If nothing printed == good\n-> "
diff outfile outfile2
printf "\n******************************\n\n"
sleep 3
printf "Twelfth test == good commands and bad infile\n******************************\n"
printf "Should output an error:\n_________________________\n"
< lol grep pancakes | wc -w | wc -l > outfile
./pipex lol "grep pancakes" "wc -w" "wc -l" outfile2
printf "_________________________\n"
printf "If nothing printed == good\n-> "
diff outfile outfile2
printf "\n******************************\n\n"
sleep 3
printf "Thirteenth test == 1st wrong command and bad infile\n******************************\n"
printf "Should not output:\n_________________________\n"
< lol lol pancakes | wc -w | wc -l > outfile
./pipex lol "lol pancakes" "wc -w" "wc -l" outfile2
printf "_________________________\n"
printf "If nothing printed == good\n-> "
diff outfile outfile2
printf "\n******************************\n\n"
sleep 3
printf "Fourteenth test == 2nd wrong command and bad infile\n******************************\n"
printf "Should output an error:\n_________________________\n"
< lol grep pancakes | lol -w | wc -l > outfile
./pipex lol "grep pancakes" "lol -w" "wc -l" outfile2
printf "_________________________\n"
printf "If nothing printed == good\n-> "
diff outfile outfile2
printf "\n******************************\n\n"
sleep 3
printf "Fifteenth test == 3rd wrong command and bad infile\n******************************\n"
printf "Should output an error:\n_________________________\n"
< lol grep pancakes | wc -w | lol -l > outfile
./pipex lol "grep pancakes" "wc -w" "lol -l" outfile2
printf "_________________________\n"
printf "If nothing printed == good\n-> "
diff outfile outfile2
printf "\n******************************\n\n"
sleep 3
printf "Sixteenth test == 3 wrong commands and bad files\n******************************\n"
printf "Should output errors:\n_________________________\n"
< lol lol pancakes | lol -w | lol -l > wtf
./pipex lol "lol pancakes" "lol -w" "lol -l" wtf2
printf "_________________________\n"
printf "If nothing printed == good\n-> "
diff wtf wtf2
printf "\n******************************\n\n"
rm -f wtf wtf2
sleep 3
printf "Seventeenth test == good commands and bad outfile\n******************************\n"
printf "Should print nothing:\n_________________________\n"
< infile grep pancakes | wc -w | wc -l > wtf
./pipex infile "grep pancakes" "wc -w" "wc -l" wtf2
printf "_________________________\n"
printf "If nothing printed == good\n-> "
diff wtf wtf2
printf "\n******************************\n\n"
rm -f wtf wtf2