-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.sh
More file actions
executable file
·90 lines (76 loc) · 2.65 KB
/
Copy pathscript.sh
File metadata and controls
executable file
·90 lines (76 loc) · 2.65 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/bin/bash
# Colors for output
GREEN="\033[0;32m"
RED="\033[0;31m"
YELLOW="\033[0;33m"
RESET="\033[0m"
# Default directory
TEST_DIR="./tests"
# Check for command-line argument
if [ $# -ge 1 ]; then
TEST_DIR="$1"
fi
# Display selected test directory
echo -e "${YELLOW}Using test directory: ${TEST_DIR}${RESET}"
# Check if nanotekspice executable exists
if [ ! -f "./nanotekspice" ]; then
echo -e "${RED}Error: nanotekspice executable not found${RESET}"
echo "Make sure to compile the program first with 'make'"
exit 1
fi
# Find all .nts files in specified directory and subdirectories
echo -e "${YELLOW}Searching for .nts circuit files...${RESET}"
NTS_FILES=$(find "${TEST_DIR}" -type f -name "*.nts" 2>/dev/null)
# Check if any .nts files were found
if [ -z "$NTS_FILES" ]; then
echo -e "${YELLOW}No .nts files found in ${TEST_DIR}. Please check the directory path.${RESET}"
exit 0
fi
echo -e "Found $(echo "$NTS_FILES" | wc -l) circuit files to test."
echo -e "${YELLOW}Starting component tests...${RESET}"
echo "=========================================="
PASS_COUNT=0
FAIL_COUNT=0
ERROR_LOG="component_test_errors.log"
> "$ERROR_LOG" # Clear error log
# Test each component file
for file in $NTS_FILES; do
echo -n "Testing $(basename "$file")... "
# Run nanotekspice with the file and exit immediately
# Using timeout to prevent hanging
output=$(timeout 2s ./nanotekspice "$file" <<< "exit" 2>&1)
exit_code=$?
# Check exit status (0 = success, 124 = timeout, other = crash)
if [ $exit_code -eq 0 ]; then
echo -e "${GREEN}PASS${RESET}"
((PASS_COUNT++))
elif [ $exit_code -eq 124 ]; then
echo -e "${RED}TIMEOUT${RESET}"
echo "File: $file - TIMEOUT" >> "$ERROR_LOG"
echo "Output: $output" >> "$ERROR_LOG"
((FAIL_COUNT++))
elif [ $exit_code -eq 84 ]; then
echo -e "${RED}ERROR${RESET}"
echo "File: $file - ERROR" >> "$ERROR_LOG"
echo "Output: $output" >> "$ERROR_LOG"
((FAIL_COUNT++))
else
echo -e "${RED}CRASH (exit code $exit_code)${RESET}"
echo "File: $file - EXIT CODE $exit_code" >> "$ERROR_LOG"
echo "Output: $output" >> "$ERROR_LOG"
((FAIL_COUNT++))
fi
done
# Display summary
echo "=========================================="
echo -e "Test Summary:"
echo -e " ${GREEN}Passed: $PASS_COUNT${RESET}"
echo -e " ${RED}Failed: $FAIL_COUNT${RESET}"
echo -e " Total: $((PASS_COUNT + FAIL_COUNT))"
if [ $FAIL_COUNT -eq 0 ]; then
echo -e "${GREEN}All components processed successfully!${RESET}"
exit 0
else
echo -e "${RED}Some components caused crashes. See $ERROR_LOG for details.${RESET}"
exit 1
fi