-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_p3.sh
More file actions
49 lines (41 loc) · 1.26 KB
/
test_p3.sh
File metadata and controls
49 lines (41 loc) · 1.26 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
#!/bin/bash
# file error handling
if [ ! -d "./tests" ]; then
echo "Error: tests directory not found!"
exit 1
fi
if [ ! -e "./a.out" ]; then
echo "Error: a.out not found!"
exit 1
fi
if [ ! -x "./a.out" ]; then
echo "Error: a.out not executable!"
exit 1
fi
let count=0;
# getting the names of all files in the for loop
for f in $(ls ./tests/*.txt); do
./a.out <$f> ./tests/`basename $f ./txt`.output;
done;
# getting all expected output files
for f in $(ls ./tests/*.output); do
diff -Bw $f ./tests/`basename $f .output`.expected > ./tests/`basename $f .output`.diff;
done
for f in $(ls ./tests/*.diff); do
echo "=================================================================";
echo "FILE:" `basename $f .output`;
echo "=================================================================";
if [ -s $f ]; then
echo "Lines that are different between the Expected file and Your Output: ";
cat ./tests/`basename $f .diff`;
echo -e "\n---------------------------------------------------------";
cat $f
else
count=$((count+1));
echo "YAY NO ERRORS :)!";
echo "LEEEEEEEEEEEEEEEEEEEETTTTTTTTTTTTTTSSSSSSSSSS GOOOOOOOOOOOOOOOOOOOOOO";
fi
done
echo "Test Cases Passed: " $count
rm tests/*.output
rm tests/*.diff