-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_pipex.sh
More file actions
executable file
·571 lines (516 loc) · 17.8 KB
/
test_pipex.sh
File metadata and controls
executable file
·571 lines (516 loc) · 17.8 KB
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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
#!/bin/bash
GREEN="\033[32m"
RED="\033[31m"
NC="\033[0m"
BLUE="\033[34m"
YELLOW="\033[33m"
touch infile
chmod +rw infile
echo "To be, or not to be, that is the question:
Whether 'tis nobler in the mind to suffer
The slings and arrows of outrageous fortune,
Or to take arms against a sea of troubles
And by opposing end them. To die—to sleep,
No more; and by a sleep to say we end
The heart-ache and the thousand natural shocks
That flesh is heir to: 'tis a consummation
Devoutly to be wish'd. To die, to sleep;
To sleep, perchance to dream—ay, there's the rub:
For in that sleep of death what dreams may come,
When we have shuffled off this mortal coil,
Must give us pause—there's the respect
That makes calamity of so long life.
For who would bear the whips and scorns of time,
Th'oppressor's wrong, the proud man's contumely,
The pangs of dispriz'd love, the law's delay,
The insolence of office, and the spurns
That patient merit of th'unworthy takes,
When he himself might his quietus make
With a bare bodkin? Who would fardels bear,
To grunt and sweat under a weary life,
But that the dread of something after death,
The undiscovere'd country, from whose bourn
No traveller returns, puzzles the will,
And makes us rather bear those ills we have
Than fly to others that we know not of?
Thus conscience doth make cowards of us all,
And thus the native hue of resolution
Is sicklied o'er with the pale cast of thought,
And enterprises of great pith and moment
With this regard their currents turn awry
And lose the name of action." > infile
mkdir tests/
mkdir tests/check_outs
mkdir tests/exits
#commands
# /bin/cat
# /bin/ls
# /usr/bin/tail
# /usr/bin/head
# /usr/bin/wc
# /usr/bin/yes
# /usr/bin/grep
printf "\n${BLUE}Copy .sh file to folder with pipex bin${NC}\n"
printf "${YELLOW}Commands from subject:\n${NC}"
let "num=1"
printf "${BLUE} 1\n${NC}"
printf "./pipex infile \"ls -l\" \"wc -l\" tests/check_outs/file_pipex\n"
printf "< infile ls -l | wc -l > tests/check_outs/file_shell\n"
./pipex infile "ls -l" "wc -l" tests/check_outs/file_pipex${num}; echo $? > tests/exits/exit_pipex${num}
< infile ls -l | wc -l > tests/check_outs/file_shell${num}; echo $? > tests/exits/exit_shell${num}
DIFF=$(diff tests/check_outs/file_pipex${num} tests/check_outs/file_shell${num})
if ["$DIFF" == ""]
then
printf "${GREEN}OK\n${NC}"
else
printf "${RED}KO\n${NC}"
fi
DIFF=$(diff tests/exits/exit_pipex${num} tests/exits/exit_shell${num})
if ["$DIFF" == ""]
then
printf "${GREEN}exit correct\n${NC}"
else
printf "${RED}exit codes differ\n${NC}"
fi
sleep 0.3
let "num=2"
printf "${BLUE} 2\n${NC}"
printf "./pipex infile \"grep to\" \"wc -l\" tests/check_outs/file_pipex\n"
printf "< infile grep to | wc -l > tests/check_outs/file_shell\n"
./pipex infile "grep to" "wc -l" tests/check_outs/file_pipex${num}; echo $? > tests/exits/exit_pipex${num}
< infile grep to | wc -l > tests/check_outs/file_shell${num}; echo $? > tests/exits/exit_shell${num}
DIFF=$(diff tests/check_outs/file_pipex${num} tests/check_outs/file_shell${num})
if ["$DIFF" == ""]
then
printf "${GREEN}OK\n${NC}"
else
printf "${RED}KO\n${NC}"
fi
DIFF=$(diff tests/exits/exit_pipex${num} tests/exits/exit_shell${num})
if ["$DIFF" == ""]
then
printf "${GREEN}exit correct\n${NC}"
else
printf "${RED}exit codes differ\n${NC}"
fi
sleep 0.3
let "num=3"
printf "${YELLOW}\nRandom commands\n${NC}"
printf "${BLUE} 3\n${NC}"
printf "./pipex infile \"grep hello\" \"cat\" tests/check_outs/file_pipex\n"
printf "< infile grep hello | cat > tests/check_outs/file_shell\n"
./pipex infile "grep hello" "cat" tests/check_outs/file_pipex${num}; echo $? > tests/exits/exit_pipex${num}
< infile grep hello | cat > tests/check_outs/file_shell${num}; echo $? > tests/exits/exit_shell${num}
DIFF=$(diff tests/check_outs/file_pipex${num} tests/check_outs/file_shell${num})
if ["$DIFF" == ""]
then
printf "${GREEN}OK\n${NC}"
else
printf "${RED}KO\n${NC}"
fi
DIFF=$(diff tests/exits/exit_pipex${num} tests/exits/exit_shell${num})
if ["$DIFF" == ""]
then
printf "${GREEN}exit correct\n${NC}"
else
printf "${RED}exit codes differ\n${NC}"
fi
sleep 0.3
let "num=4"
printf "${BLUE} 4\n${NC}"
printf "./pipex infile \"cat\" \"wc\" tests/check_outs/file_pipex\n"
printf "< infile cat | wc > tests/check_outs/file_shell\n"
./pipex infile "cat" "wc" tests/check_outs/file_pipex${num}; echo $? > tests/exits/exit_pipex${num}
< infile cat | wc > tests/check_outs/file_shell${num}; echo $? > tests/exits/exit_shell${num}
DIFF=$(diff tests/check_outs/file_pipex${num} tests/check_outs/file_shell${num})
if ["$DIFF" == ""]
then
printf "${GREEN}OK\n${NC}"
else
printf "${RED}KO\n${NC}"
fi
DIFF=$(diff tests/exits/exit_pipex${num} tests/exits/exit_shell${num})
if ["$DIFF" == ""]
then
printf "${GREEN}exit correct\n${NC}"
else
printf "${RED}exit codes differ\n${NC}"
fi
sleep 0.3
let "num=5"
printf "${BLUE} 5\n${NC}"
printf "./pipex infile \"cat\" \"tail -n5 -r\" tests/check_outs/file_pipex\n"
printf "< infile cat | tail -n5 -r > tests/check_outs/file_shell\n"
./pipex infile "cat" "tail -n5 -r" tests/check_outs/file_pipex${num}; echo $? > tests/exits/exit_pipex${num}
< infile cat | tail -n5 -r > tests/check_outs/file_shell${num}; echo $? > tests/exits/exit_shell${num}
DIFF=$(diff tests/check_outs/file_pipex${num} tests/check_outs/file_shell${num})
if ["$DIFF" == ""]
then
printf "${GREEN}OK\n${NC}"
else
printf "${RED}KO\n${NC}"
fi
DIFF=$(diff tests/exits/exit_pipex${num} tests/exits/exit_shell${num})
if ["$DIFF" == ""]
then
printf "${GREEN}exit correct\n${NC}"
else
printf "${RED}exit codes differ\n${NC}"
fi
sleep 0.3
let "num=6"
printf "\n${YELLOW}Invalid first command${NC}\n"
printf "${BLUE} 6\n${NC}"
printf "./pipex infile \"ca\" \"wc\" tests/check_outs/file_pipex\n"
printf "< infile ca | wc > tests/check_outs/file_shell\n"
./pipex infile "ca" "wc" tests/check_outs/file_pipex${num}; 2>&1 echo $? > tests/exits/exit_pipex${num}
< infile ca | wc > tests/check_outs/file_shell${num}; 2>&1 echo $? > tests/exits/exit_shell${num}
DIFF=$(diff tests/check_outs/file_pipex${num} tests/check_outs/file_shell${num})
if ["$DIFF" == ""]
then
printf "${GREEN}OK\n${NC}"
else
printf "${RED}KO\n${NC}"
fi
DIFF=$(diff tests/exits/exit_pipex${num} tests/exits/exit_shell${num})
if ["$DIFF" == ""]
then
printf "${GREEN}exit correct\n${NC}"
else
printf "${RED}exit codes differ\n${NC}"
fi
sleep 0.3
let "num=7"
printf "\n${YELLOW}Invalid second command\n${NC}"
printf "${BLUE} 7\n${NC}"
printf "./pipex infile \"cat\" \"invalid\" tests/check_outs/file_pipex\n"
printf "< infile cat | invalid > tests/check_outs/file_shell\n"
./pipex infile "cat" "invalid" tests/check_outs/file_pipex${num}; echo $? > tests/exits/exit_pipex${num}
< infile cat | invalid > tests/check_outs/file_shell${num}; echo $? > tests/exits/exit_shell${num}
DIFF=$(diff tests/check_outs/file_pipex${num} tests/check_outs/file_shell${num})
if ["$DIFF" == ""]
then
printf "${GREEN}OK\n${NC}"
else
printf "${RED}KO\n${NC}"
fi
DIFF=$(diff tests/exits/exit_pipex${num} tests/exits/exit_shell${num})
if ["$DIFF" == ""]
then
printf "${GREEN}exit correct\n${NC}"
else
printf "${RED}exit codes differ\n${NC}"
fi
sleep 0.3
let "num=8"
printf "${BLUE} 8\n${NC}"
printf "./pipex infile \"yes helloword\" \"head -10000\" tests/check_outs/file_pipex\n"
printf "< infile yes helloworld! | head -10000 > tests/check_outs/file_shell\n"
./pipex infile "yes helloworld!" "head -10000" tests/check_outs/file_pipex${num}; echo $? > tests/exits/exit_pipex${num}
< infile yes helloworld! | head -10000 > tests/check_outs/file_shell${num}; echo $? > tests/exits/exit_shell${num}
DIFF=$(diff tests/check_outs/file_pipex${num} tests/check_outs/file_shell${num})
if ["$DIFF" == ""]
then
printf "${GREEN}OK\n${NC}"
else
printf "${RED}KO\n${NC}"
fi
DIFF=$(diff tests/exits/exit_pipex${num} tests/exits/exit_shell${num})
if ["$DIFF" == ""]
then
printf "${GREEN}exit correct\n${NC}"
else
printf "${RED}exit codes differ\n${NC}"
fi
sleep 0.3
let "num=9"
printf "${YELLOW}Command with path${NC}\n"
printf "${BLUE} 9\n${NC}"
printf "./pipex infile \"//////////bin/////////cat\" \"/usr/bin/head -n10\" tests/check_outs/file_pipex\n"
printf "< infile //////////bin/////////cat | /usr/bin/head -n10 > tests/check_outs/file_shell\n"
./pipex infile "//////////bin/////////cat" "/usr/bin/head -n10" tests/check_outs/file_pipex${num}; echo $? > tests/exits/exit_pipex${num}
< infile //////////bin/////////cat | /usr/bin/head -n10 > tests/check_outs/file_shell${num}; echo $? > tests/exits/exit_shell${num}
DIFF=$(diff tests/check_outs/file_pipex${num} tests/check_outs/file_shell${num})
if ["$DIFF" == ""]
then
printf "${GREEN}OK\n${NC}"
else
printf "${RED}KO\n${NC}"
fi
DIFF=$(diff tests/exits/exit_pipex${num} tests/exits/exit_shell${num})
if ["$DIFF" == ""]
then
printf "${GREEN}exit correct\n${NC}"
else
printf "${RED}exit codes differ\n${NC}"
fi
sleep 0.3
let "num=10"
printf "\n${YELLOW}Invalid first path${NC}\n"
printf "${BLUE} 10\n${NC}"
printf "./pipex infile \"/usr/bin/tail/ -n10 -r\" \"/usr/bin/wc\" tests/check_outs/file_pipex\n"
printf "< infile /usr/bin/tail/ -n10 -r | /usr/bin/wc > tests/check_outs/file_shell\n"
./pipex infile "/usr/bin/tail/ -n10 -r" "/usr/bin/wc" tests/check_outs/file_pipex${num}; echo $? > tests/exits/exit_pipex${num}
< infile /usr/bin/tail/ -n10 -r | /usr/bin/wc > tests/check_outs/file_shell${num}; echo $? > tests/exits/exit_shell${num}
DIFF=$(diff tests/check_outs/file_pipex${num} tests/check_outs/file_shell${num})
if ["$DIFF" == ""]
then
printf "${GREEN}OK\n${NC}"
else
printf "${RED}KO\n${NC}"
fi
DIFF=$(diff tests/exits/exit_pipex${num} tests/exits/exit_shell${num})
if ["$DIFF" == ""]
then
printf "${GREEN}exit correct\n${NC}"
else
printf "${RED}exit codes differ\n${NC}"
fi
sleep 0.3
printf "\n${YELLOW}Empty file\n${NC}"
touch empty.txt
echo "" > empty
let "num=11"
printf "${BLUE} 11\n${NC}"
printf "./pipex empty \"cat\" \"wc\" tests/check_outs/file_pipex\n"
printf "< empty cat | wc > tests/check_outs/file_shell\n"
./pipex empty "cat" "wc" tests/check_outs/file_pipex${num}; echo $? > tests/exits/exit_pipex${num}
< empty cat | wc > tests/check_outs/file_shell${num}; echo $? > tests/exits/exit_shell${num}
DIFF=$(diff tests/check_outs/file_pipex${num} tests/check_outs/file_shell${num})
if ["$DIFF" == ""]
then
printf "${GREEN}OK\n${NC}"
else
printf "${RED}KO\n${NC}"
fi
DIFF=$(diff tests/exits/exit_pipex${num} tests/exits/exit_shell${num})
if ["$DIFF" == ""]
then
printf "${GREEN}exit correct\n${NC}"
else
printf "${RED}exit codes differ\n${NC}"
fi
rm empty
sleep 0.3
let "num=12"
printf "${BLUE} 12\n${NC}"
printf "./pipex /dev/null \"wc\" \"grep 0\" tests/check_outs/file_pipex\n"
printf "< /dev/null wc | grep 0 > tests/check_outs/file_shell\n"
./pipex /dev/null "wc" "grep 0" tests/check_outs/file_pipex${num}; echo $? > tests/exits/exit_pipex${num}
< /dev/null wc | grep 0 > tests/check_outs/file_shell${num}; echo $? > tests/exits/exit_shell${num}
DIFF=$(diff tests/check_outs/file_pipex${num} tests/check_outs/file_shell${num})
if ["$DIFF" == ""]
then
printf "${GREEN}OK\n${NC}"
else
printf "${RED}KO\n${NC}"
fi
DIFF=$(diff tests/exits/exit_pipex${num} tests/exits/exit_shell${num})
if ["$DIFF" == ""]
then
printf "${GREEN}exit correct\n${NC}"
else
printf "${RED}exit codes differ\n${NC}"
fi
sleep 0.3
let "num=13"
printf "${BLUE} 13\n${NC}"
printf "./pipex infile \"cat\" \"cat -e\" tests/check_outs/file_pipex\n"
printf "< infile cat | cat -e > tests/check_outs/file_shell\n"
./pipex infile "cat" "cat -e" tests/check_outs/file_pipex${num}; echo $? > tests/exits/exit_pipex${num}
< infile cat | cat -e > tests/check_outs/file_shell${num}; echo $? > tests/exits/exit_shell${num}
DIFF=$(diff tests/check_outs/file_pipex${num} tests/check_outs/file_shell${num})
if ["$DIFF" == ""]
then
printf "${GREEN}OK\n${NC}"
else
printf "${RED}KO\n${NC}"
fi
DIFF=$(diff tests/exits/exit_pipex${num} tests/exits/exit_shell${num})
if ["$DIFF" == ""]
then
printf "${GREEN}exit correct\n${NC}"
else
printf "${RED}exit codes differ\n${NC}"
fi
sleep 0.3
let "num=14"
printf "${BLUE} 14\n${NC}"
printf "./pipex infile \"grep The \" \"tr a-z A-Z\" tests/check_outs/file_pipex\n"
printf "< infile grep 'The ' | tr a-z A-Z > tests/check_outs/file_shell\n"
./pipex infile "grep The " "tr a-z A-Z" tests/check_outs/file_pipex${num}; echo $? > tests/exits/exit_pipex${num}
< infile grep 'The ' | tr a-z A-Z > tests/check_outs/file_shell${num}; echo $? > tests/exits/exit_shell${num}
DIFF=$(diff tests/check_outs/file_pipex${num} tests/check_outs/file_shell${num})
if ["$DIFF" == ""]
then
printf "${GREEN}OK\n${NC}"
else
printf "${RED}KO\n${NC}"
fi
DIFF=$(diff tests/exits/exit_pipex${num} tests/exits/exit_shell${num})
if ["$DIFF" == ""]
then
printf "${GREEN}exit correct\n${NC}"
else
printf "${RED}exit codes differ\n${NC}"
fi
sleep 0.3
let "num=15"
printf "${BLUE} 15\n${NC}"
printf "./pipex infile \"less \" \"tr -d abc\" tests/check_outs/file_pipex\n"
printf "< infile less | tr -d abc > tests/check_outs/file_shell\n"
./pipex infile "less" "tr -d abc" tests/check_outs/file_pipex${num}; echo $? > tests/exits/exit_pipex${num}
< infile less | tr -d abc > tests/check_outs/file_shell${num}; echo $? > tests/exits/exit_shell${num}
DIFF=$(diff tests/check_outs/file_pipex${num} tests/check_outs/file_shell${num})
if ["$DIFF" == ""]
then
printf "${GREEN}OK\n${NC}"
else
printf "${RED}KO\n${NC}"
fi
DIFF=$(diff tests/exits/exit_pipex${num} tests/exits/exit_shell${num})
if ["$DIFF" == ""]
then
printf "${GREEN}exit correct\n${NC}"
else
printf "${RED}exit codes differ\n${NC}"
fi
sleep 0.3
printf "${YELLOW}\nFirst file doesn't exist\n${NC}"
let "num=16"
printf "${BLUE} 16\n${NC}"
printf "./pipex nofile \"wc \" \"tr -d abc\" tests/check_outs/file_pipex\n"
printf "< nofile wc | tr -d abc > tests/check_outs/file_shell\n"
./pipex nofile "wc" "tr -d abc" tests/check_outs/file_pipex${num}; echo $? > tests/exits/exit_pipex${num}
< nofile wc | tr -d abc > tests/check_outs/file_shell${num}; echo $? > tests/exits/exit_shell${num}
DIFF=$(diff tests/check_outs/file_pipex${num} tests/check_outs/file_shell${num})
if ["$DIFF" == ""]
then
printf "${GREEN}OK\n${NC}"
else
printf "${RED}KO\n${NC}"
fi
DIFF=$(diff tests/exits/exit_pipex${num} tests/exits/exit_shell${num})
if ["$DIFF" == ""]
then
printf "${GREEN}exit correct\n${NC}"
else
printf "${RED}exit codes differ\n${NC}"
fi
sleep 0.3
printf "${YELLOW}\nSecond file doesn't exist\n${NC}"
let "num=17"
printf "${BLUE} 17\n${NC}"
printf "./pipex infile \"pwd \" \"wc\" /dev/null/\n"
printf "< infile pwd | wc > /dev/null/\n"
./pipex infile "pwd" "wc" /dev/null/; echo $? > tests/exits/exit_pipex${num}
< infile pwd | wc > /dev/null/; echo $? > tests/exits/exit_shell${num}
touch tests/check_outs/file_pipex${num}
touch tests/check_outs/file_shell${num}
DIFF=$(diff tests/check_outs/file_pipex${num} tests/check_outs/file_shell${num})
if ["$DIFF" == ""]
then
printf "${GREEN}OK\n${NC}"
else
printf "${RED}KO\n${NC}"
fi
DIFF=$(diff tests/exits/exit_pipex${num} tests/exits/exit_shell${num})
if ["$DIFF" == ""]
then
printf "${GREEN}exit correct\n${NC}"
else
printf "${RED}exit codes differ\n${NC}"
fi
sleep 0.3
printf "${YELLOW}\nBoth files aren't valid\n${NC}"
let "num=18"
printf "${BLUE} 18\n${NC}"
printf "./pipex nofile \"pwd \" \"wc\" /dev/null/\n"
printf "< nofile pwd | wc > /dev/null/\n"
./pipex nofile "pwd" "wc" dev/null/; echo $? > tests/exits/exit_pipex${num}
< nofile pwd | wc > dev/null/; echo $? > tests/exits/exit_shell${num}
touch tests/check_outs/file_pipex${num}
touch tests/check_outs/file_shell${num}
DIFF=$(diff tests/check_outs/file_pipex${num} tests/check_outs/file_shell${num})
if ["$DIFF" == ""]
then
printf "${GREEN}OK\n${NC}"
else
printf "${RED}KO\n${NC}"
fi
DIFF=$(diff tests/exits/exit_pipex${num} tests/exits/exit_shell${num})
if ["$DIFF" == ""]
then
printf "${GREEN}exit correct\n${NC}"
else
printf "${RED}exit codes differ\n${NC}"
fi
sleep 0.3
let "num=19"
printf "${BLUE} 19\n${NC}"
printf "./pipex infile \"ls -l\" \"head -n3\" outfile\n"
printf "< infile ls -l | head -n3 > outfile\n"
< infile ls -l | head -n3 > tests/check_outs/file_shell${num}; echo $? > tests/exits/exit_shell${num}
./pipex infile "ls -l" "head -n3" tests/check_outs/file_pipex${num}; echo $? > tests/exits/exit_pipex${num}
DIFF=$(diff tests/check_outs/file_pipex${num} tests/check_outs/file_shell${num})
if ["$DIFF" == ""]
then
printf "${GREEN}OK\n${NC}"
else
printf "${RED}KO\n${NC}"
fi
DIFF=$(diff tests/exits/exit_pipex${num} tests/exits/exit_shell${num})
if ["$DIFF" == ""]
then
printf "${GREEN}exit correct\n${NC}"
else
printf "${RED}exit codes differ\n${NC}"
fi
sleep 0.3
let "num=20"
printf "${BLUE} 20\n${NC}"
printf "./pipex infile \"\" \"notex\" outfile\n"
printf "< infile "" | notex > outfile\n"
./pipex infile "" "notex" tests/check_outs/file_pipex${num}; echo $? > tests/exits/exit_pipex${num}
< infile "" | notex > tests/check_outs/file_shell${num}; echo $? > tests/exits/exit_shell${num}
DIFF=$(diff tests/check_outs/file_pipex${num} tests/check_outs/file_shell${num})
if ["$DIFF" == ""]
then
printf "${GREEN}OK\n${NC}"
else
printf "${RED}KO\n${NC}"
fi
DIFF=$(diff tests/exits/exit_pipex${num} tests/exits/exit_shell${num})
if ["$DIFF" == ""]
then
printf "${GREEN}exit correct\n${NC}"
else
printf "${RED}exit codes differ\n${NC}"
fi
sleep 0.3
printf "${YELLOW}\nFile permissions rights\n${NC}"
let "num=21"
printf "${BLUE} 21\n${NC}"
chmod -rw infile
printf "./pipex infile \"cat\" \"grep a\" outfile\n"
printf "< infile cat | grep a > outfile\n"
./pipex infile "cat" "grep a" tests/check_outs/file_pipex${num}; echo $? > tests/exits/exit_pipex${num}
< infile cat | grep a > tests/check_outs/file_shell${num}; echo $? > tests/exits/exit_shell${num}
DIFF=$(diff tests/check_outs/file_pipex${num} tests/check_outs/file_shell${num})
if ["$DIFF" == ""]
then
printf "${GREEN}OK\n${NC}"
else
printf "${RED}KO\n${NC}"
fi
DIFF=$(diff tests/exits/exit_pipex${num} tests/exits/exit_shell${num})
if ["$DIFF" == ""]
then
printf "${GREEN}exit correct\n${NC}"
else
printf "${RED}exit codes differ\n${NC}"
fi
chmod +rw infile
sleep 0.3
# rm -rf tests/
# rm infile