Last active
March 19, 2020 23:27
-
-
Save tarunbod/648e91d1d2f95488be4c734e32f4335a to your computer and use it in GitHub Desktop.
put this file in your project folder and run it with `sh test.sh`
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo "Generating inputs..." | |
# Generate random inputs | |
echo $RANDOM > sample0.tinyL.in | |
echo $RANDOM >> sample0.tinyL.in | |
echo $RANDOM >> sample0.tinyL.in | |
# echo >> sample0.tinyL.in | |
echo $RANDOM > sample1.tinyL.in | |
# echo >> sample1.tinyL.in | |
echo $RANDOM > sample3.tinyL.in | |
# echo >> sample3.tinyL.in | |
echo $RANDOM > sample4.tinyL.in | |
# echo >> sample4.tinyL.in | |
echo $RANDOM > sample6.tinyL.in | |
echo $RANDOM >> sample6.tinyL.in | |
# echo >> sample6.tinyL.in | |
echo $RANDOM > sample7.tinyL.in | |
# echo >> sample7.tinyL.in | |
echo $RANDOM > sample8.tinyL.in | |
# echo >> sample8.tinyL.in | |
echo $RANDOM > sample9.tinyL.in | |
# echo >> sample9.tinyL.in | |
echo "Running tests..." | |
# 1. Use your compiler and the reference compiler and compare | |
# the outputs when running both | |
# 2. Run your optimizer and the reference optimizer on both versions | |
# of compiled outputs | |
for f in `ls tests`; do | |
current=`echo $f | awk -F'.' '{ print $1 }'`; | |
echo "Testing $current"; | |
./compile.sol "tests/$f" > /dev/null; | |
mv tinyL.out "$f".out1; | |
./compile "tests/$f" > /dev/null; | |
mv tinyL.out "$f".out2; | |
if [[ -f "$f.in" ]]; then | |
./run "$f".out1 < "$f.in" | sed '$d' > "$f".run1; | |
./run "$f".out2 < "$f.in" | sed '$d' > "$f".run2; | |
else | |
./run "$f".out1 | sed '$d' > "$f".run1; | |
./run "$f".out2 | sed '$d' > "$f".run2; | |
fi | |
if diff "$f".run1 "$f".run2 > /dev/null; then | |
echo -e "\e[32m Compilers test for $f passed\e[0m"; | |
else | |
echo -e "\e[31m Compilers test for $f failed\e[0m"; | |
fi | |
./optimize.sol < "$f".out1 > "$f".opt11; | |
./optimize < "$f".out1 > "$f".opt21; | |
if diff "$f".opt11 "$f".opt21 > /dev/null; then | |
echo -e "\e[32m 1st Optmn test for $f passed\e[0m"; | |
else | |
echo -e "\e[31m 1st Optmn test for $f failed\e[0m"; | |
fi | |
./optimize.sol < "$f".out2 > "$f".opt12; | |
./optimize < "$f".out2 > "$f".opt22; | |
if diff "$f".opt12 "$f".opt22 > /dev/null; then | |
echo -e "\e[32m 2nd Optmn test for $f passed\e[0m"; | |
else | |
echo -e "\e[31m 2nd Optmn test for $f failed\e[0m"; | |
fi | |
if [[ -f "$f".in ]]; then | |
rm "$f".in; | |
fi | |
rm "$f".out1; | |
rm "$f".out2; | |
rm "$f".run1; | |
rm "$f".run2; | |
rm "$f".opt11; | |
rm "$f".opt12; | |
rm "$f".opt21; | |
rm "$f".opt22; | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment