mirror of
https://github.com/Hizenberg469/Algorithms-snippets.git
synced 2026-04-19 22:52:23 +03:00
Bash script for playground updated
This commit is contained in:
@@ -1,11 +1,32 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ $# -ne 1 ]; then
|
||||
echo "Provide the limit of stress testing"
|
||||
echo "$0 'test case limit'"
|
||||
echo "$0 -1 (for unlimited)"
|
||||
exit 1
|
||||
fi
|
||||
# if [ $# -ne 1 ]; then
|
||||
# echo "Provide the limit of stress testing"
|
||||
# echo "$0 'test case limit'"
|
||||
# echo "$0 -1 (for unlimited)"
|
||||
# echo "OPTIONAL: $0 -n (for running with bruteforce)"
|
||||
# exit 1
|
||||
# fi
|
||||
|
||||
limit=0
|
||||
flag=true
|
||||
while getopts l:nh param; do
|
||||
case $param in
|
||||
l)
|
||||
limit=$OPTARG
|
||||
;;
|
||||
n)
|
||||
flag=false
|
||||
;;
|
||||
h)
|
||||
echo "Provide the limit of stress testing"
|
||||
echo "$0 'test case limit'"
|
||||
echo "$0 -1 (for unlimited)"
|
||||
echo "OPTIONAL: $0 -n (for running with bruteforce)"
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
#Required tools
|
||||
SOLUTION=build/solution
|
||||
@@ -24,24 +45,34 @@ pass_count=0
|
||||
|
||||
while (( 1 ))
|
||||
do
|
||||
./generator > $TESTCASE_FILE
|
||||
./SOLUTION < $TESTCASE_FILE > $OUTPUT_FILE
|
||||
./BRUTEFORCE < $TESTCASE_FILE > $CORRECT_ANSWER_FILE
|
||||
./$GENERATOR $(($pass_count+1)) > $TESTCASE_FILE
|
||||
./$SOLUTION < $TESTCASE_FILE > $OUTPUT_FILE
|
||||
|
||||
if diff -q -Z $OUTPUT_FILE $CORRECT_ANSWER_FILE >> /dev/null; then
|
||||
echo -e "\033[0;31mTest #$(($pass_count+1)): FAIL\033[0m"
|
||||
if $flag ; then
|
||||
./$BRUTEFORCE < $TESTCASE_FILE > $CORRECT_ANSWER_FILE
|
||||
|
||||
if diff -q -Z $OUTPUT_FILE $CORRECT_ANSWER_FILE >> /dev/null; then
|
||||
echo -e "\033[0;31mTest #$(($pass_count+1)): FAIL\033[0m"
|
||||
echo "Test case:"
|
||||
cat $TESTCASE_FILE
|
||||
echo "Your output:"
|
||||
cat $OUTPUT_FILE
|
||||
echo "Correct output:"
|
||||
cat $CORRECT_ANSWER_FILE
|
||||
break
|
||||
fi
|
||||
|
||||
echo -e "\033[0;32mPassed test: #$(($pass_count+1))\033[0m"
|
||||
else
|
||||
echo -e "Test #$(($pass_count+1)):"
|
||||
echo "Test case:"
|
||||
cat $TESTCASE_FILE
|
||||
echo "Your output:"
|
||||
cat $OUTPUT_FILE
|
||||
echo "Correct output:"
|
||||
cat $CORRECT_ANSWER_FILE
|
||||
break
|
||||
fi
|
||||
|
||||
echo -e "\033[0;32mPassed test: #$(($pass_count+1))\033[0m"
|
||||
|
||||
if [ $1 -ne -1 ] || [ $pass_count -lt $1 ]; then
|
||||
let pass_count++
|
||||
if [ $limit -ne -1 ] && [ $pass_count -ge $limit ]; then
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
Reference in New Issue
Block a user