forked from fgarbe/TypeChef-SQLiteIfdeftoif
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathth3ParallelMultiConfigTest_featurewise.sh
More file actions
executable file
·120 lines (109 loc) · 4.37 KB
/
Copy pathth3ParallelMultiConfigTest_featurewise.sh
File metadata and controls
executable file
·120 lines (109 loc) · 4.37 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#!/bin/bash
trap "kill 0" SIGINT
# Use gcc version 4.8 if possible
GCC="gcc"
if [ ! -z "$(command -v gcc-4.8)" ]; then
GCC="gcc-4.8"
fi
rm -f featurewise_*.txt
./ifdeftoifParallel_fixed.sh
echo -e "Featurewise parallel starts at $(date +"%T")"
cd ../TH3
for th3configFile in ../TH3/cfg/*.cfg;
do
#generate test
for dir in */;
do
# Check if current folder contains *.test files
count=`ls -1 $dir/*.test 2>/dev/null | wc -l`
if [ $count != 0 -a $dir != "stress/" ]
then
for f in ../TypeChef-SQLiteIfdeftoif/optionstructs_ifdeftoif/featurewise/id2i_optionstruct*.h;
do
#sed filters everything but the number of the configuration
configID=$(basename $f | sed 's/id2i_optionstruct_//' | sed 's/.h//')
( cd ..
if [ ! -d "tmp_f$configID" ]; then
mkdir tmp_f$configID
fi
#generate TH3 test file
cd TH3
./mkth3.tcl $dir/*.test "$th3configFile" > ../tmp_f$configID/th3_generated_test.c
cd ../tmp_f$configID
cp th3_generated_test.c th3_generated_test_ifdeftoif.c
#insert /* Alex: added initialization of our version of the azCompileOpt array */ init_azCompileOpt();
sed -i \
's/int main(int argc, char \*\*argv){/int main(int argc, char \*\*argv){\/* Alex: added initialization of our version of the azCompileOpt array *\/ init_azCompileOpt()\;/' \
th3_generated_test_ifdeftoif.c
#better never touch this sed again
# Copy files used for compilation into temporary directory
cp $f id2i_optionstruct.h
cp ../TypeChef-SQLiteIfdeftoif/sqlite3_ifdeftoif.c sqlite3_ifdeftoif.c
cp ../TypeChef-SQLiteIfdeftoif/sqlite3.h sqlite3.h
echo "testing #ifConfig $f on .test files in $dir with th3Config $th3configFile at $(date +"%T")"
# Test normal sqlite
originalGCC=$($GCC -w -DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_THREADSAFE=0 \
-include "../TypeChef-SQLiteIfdeftoif/optionstructs_ifdeftoif/featurewise/id2i_include_$configID.h" \
../TypeChef-SQLiteIfdeftoif/sqlite3_original.c th3_generated_test.c 2>&1)
# If gcc returns errors skip the testing
if [ $? != 0 ]
then
echo -e "TH3 test can't compile original, skipping test; original GCC error:\n$originalGCC\n\n"
else
expectedTestResult=$(bash -c '(./a.out); exit $?' 2>&1)
expectedOutputValue=$?
rm -f a.out
# Test ifdeftoif sqlite
ifdeftoifGCC=$($GCC -w -DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_THREADSAFE=0 \
sqlite3_ifdeftoif.c th3_generated_test_ifdeftoif.c 2>&1)
# If gcc returns errors don't start testing the ifdeftoif variant
if [ $? != 0 ]
then
echo -e "TH3 test can't compile ifdeftoif; expected: $expectedOutputValue\nExpected test output:"
echo -e "$expectedTestResult" | tail -n 10
echo -e "\nIfdeftoif GCC error:"
echo -e "$ifdeftoifGCC"
echo -e "\n"
else
ifdeftoifTestResult=$(bash -c '(./a.out); exit $?' 2>&1)
testOutputValue=$?
if [ $testOutputValue -eq $expectedOutputValue ] ; then
# echo -e "$expectedTestResult"
echo -e "Test successful, exit Codes: $testOutputValue;\n\n"
else
if [ $expectedOutputValue -eq 0 ] ; then
echo -e "TH3 succeeds, ifdeftoif does not; ifdeftoif: $testOutputValue ; expected: $expectedOutputValue\nIfdeftoif test output:"
echo -e "$ifdeftoifTestResult" | tail -n 10
echo -e "\n"
else
if [ $testOutputValue -eq 0 ] ; then
echo -e "Ifdeftoif succeeds, TH3 does not; ifdeftoif: $testOutputValue ; expected: $expectedOutputValue\nExpected test output:"
echo -e "$expectedTestResult" | tail -n 10
echo -e "\n"
else
echo -e "TH3 test differs; ifdeftoif: $testOutputValue ; expected: $expectedOutputValue\nExpected test output:"
echo -e "$expectedTestResult" | tail -n 10
echo -e "\nIfdeftoif test output:"
echo -e "$ifdeftoifTestResult" | tail -n 10
echo -e "\n"
fi
fi
fi
rm -f a.out
fi
fi
#delete all temporary contents
rm -rf *; ) 2>&1 >> ../TypeChef-SQLiteIfdeftoif/featurewise_$configID.txt &
done
wait
fi
done
done
cd ..
rm -rf tmp_f*
cd TypeChef-SQLiteIfdeftoif/
rm -f th3_featurewise.txt
cat featurewise_*.txt > th3_featurewise.txt
rm -f featurewise_*.txt
echo -e "Featurewise parallel finished at $(date +"%T")"
exit