forked from ACMClassCourse-2024/Bookstore-2024
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun
executable file
·76 lines (66 loc) · 1.96 KB
/
run
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
#!/bin/bash
clean_flag=false
size_flag=false
binary_flag=false
binary_string=""
# Process command-line arguments
while [[ $# -gt 0 ]]; do
case "$1" in
--clean|-c)
clean_flag=true
;;
--size|-s)
size_flag=true
;;
-b)
binary_flag=true
shift # Shift to get the string argument
if [[ $# -eq 0 ]]; then # Check if the string argument is provided
echo "Error: -b option requires a string argument." >&2
exit 1
fi
binary_string="$1"
;;
*)
test_cases+=("$1")
;;
esac
shift
done
# Change to the build directory
#cd generated/ || exit 1
# Clean *.bin files if clean flag is set.
if $clean_flag; then
find . -maxdepth 2 -name "*.bin" -delete
find . -maxdepth 2 -name "*.log" -delete
find . -maxdepth 2 -name "*.testdata" -delete
fi
# Loop through test cases
for input_file_base in "${test_cases[@]}"; do
input_file="../testpoints/${input_file_base}.in"
echo "Callback from test case $input_file_base:"
if [ ! -f "$input_file" ]; then
printf "\e[1;31m Error: Input file '%s' not found.\e[0m" "$input_file" >&2
exit 1
fi
printf "\e[0;32m"
sed 's/\/\/.*$//' "$input_file" | ./code
printf "\e[0m"
done
# Show sizes or binary data
if $size_flag; then
echo ""
echo "Metadata file sizes:"
find ./data -maxdepth 1 -name "*.bin" -printf "%s\t%p\n" | while IFS=$'\t' read -r size file; do
printf "\e[33m%s\e[0m\t%s\n" "$size" "$file"
done
elif $binary_flag; then # Check binary flag after size flag
echo ""
echo "Binary data of files containing '$binary_string':"
find . -maxdepth 1 -name "*.bin" -name "*$binary_string*" -print0 | while IFS= read -r -d $'\0' file; do
echo "File: $file"
xxd -b "$file"
echo "" # Add an extra blank line
done
fi
cd .. # Go back to the parent directory