This repository was archived by the owner on Jun 19, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmouli.sh
executable file
·622 lines (527 loc) · 16.4 KB
/
mouli.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
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
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
#! /bin/bash
test_passed=0
test_fail=0
echo -e "Integration tests by mariusvnh, zuldruck, simontraww"
echo -e "\n\nTESTS\n"
#simple exit
echo "exit" | ./mysh &> log.txt
if [ $? != 0 ]; then
echo -e "simple exit: Return value was $?\nExpected 0\n"
else {
echo -e "simple exit: PASSED\n"
((test_passed++))
}
fi
DIFF=$(diff <(cat log.txt) <(echo "exit"))
if [ "$DIFF" != "" ]; then
echo -e "simple exit: Got: $DIFF\nExpected: \"\"\n"
else
echo -e "simple exit [2]: PASSED\n"
((test_passed++))
fi
#exit 43
echo "exit 43" | ./mysh &> log.txt
if [ $? != 43 ]; then
echo -e "exit 43: Return value was $?\nExpected 43\n"
else {
echo -e "exit 43: PASSED\n"
((test_passed++))
}
fi
DIFF=$(diff <(cat log.txt) <(echo "exit"))
if [ "$DIFF" != "" ]; then
echo -e "exit 43: Got: $DIFF\nExpected: \"\"\n"
else {
echo -e "exit 43 [2]: PASSED\n"
((test_passed++))
}
fi
#exit test
echo "exit test" | ./mysh &> log.txt
echo "exit test" | tcsh &> tcssh.txt
DIFF=$(diff <(cat log.txt) <(cat tcssh.txt))
if [ "$DIFF" != "" ]; then
echo -e "exit test: Got: $DIFF\nExpected: \"\"\n"
else {
echo -e "exit test: PASSED\n"
((test_passed++))
}
fi
#exit 42test
echo "exit 42test" | ./mysh &> log.txt
echo "exit 42test" | tcsh >& tcssh.txt
DIFF=$(diff <(cat log.txt) <(cat tcssh.txt))
if [ "$DIFF" != "" ]; then
echo -e "exit 42test: Got: $DIFF\nExpected: \"\"\n"
else {
echo -e "exit 42test: PASSED\n"
((test_passed++))
}
fi
#exit badly [SIMONTRAWW]
echo "exit -77j" | ./mysh &> log.txt
echo "exit -77j" | tcsh &> tcssh.txt
DIFF=$(diff <(cat log.txt) <(cat tcssh.txt))
if [ "$DIFF" != "" ]; then
echo -e "exit -77j: Got: $DIFF\nExpected: \"\"\n"
else {
echo -e "exit -77j: PASSED\n"
((test_passed++))
}
fi
#pwd
echo -e "cd ..\npwd" | ./mysh &> log.txt
echo -e "cd ..\npwd" | tcsh &> tcsh.txt
DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
if [ "$DIFF" != "" ]; then
echo -e "cd .. --> pwd: Got: $DIFF\nExpected: \"\"\n"
else {
echo -e "cd .. --> pwd: PASSED\n"
((test_passed++))
}
fi
#env path presence
echo -e "env" | ./mysh &> log.txt
DIFF=$(cat log.txt | grep "^PATH=" | wc -l)
if [ "$DIFF" != "1" ]; then
echo -e "env PATH check: Got: $DIFF\nExpected: \"1\"\n"
else {
echo -e "env PATH check: PASSED\n"
((test_passed++))
}
fi
#setenv
echo -e "setenv SALUT PUTE\nenv" | ./mysh &> log.txt
DIFF=$(cat log.txt | grep "^SALUT=PUTE" | wc -l)
if [ "$DIFF" != "1" ]; then
echo -e "setenv test: Got: $DIFF\nExpected: \"1\"\n"
else {
echo -e "setenv test: PASSED\n"
((test_passed++))
}
fi
#setenv
echo -e "unsetenv PATH\nenv" | ./mysh &> log.txt
DIFF=$(cat log.txt | grep "^PATH" | wc -l)
if [ "$DIFF" != "0" ]; then
echo -e "unsetenv test: Got: $DIFF\nExpected: \"1\"\n"
else {
echo -e "unsetenv test: PASSED\n"
((test_passed++))
}
fi
#setenv
mkdir lstest
mkdir lstest/plouplou
touch lstest/salut.txt
touch lstest/lala.txt
touch lstest/plouplou/yop.txt
cd lstest
echo -e "cd plouplou\nls" | ./../mysh &> log.txt
echo -e "cd plouplou\nls" | tcsh &> tcssh.txt
DIFF=$(diff <(cat log.txt) <(cat tcssh.txt))
if [ "$DIFF" != "" ]; then
echo -e "ls: Got: $DIFF\n"
else {
echo -e "ls: PASSED\n"
((test_passed++))
}
fi
#TEST LONG SPACES [SIMONTRAWW]
echo "ls " | ./../mysh &>log.txt
echo "ls " | tcsh &>tcssh.txt
DIFF=$(diff <(cat log.txt) <(cat tcssh.txt))
if [ "$DIFF" != "" ]; then
echo -e "TEST LONG WHITESPACES : Got: $DIFF\n"
else {
echo -e "TEST LONG WHITESPACES : PASSED\n"
((test_passed++))
}
fi
#TEST WITH TAB [SIMONTRAWW]
echo "ls " | ./../mysh &>log.txt
echo "ls " | tcsh &>tcssh.txt
DIFF=$(diff <(cat log.txt) <(cat tcssh.txt))
if [ "$DIFF" != "" ]; then
echo -e "TEST WITH TAB : Got: $DIFF\n"
else {
echo -e "TEST WITH TAB : PASSED\n"
((test_passed++))
}
fi
cd ..
rm -rf lstest
#TEST WITH spaces [SIMONTRAWW]
echo "cd ../" | ./mysh &>log.txt
echo "cd ../" | tcsh &>tcssh.txt
DIFF=$(diff <(cat log.txt) <(cat tcssh.txt))
if [ "$DIFF" != "" ]; then
echo -e "TEST CD ../ WITH SPACES : Got: $DIFF\n"
else {
echo -e "TEST CD ../ WITH SPACES : PASSED\n"
((test_passed++))
}
fi
#TEST WITH TAB [SIMONTRAWW]
echo -e "\t\tcd\t" | ./mysh &>log.txt
echo -e "\t\tcd\t" | tcsh &>tcssh.txt
DIFF=$(diff <(cat log.txt) <(cat tcssh.txt))
if [ "$DIFF" != "" ]; then
echo -e "TEST CD WITH tab : Got: $DIFF\n"
else {
echo -e "TEST CD WITH tab : PASSED\n"
((test_passed++))
}
fi
#execute non executable file
echo -e "./Makefile" | ./mysh &> log.txt
echo -e "./Makefile" | tcsh &> tcssh.txt
DIFF=$(diff <(cat log.txt) <(cat tcssh.txt))
if [ "$DIFF" != "" ]; then
echo -e "ls: Got: $DIFF\n"
else {
echo -e "ls: PASSED\n"
((test_passed++))
}
fi
#TEST CHMOD -x [SIMONTRAWW]
touch foobar
echo "echo \"fail\"" | > foobar
echo -e "chmod -x ./foobar\n./foobar" |./mysh &> log.txt
echo -e "chmod -x ./foobar\n./foobar" | tcsh &> tcssh.txt
rm -rf foobar
DIFF=$(diff <(cat log.txt) <(cat tcssh.txt))
if [ "$DIFF" != "" ]; then
echo -e "TEST CHMOD: Got: $DIFF\n"
else {
echo -e "TEST CHMOD: PASSED\n"
((test_passed++))
}
fi
#TEST ERROR + one or two letter after word [SIMONTRAWW]
echo -e "exitt" | ./mysh &> log.txt
echo -e "exitt" | tcsh &> tcssh.txt
DIFF=$(diff <(cat log.txt) <(cat tcssh.txt))
if [ "$DIFF" != "" ]; then
echo -e "TEST EXITT (one two letter at the end of word): Got: $DIFF\n"
else {
echo -e "TEST EXITT (one two letter at the end of word): PASSED\n"
((test_passed++))
}
fi
#TEST CHMOD +x on picture [SIMONTRAWW]
wget http://convertir-une-image.com/frontframe/images/cute_ball_info.png &> /dev/null
mv cute_ball_info.png test.png &> /dev/null
echo -e "chmod +x test.png\n./test.png" | ./mysh &> log.txt
echo -e "chmod +x test.png\n./test.png" | tcsh &> tcssh.txt
rm -rf test.png
DIFF=$(diff <(cat log.txt) <(cat tcssh.txt))
if [ "$DIFF" != "" ]; then
echo -e "TEST EXEC IMG: Got: $DIFF\n"
else {
echo -e "TEST EXEC IMG: PASSED\n"
((test_passed++))
}
fi
#TEST programm segfault [SIMONTRAWW]
mkdir tests
cd tests
wget http://epi2022.fr/neo/PSU/PSU_minishell1_2017/segfault.c &> /dev/null
echo -e "gcc segfault.c\n./a.out" | ./../mysh &> log.txt
echo -e "gcc segfault.c\n./a.out" | tcsh &> tcssh.txt
rm -rf segfault.c &> /dev/null
rm -rf a.out &> /dev/null
DIFF=$(diff <(cat log.txt) <(cat tcssh.txt))
if [ "$DIFF" != "" ]; then
echo -e "TEST SEGFAULT: Got: $DIFF\n"
else {
echo -e "TEST SEGFAULT: PASSED\n"
((test_passed++))
}
fi
#TEST programm floating point exeception [SIMONTRAWW]
wget http://epi2022.fr/neo/PSU/PSU_minishell1_2017/floating.c &> /dev/null
echo "gcc floating.c -lm" | ./../mysh &> /dev/null
echo "gcc floating.c -lm" | tcsh &> /dev/null
echo -e "gcc floating.c -lm\n./a.out" | ./../mysh &> log.txt
echo -e "gcc floating.c -lm\n./a.out" | tcsh &> tcssh.txt
rm -rf floating.c
rm -rf a.out
DIFF=$(diff <(cat log.txt) <(cat tcssh.txt))
if [ "$DIFF" != "" ]; then
echo -e "TEST FLOATING point exception: Got: $DIFF\n"
else {
echo -e "TEST FLOATING point exception: PASSED\n"
((test_passed++))
}
fi
cd ..
rm -rf tests
#TEST ERROR + one or two letter after word [SIMONTRAWW]
echo -e "unsetenvv" | ./mysh &> log.txt
echo -e "unsetenvv" | tcsh &> tcssh.txt
DIFF=$(diff <(cat log.txt) <(cat tcssh.txt))
if [ "$DIFF" != "" ]; then
echo -e "TEST unsetenvv (one two letter at the end of word): Got: $DIFF\n"
else {
echo -e "TEST unsetenvv (one two letter at the end of word): PASSED\n"
((test_passed++))
}
fi
#TEST ERROR + one or two letter after word [SIMONTRAWW]
echo -e "setenvi" | ./mysh &> log.txt
echo -e "setenvi" | tcsh &> tcssh.txt
DIFF=$(diff <(cat log.txt) <(cat tcssh.txt))
if [ "$DIFF" != "" ]; then
echo -e "TEST setenvi (one two letter at the end of word): Got: $DIFF\n"
else {
echo -e "TEST setenvi (one two letter at the end of word): PASSED\n"
((test_passed++))
}
fi
#TEST cd [SIMONTRAWW]
echo -e "cd\npwd" | ./mysh &>log.txt
echo -e "cd\npwd" | tcsh &>tcssh.txt
DIFF=$(diff <(cat log.txt) <(cat tcssh.txt))
if [ "$DIFF" != "" ]; then
echo -e "TEST cd : Got: $DIFF\n"
else {
echo -e "TEST cd : PASSED\n"
((test_passed++))
}
fi
#TEST cd ../ [SIMONTRAWW]
echo -e "cd ../\npwd" | ./mysh &>log.txt
echo -e "cd ../\npwd" | tcsh &>tcssh.txt
DIFF=$(diff <(cat log.txt) <(cat tcssh.txt))
if [ "$DIFF" != "" ]; then
echo -e "TEST cd ../ : Got: $DIFF\n"
else {
echo -e "TEST cd ../ : PASSED\n"
((test_passed++))
}
fi
#TEST cd /dev [SIMONTRAWW]
echo -e "cd /dev\npwd" | ./mysh &>log.txt
echo -e "cd /dev\npwd" | tcsh &>tcssh.txt
DIFF=$(diff <(cat log.txt) <(cat tcssh.txt))
if [ "$DIFF" != "" ]; then
echo -e "TEST cd /dev : Got: $DIFF\n"
else {
echo -e "TEST cd /dev : PASSED\n"
((test_passed++))
}
fi
#TEST cd NULL [SIMONTRAWW]
echo -e "cd NULL" | ./mysh &>log.txt
echo -e "cd NULL" | tcsh &>tcssh.txt
DIFF=$(diff <(cat log.txt) <(cat tcssh.txt))
if [ "$DIFF" != "" ]; then
echo -e "TEST cd NULL directory : Got: $DIFF\n"
else {
echo -e "TEST cd NULL directory : PASSED\n"
((test_passed++))
}
fi
#TEST cd random dirr [SIMONTRAWW]
echo -e "cd ../../../../../../../../\npwd" | ./mysh &>log.txt
echo -e "cd ../../../../../../../../\npwd" | tcsh &>tcssh.txt
DIFF=$(diff <(cat log.txt) <(cat tcssh.txt))
if [ "$DIFF" != "" ]; then
echo -e "TEST random dirr : Got: $DIFF\n"
else {
echo -e "TEST random dirr : PASSED\n"
((test_passed++))
}
fi
#TEST cd moins without any OLDPWD [SIMONTRAWW]
echo -e "cd ../\ncd -\npwd" | ./mysh &>log.txt
echo -e "cd ../\ncd -\npwd" | tcsh &>tcssh.txt
DIFF=$(diff <(cat log.txt) <(cat tcssh.txt))
if [ "$DIFF" != "" ]; then
echo -e "TEST cd moins without OLDPWD : Got: $DIFF\n"
else {
echo -e "TEST cd moins without OLDPWD: PASSED\n"
((test_passed++))
}
fi
#TEST NAME TOO LONG [SIMONTRAWW]
echo "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" | ./mysh &>log.txt ./mysh &> /dev/null
echo "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" | tcsh &>tcssh.txt tcsh &> /dev/null
DIFF=$(diff <(cat log.txt) <(cat tcssh.txt))
if [ "$DIFF" != "" ]; then
echo -e "TEST CD NAME TOO LONG: Got: $DIFF\n"
else {
echo -e "TEST CD NAME TOO LONG : PASSED\n"
((test_passed++))
}
fi
#TEST /bin/ls [SIMONTRAWW]
echo -e "/bin/ls" | ./mysh &>log.txt
echo -e "/bin/ls" | tcsh &>tcssh.txt
DIFF=$(diff <(cat log.txt) <(cat tcssh.txt))
if [ "$DIFF" != "" ]; then
echo -e "TEST /bin/ls: Got: $DIFF\n"
else {
echo -e "TEST /bin/ls: PASSED\n"
((test_passed++))
}
fi
#TEST /bin/ls [SIMONTRAWW]
echo -e "/bin/ls" | ./mysh &>log.txt
echo -e "/bin/ls" | tcsh &>tcssh.txt
DIFF=$(diff <(cat log.txt) <(cat tcssh.txt))
if [ "$DIFF" != "" ]; then
echo -e "TEST /bin/ls: Got: $DIFF\n"
else {
echo -e "TEST /bin/ls: PASSED\n"
((test_passed++))
}
fi
#TEST cd bin/pwd [SIMONTRAWW]
echo -e "cd /bin/pwd" | ./mysh &>log.txt
echo -e "cd /bin/pwd" | tcsh &>tcssh.txt
DIFF=$(diff <(cat log.txt) <(cat tcssh.txt))
if [ "$DIFF" != "" ]; then
echo -e "TEST cd /bin/pwd directory : Got: $DIFF\n"
else {
echo -e "TEST cd /bin/pwd directory : PASSED\n"
((test_passed++))
}
fi
#TEST cd bin/pwd [SIMONTRAWW]
echo -e "env -i ./mysh" | ./mysh &>log.txt
echo -e "env -i ./mysh" | tcsh &>tcssh.txt
DIFF=$(diff <(cat log.txt) <(cat tcssh.txt))
if [ "$DIFF" != "" ]; then
echo -e "TEST env -i directory : Got: $DIFF\n"
else {
echo -e "TEST env -i directory : PASSED\n"
((test_passed++))
}
fi
#setenv A 2
echo -e "setenv A 2\nenv" | ./mysh &> log.txt
DIFF=$(cat log.txt | grep "^A=2" | wc -l)
if [ "$DIFF" != "1" ]; then
echo -e "setenv A 2: Got: $DIFF\nExpected: \"1\"\n"
else {
echo -e "setenv A 2: PASSED\n"
((test_passed++))
}
fi
#TEST setenv A 2[SIMONTRAWW]
echo "setenv 2 A" | ./mysh &>log.txt
echo "setenv 2 A" | tcsh &>tcssh.txt
DIFF=$(diff <(cat log.txt) <(cat tcssh.txt))
if [ "$DIFF" != "" ]; then
echo -e "SETENV 2 A error msg : Got: $DIFF\n"
else {
echo -e "SETENV 2 A error msg : PASSED\n"
((test_passed++))
}
fi
#TEST setenv A/ 2[SIMONTRAWW]
echo "setenv A/ 2" | ./mysh &>log.txt
echo "setenv A/ 2" | tcsh &>tcssh.txt
DIFF=$(diff <(cat log.txt) <(cat tcssh.txt))
if [ "$DIFF" != "" ]; then
echo -e "SETENV A/ 2 error msg : Got: $DIFF\n"
else {
echo -e "SETENV A/ 2 error msg : PASSED\n"
((test_passed++))
}
fi
#TEST setenv A 2[SIMONTRAWW]
echo "setenv SALU/T 2" | ./mysh &>log.txt
echo "setenv SALU/T 2" | tcsh &>tcssh.txt
DIFF=$(diff <(cat log.txt) <(cat tcssh.txt))
if [ "$DIFF" != "" ]; then
echo -e "SETENV SALU/T 2 error msg : Got: $DIFF\n"
else {
echo -e "SETENV SALU/T 2 error msg : PASSED\n"
((test_passed++))
}
fi
#CD cd -
echo -e "cd ..\ncd -\npwd" | ./mysh &> log.txt
echo -e "cd ..\ncd -\npwd" | tcsh &> tcsh.txt
DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
if [ "$DIFF" != "" ]; then
echo -e "cd .. puis cd - puis pwd --> pwd: Got: $DIFF\nExpected: \"\"\n"
else {
echo -e "cd .. puis cd - puis pwd --> pwd: PASSED\n"
((test_passed++))
}
fi
#CD cd -
echo -e "cd ..\ncd -\ncd ../\ncd -\ncd ../\ncd -\npwd" | ./mysh &> log.txt
echo -e "cd ..\ncd -\ncd ../\ncd -\ncd ../\ncd -\npwd" | tcsh &> tcsh.txt
DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
if [ "$DIFF" != "" ]; then
echo -e "cd .. puis cd - puis cd ../ puis cd - (3fois) puis pwd --> pwd: Got: $DIFF\nExpected: \"\"\n"
else {
echo -e "cd .. puis cd - puis cd ../ puis cd - (3fois) puis pwd --> pwd: PASSED\n"
((test_passed++))
}
fi
#CD cd -
echo -e "cd ..\ncd -\ncd ../\ncd -\ncd ../\ncd -\npwd" | ./mysh &> log.txt
echo -e "cd ..\ncd -\ncd ../\ncd -\ncd ../\ncd -\npwd" | tcsh &> tcsh.txt
DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
if [ "$DIFF" != "" ]; then
echo -e "cd .. puis cd - puis cd ../ puis cd - (3fois) puis pwd --> pwd: Got: $DIFF\nExpected: \"\"\n"
else {
echo -e "cd .. puis cd - puis cd ../ puis cd - (3fois) puis pwd --> pwd: PASSED\n"
((test_passed++))
}
fi
#CD cd -
echo "setenv 2/A" | ./mysh &> log.txt
echo "setenv 2/A" | tcsh &> tcsh.txt
DIFF=$(diff <(cat log.txt) <(cat tcsh.txt))
if [ "$DIFF" != "" ]; then
echo -e "setenv 2/A --> pwd: Got: $DIFF\nExpected: \"\"\n"
else {
echo -e "setenv 2/A --> pwd: PASSED\n"
((test_passed++))
}
fi
echo "####################################"
echo "SUCCESS TEST --> " $test_passed
test_fail=$(echo "42-$test_passed" |bc )
echo "FAIL TEST --> " $test_fail
echo "####################################"
# IL FAUT TROUVER UNE SOLUTION POUR CES TESTS..
#######################################################################################################################################################
# CE TEST EST PROBLEMATIQUE --> il aura toujours un soucis au niveaux du level du shell dans le system ! SHLVL. mais s'il y a que ça, le test passed !#
#######################################################################################################################################################
#echo -e "setenv" | ./mysh &> log.txt
#echo -e "setenv" | tcsh &> tcssh.txt
#
#DIFF=$(diff <(cat log.txt) <(cat tcssh.txt))
#if [ "$DIFF" != "" ]; then
# echo -e "TEST setenv : Got: $DIFF\n"
#else
# echo -e "TEST setenv : PASSED\n"
#fi
#######################################################################################################################################################
# CE TEST EST PROBLEMATIQUE --> il aura toujours un soucis au niveaux du level du shell dans le system ! SHLVL. mais s'il y a que ça, le test passed !#
#######################################################################################################################################################
#TEST ERROR + one or two letter after word
#
#echo -e "env" | ./mysh &> log.txt
#echo -e "env" | tcsh &> tcssh.txt
#
#DIFF=$(diff <(cat log.txt) <(cat tcssh.txt))
#if [ "$DIFF" != "" ]; then
# echo -e "TEST PRINT env: Got: $DIFF\n"
#else
# echo -e "TEST PRINT env: PASSED\n"
#fi
rm -rf log.txt
rm -rf tcsh.txt
rm -rf tcssh.txt
echo -e "\nEND OF TESTS\n"