Skip to content

Commit 783faa8

Browse files
committed
💲
1 parent ce1c263 commit 783faa8

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

ctest.sh

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ if [ -t 1 ]; then echo -e "${CYANBACK} ==:: TEST RESULTS ::== ${ENDCOLOR}"
5353
else echo "==:: TEST RESULTS ::=="; fi
5454
echo
5555

56+
# Compare the output of the program with the expected output
5657
for INFILE in "${INFILES[@]}"; do
5758
if [ -t 1 ]; then echo -e "${BOLDBLUE}Test ${INFILE:8} ${ENDCOLOR}"
5859
echo -e "${BOLDBLUE}---------- ${ENDCOLOR}"
@@ -79,7 +80,7 @@ for INFILE in "${INFILES[@]}"; do
7980
fi
8081
done
8182

82-
# Valgrind test
83+
# Check for memory issues with valgrind
8384
if [ -t 1 ]; then echo -e "${BOLDBLUE}Valgrind test ${ENDCOLOR}"
8485
echo -e "${BOLDBLUE}------------- ${ENDCOLOR}"
8586
else echo -e "Valgrind test\n------------- "; fi
@@ -91,17 +92,24 @@ else
9192
CHECK1=$(echo "$TEST" | grep -c "in use at exit: 0 bytes in 0 blocks")
9293
CHECK2=$(echo "$TEST" | grep -c "0 errors from 0 contexts")
9394
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
9697
PASSED=$((PASSED + 1))
9798
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
100106
fi
107+
echo
101108
fi
102109

103110
LEN=$((LEN + 1)) # Add 1 for valgrind test
104111

112+
# Print final result
105113
if [ $PASSED -eq $LEN ]; then
106114
if [ -t 1 ]; then echo -e "${GREEN}You have passed all tests! \(ᵔᵕᵔ)/${ENDCOLOR}"
107115
else echo "All tests passed!"; fi

0 commit comments

Comments
 (0)