From 4bbac23dd9bbb45cc74d9e25a74ef0b9bce20ac2 Mon Sep 17 00:00:00 2001 From: Lucky8boy Date: Tue, 24 Oct 2023 08:41:49 +0300 Subject: [PATCH] Update test_malloc_free.sh - now it checks if the executable give segmentation fault or not and gives 0 points for it --- .../mini-libc/tests/test_malloc_free.sh | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/content/assignments/mini-libc/tests/test_malloc_free.sh b/content/assignments/mini-libc/tests/test_malloc_free.sh index 4a2e6a91f2..5f0ba8088b 100755 --- a/content/assignments/mini-libc/tests/test_malloc_free.sh +++ b/content/assignments/mini-libc/tests/test_malloc_free.sh @@ -48,7 +48,21 @@ test_malloc_free() exit 1 fi - "$exec_file" & + touch "valgrind-out.txt" + + valgrind --leak-check=full \ + --verbose \ + --log-file=valgrind-out.txt \ + ./"$exec_file" & + + if `grep -qE '(Invalid| bound array)' valgrind-out.txt`; then # test segmentation fault + echo "Sementation fault" + rm "valgrind-out.txt" + exit 1 + fi + + rm "valgrind-out.txt" + sleep 1 PID=$! mem1=$(ps -o vsz --noheader --pid "$PID")