-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun_tests.sh
executable file
·68 lines (54 loc) · 2.27 KB
/
run_tests.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
#!/bin/bash
run_tests() {
local policy=$1
local output_file_memory="test_output_mem_$policy.log"
local output_file_thread="test_output_thread_$policy.log"
echo "========================================"
echo "Running tests with eviction policy: $policy"
echo "========================================"
make clean
if ! make EVICTION_POLICY=$policy; then
echo "Build failed for policy: $policy"
exit 1
fi
echo "Running Valgrind Memory Leak Check..."
if ! valgrind --leak-check=full --track-origins=yes -s --show-leak-kinds=all --show-reachable=yes ./test_app &> $output_file_memory; then
echo "Valgrind Memory Check failed for policy: $policy"
exit 1
fi
if ! grep -q "Tests 0 Failures 0 Ignored" $output_file_memory; then
echo "Test failures detected for policy: $policy"
cat $output_file_memory
exit 1
fi
if ! grep -q "All heap blocks were freed -- no leaks are possible" $output_file_memory; then
echo "Test failures detected for policy: $policy"
cat $output_file_memory
exit 1
fi
echo "Memory Leak Check passed for policy: $policy"
echo "Running Valgrind Helgrind (Thread Error Check)..."
if ! valgrind --tool=helgrind --history-level=full ./test_app &> $output_file_thread; then
echo "Valgrind Helgrind Check failed for policy: $policy"
exit 1
fi
if ! grep -q "ERROR SUMMARY: 0 errors from 0 contexts" $output_file_thread; then
echo "Valgrind Helgrind Check failed for policy: $policy"
cat $output_file_thread
exit 1
fi
echo "========================================"
echo "Tests passed for eviction policy: $policy"
echo "========================================"
}
# run tests
run_tests "TTL"
run_tests "LRU"
echo "================================================"
echo "= ="
echo "= ="
echo "= All tests passed for both eviction policies! ="
echo "= No memory leaks or thread issues detected! ="
echo "= ="
echo "= ="
echo "================================================"