-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_fast.sh
More file actions
executable file
·68 lines (58 loc) · 1.68 KB
/
Copy pathtest_fast.sh
File metadata and controls
executable file
·68 lines (58 loc) · 1.68 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/env bash
set -uo pipefail # Removed -e to manually handle background job failures
CC=gcc
CFLAGS="-g -O0 -fsanitize=address,undefined -I../include -lAidan -lwolfssl -fno-omit-frame-pointer"
RUN_DIR="../.test_bins"
GREEN='\033[0;32m'
RED='\033[0;31m'
NC='\033[0m'
cd ./scripts
mkdir -p "$RUN_DIR"
shopt -s globstar
found_any=false
number_found=0
pids=()
for file in ../**/*_test.c; do
found_any=true
number_found=$((number_found + 1))
(
base=$(basename "$file" .c)
out="$RUN_DIR/$base"
# Capture all output (stdout + stderr) into a variable
output=$(
if ! $CC $CFLAGS "$file" -o "$out" 2>&1; then
echo "❌ Compile failed: $file"
exit 1
fi
if ! "$out" 2>&1; then
echo "❌ Test failed: $file"
exit 1
fi
)
status=$?
# Print the grouped output once the subshell is done
echo -e "$output\n"
exit "$status"
) &
pids+=($!) # Track the Process ID of the background job
done
# Wait for all background processes to finish
number_passed=$number_found
exit_code=0
for pid in "${pids[@]}"; do
if ! wait "$pid"; then
number_passed=$((number_passed - 1))
exit_code=1
fi
done
if ! $found_any; then
echo "No Tests Found"
else
echo -e "${GREEN}Found $number_found Tests${NC}"
if (( number_found > number_passed )); then
echo -e "${RED}$number_passed/$number_found Tests Have Passed${NC}"
else
echo -e "${GREEN}$number_passed/$number_found Tests Have Passed${NC}"
fi
fi
exit $exit_code