@@ -53,6 +53,7 @@ if [ -t 1 ]; then echo -e "${CYANBACK} ==:: TEST RESULTS ::== ${ENDCOLOR}"
53
53
else echo " ==:: TEST RESULTS ::==" ; fi
54
54
echo
55
55
56
+ # Compare the output of the program with the expected output
56
57
for INFILE in " ${INFILES[@]} " ; do
57
58
if [ -t 1 ]; then echo -e " ${BOLDBLUE} Test ${INFILE: 8} ${ENDCOLOR} "
58
59
echo -e " ${BOLDBLUE} ---------- ${ENDCOLOR} "
@@ -79,7 +80,7 @@ for INFILE in "${INFILES[@]}"; do
79
80
fi
80
81
done
81
82
82
- # Valgrind test
83
+ # Check for memory issues with valgrind
83
84
if [ -t 1 ]; then echo -e " ${BOLDBLUE} Valgrind test ${ENDCOLOR} "
84
85
echo -e " ${BOLDBLUE} ------------- ${ENDCOLOR} "
85
86
else echo -e " Valgrind test\n------------- " ; fi
91
92
CHECK1=$( echo " $TEST " | grep -c " in use at exit: 0 bytes in 0 blocks" )
92
93
CHECK2=$( echo " $TEST " | grep -c " 0 errors from 0 contexts" )
93
94
if [[ $CHECK1 -ne 0 && $CHECK2 -ne 0 ]]; then
94
- if [ -t 1 ]; then echo -e " ${GREEN} PASSED!\n ${ENDCOLOR} "
95
- else echo -e " PASSED!\n " ; fi
95
+ if [ -t 1 ]; then echo -e " ${GREEN} PASSED!${ENDCOLOR} "
96
+ else echo -e " PASSED!" ; fi
96
97
PASSED=$(( PASSED + 1 ))
97
98
else
98
- if [ -t 1 ]; then echo -e " ${RED} Memory issues detected!\n${ENDCOLOR} "
99
- else echo -e " Memory issues detected!\n" ; fi
99
+ if [ -t 1 ]; then echo -e " ${RED} Test failed."
100
+ if [ $CHECK1 -eq 0 ]; then echo -e " Not all memory freed." ; fi
101
+ if [ $CHECK2 -eq 0 ]; then echo -e " Memory errors detected.${ENDCOLOR} " ; fi
102
+ else echo -e " Test failed."
103
+ if [ $CHECK1 -eq 0 ]; then echo -e " Not all memory freed." ; fi
104
+ if [ $CHECK2 -eq 0 ]; then echo -e " Memory errors detected." ; fi
105
+ fi
100
106
fi
107
+ echo
101
108
fi
102
109
103
110
LEN=$(( LEN + 1 )) # Add 1 for valgrind test
104
111
112
+ # Print final result
105
113
if [ $PASSED -eq $LEN ]; then
106
114
if [ -t 1 ]; then echo -e " ${GREEN} You have passed all tests! \(ᵔᵕᵔ)/${ENDCOLOR} "
107
115
else echo " All tests passed!" ; fi
0 commit comments