-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathtest_stat_examples
More file actions
executable file
·54 lines (44 loc) · 1.66 KB
/
test_stat_examples
File metadata and controls
executable file
·54 lines (44 loc) · 1.66 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
#!/bin/bash
# Define colors
GREEN='\033[0;32m'
RED='\033[0;31m'
NC='\033[0m' # No Color
# Define paths
setlXlaunchScript="$PWD/interpreter/setlX"
statExamples="$PWD/example_SetlX_code/stat_test_code"
pythonReferences="$PWD/example_SetlX_stat_code/stat_python_code"
started=0
# Execute all test files
for file in `find $statExamples -name '*.reference' -prune`
do
setlXValue=$(cat $file)
file=${file##*/} # removing path from file name
file=${file%.*} # removing .reference ending from file name
file=${file%.*} # removing .stlx ending from file name
started=$(bc <<< "$started + 1")
echo -e "[INFO] Starting Test $started (${file})."
echo "::: SetlX: $setlXValue" # printing setlx value
pythonValue=0
if [ -f $pythonReferences/${file}".py.reference" ] # check if python reference exists for $file
then
pythonValue=$(cat $pythonReferences/${file}".py.reference")
echo "::: Python: $pythonValue" # printing python value
else
echo -e "[ERROR] Could not find the corresponding python reference file. Did you update the python references by running './example_SetlX_stat_code/create_python_references'?\n"
continue
fi
difference=1
faultTolerance=10E-12
if (( $(echo "$setlXValue > $pythonValue" | tr -d $'\r' | bc -l) ));
then difference=$(echo "scale=12;$setlXValue-$pythonValue" | tr -d $'\r' | bc)
else
difference=$(echo "scale=12;$pythonValue-$setlXValue" | tr -d $'\r' | bc)
fi
if (( $(echo "$difference < $faultTolerance" | tr -d $'\r' | bc) ));
then
message="::: Test $started (${file}) ${GREEN}successful${NC}!\n"
else
message="::: Test $started (${file}) ${RED}failed${NC} ...\n"
fi
echo -e "$message"
done