diff --git a/README.md b/README.md index 063b579..83350b6 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,7 @@ eval | Contains files related to evaluation eval/makefile | A file that needs to make the evaluator, eval/eval.bin eval/eval.bin | A file that evaluates. It will read the input file from *problemname*.in, the output file from *problemname*.out, the ok file from *problemname*.ok. It will write the score to *stdout* and the evaluation message to *stderr*. tests | Holds tests +oldtests | Holds old revisions of tests stage | Where evaluation happens testmanifest format: diff --git a/examples/aorib/eval/eval.bin b/examples/aorib/eval/eval.bin deleted file mode 100755 index d03e57d..0000000 Binary files a/examples/aorib/eval/eval.bin and /dev/null differ diff --git a/examples/aorib/eval/eval.cpp b/examples/aorib/eval/eval.cpp deleted file mode 100644 index eb52b30..0000000 --- a/examples/aorib/eval/eval.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include -#include -#include -using namespace std; - -int main(){ - ifstream fout("aorib.out"); - ifstream fok("aorib.ok"); - - int points = 0; - fok >> points; - - string s1, s2; - while(fok >> s1){ - if(!bool(fout >> s2) || s1 != s2){ - cerr << "WA" << endl; - cout << 0 << endl; - return 0; } } - - cerr << "OK" << endl; - cout << points << endl; - return 0; } diff --git a/examples/aorib/eval/makefile b/examples/aorib/eval/makefile deleted file mode 100644 index 2abe5c6..0000000 --- a/examples/aorib/eval/makefile +++ /dev/null @@ -1,2 +0,0 @@ -../eval/eval.bin: - g++ eval.cpp -std=c++11 -o ../eval/eval.bin diff --git a/examples/aorib/incf/fixed b/examples/aorib/incf/fixed deleted file mode 100644 index 722ff38..0000000 --- a/examples/aorib/incf/fixed +++ /dev/null @@ -1 +0,0 @@ -1 0 1 diff --git a/examples/aorib/incf/random b/examples/aorib/incf/random deleted file mode 100644 index a5c7b77..0000000 --- a/examples/aorib/incf/random +++ /dev/null @@ -1 +0,0 @@ -0 0 0 diff --git a/examples/aorib/ingen/ingen.bin b/examples/aorib/ingen/ingen.bin deleted file mode 100755 index 078734f..0000000 Binary files a/examples/aorib/ingen/ingen.bin and /dev/null differ diff --git a/examples/aorib/ingen/ingen.cpp b/examples/aorib/ingen/ingen.cpp deleted file mode 100644 index b59f1f5..0000000 --- a/examples/aorib/ingen/ingen.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include -#include -using namespace std; - -int main(){ - ifstream f("aorib.cf"); - ofstream g("aorib.in"); - bool fixed; - int x, y; - f >> fixed >> x >> y; - - if(fixed) g << x << ' ' << y << endl; - else{ - srand(time(nullptr)); - g << rand() << ' ' << rand() << endl; } - return 0; } diff --git a/examples/aorib/ingen/makefile b/examples/aorib/ingen/makefile deleted file mode 100644 index ae4ea9c..0000000 --- a/examples/aorib/ingen/makefile +++ /dev/null @@ -1,2 +0,0 @@ -../ingen/ingen.bin: - g++ ingen.cpp -std=c++11 -o ../ingen/ingen.bin diff --git a/examples/aorib/lib.sh b/examples/aorib/lib.sh deleted file mode 100644 index cfee486..0000000 --- a/examples/aorib/lib.sh +++ /dev/null @@ -1,100 +0,0 @@ -#!/bin/bash -# -# Bash library for this project -# Tamio-Vesa Nakajima - -# Tries to execute $1 ; if this succeeds, do nothing -# otherwise, output $2 -try () { - if eval $1 ; then - : - else - echo $2 - exit 1 - fi -} - -# Tries to copy $1 to $2 ; if $1 doesn't exist, creates an empty $2 -maybecp () { - if [ -f $1 ] ; then - cp $1 $2 - else - touch $2 - fi -} - -# Evaluates the binary $1 with test $2, returning the message in $message, the time used in $timeUsed and the points in $points -evaluate_src_test () { - binary=$1 - testname=$2 - - # Get an appropriate timeout command - timeoutCommand=timeout - - if [[ "$OSTYPE" == "darwin"* ]] ; then - timeoutCommand=gtimeout - fi - - # Fetch the problem configuration - source problemconfig.sh - - # clear any previous messages - echo -en " \r" - - # Output an appropriate messgae - echo -en "Doing $testname\r" - - # Clean the stage - rm stage/* - - # Copy the binary into the stage - cp $binary stage/$problemname.bin - - # Copy the input into the stage - cp tests/$testname.in stage/$problemname.in - - # Get the problem config - source problemconfig.sh - - # This string runs the competitor's executable - runExec="./$problemname.bin > /dev/null 2> /dev/null" - - # This string runs the competitors executable with an appropriate timeout - runExecWithTimeout="$timeoutCommand $timelimit $runExec" - - # Run the competitors executable with a timeout, and store the time used in timeUsed - timeUsed=$(cd stage && { time $runExecWithTimeout ; } 2>&1 >/dev/null \ - | tail -3 \ - | head -1 \ - | awk -F ' ' '{print $2}' \ - | awk -F 'm' '{print $2}' \ - | awk -F 's' '{print $1}' && cd ..) - - if (( $(echo "$timeUsed > $timelimit" | bc -l))) ; then - # Set the return values - # timeUsed is already set - message=TLE - points=0 - else - # Make the evaluator - try "cd eval && make -s && cd .." "evaluator build fail" - - # Copy the evaluator into the stage - cp eval/eval.bin stage/eval.bin - - # Copy the ok file into the stage - cp tests/$testname.ok stage/$problemname.ok - - # Create temporary files to hold the points and the eval message - pointsFile=`mktemp` - messageFile=`mktemp` - - # Enter the stage and evaluate, storing the results in $pointsFile and $messageFile - try "cd stage && ./eval.bin > $pointsFile 2> $messageFile && cd .." "eval error" - - # Set the return values - # timeUsed is already set - points=`cat $pointsFile` - message=`cat $messageFile` - fi -} diff --git a/examples/aorib/okgen/makefile b/examples/aorib/okgen/makefile deleted file mode 100644 index 0bc29f0..0000000 --- a/examples/aorib/okgen/makefile +++ /dev/null @@ -1,2 +0,0 @@ -../okgen/okgen.bin: - g++ okgen.cpp -std=c++11 -o ../okgen/okgen.bin diff --git a/examples/aorib/okgen/okgen.bin b/examples/aorib/okgen/okgen.bin deleted file mode 100755 index c5e0513..0000000 Binary files a/examples/aorib/okgen/okgen.bin and /dev/null differ diff --git a/examples/aorib/okgen/okgen.cpp b/examples/aorib/okgen/okgen.cpp deleted file mode 100644 index 9d7d3cb..0000000 --- a/examples/aorib/okgen/okgen.cpp +++ /dev/null @@ -1,14 +0,0 @@ -#include -using namespace std; - -int main(){ - ifstream points("aorib.points"); - ifstream f("aorib.in"); - ofstream g("aorib.ok"); - - long long p, x, y; - f >> x >> y; - points >> p; - g << p << endl; - g << x*y << endl; - return 0; } diff --git a/examples/aorib/problemconfig.sh b/examples/aorib/problemconfig.sh deleted file mode 100644 index eb06f31..0000000 --- a/examples/aorib/problemconfig.sh +++ /dev/null @@ -1,2 +0,0 @@ -problemname=aorib -timelimit=0.1 diff --git a/examples/aorib/run.sh b/examples/aorib/run.sh deleted file mode 100755 index c5067cf..0000000 --- a/examples/aorib/run.sh +++ /dev/null @@ -1,107 +0,0 @@ -#!/bin/bash -# -# Runs sources on tests -# Tamio-Vesa Nakajima -# -# Use cases: -# ./run.sh -> runs all sources on all tests -# ./run.sh -s "a.cpp b.cpp" -s c.cpp -> runs a,b,c.cpp on all tests -# ./run.sh -t "00 01 02" -> runs all sources on tests 00, 01, 02 -# ./run.sh -s a.cpp -t 00 -> runs a.cpp on 00 - -########################## -# GENERAL SETUP -######################### - -# include the library -source lib.sh - -# include the configuration -source problemconfig.sh - -# make stage (as git deletes it) -mkdir -p stage - -############################ -# ARGUMENT PARSING -############################# - -# default values for used sources and used tests - -srcs="" -tests="" - -while getopts "hs:t:" opt; do - case $opt in - h) - echo "Usage: ./run.sh -s [source] -t [test]" - exit 0 - ;; - s) - for x in $OPTARG ; do - srcs="$srcs $x" - done - ;; - t) - for x in $OPTARG ; do - tests="$tests $problemname-$x" - done - ;; - esac -done - -if [ -z "$srcs" ] ; then - srcs=`ls -1 src | grep .cpp` -fi - -if [ -z "$tests" ] ; then - tests=`ls -1 tests | grep .in | awk -F '.' '{print $1}'` -fi - -tests=`echo $tests | sort -t '-' -k 1 -n` - - -########################### -# EVALUATING -########################## - -for src in $srcs ; do - # Copy the source into the stage - try "cp src/$src stage/$problemname.cpp" "source file missing" - - # Create a temporary file to hold the problem binary - binary=`mktemp` - - # Build the source - try "g++ stage/$problemname.cpp -std=c++11 -o $binary -O2" "Compile error" - - # Make a temporary file to hold the table: - table=`mktemp` - - # $table holds the score table - echo $src > $table - echo Test Message Time Points >> $table - - # For all tests - for testname in $tests ; do - # evaluate $binary on $testname, setting $message, $timeUsed, $points - evaluate_src_test $binary $testname - echo $testname.in $message $timeUsed $points >> $table - done - - # Clear "Doing test ..." - echo -en " \r" - - # Output the table - column -t $table - - # Calculate the score - echo SCORE: `awk -F ' ' '$1 != "Test" {sum += 0 $4} END {print sum}' $table` - - # Clear the temporary files - rm $table - rm $binary - - # And the stage - rm stage/* -done diff --git a/examples/aorib/src/ok.cpp b/examples/aorib/src/ok.cpp deleted file mode 100644 index f62ffa8..0000000 --- a/examples/aorib/src/ok.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include -using namespace std; - -int main(){ - ifstream f("aorib.in"); - ofstream g("aorib.out"); - long long x, y; - f >> x >> y; - g << x*y << endl; - return 0; } diff --git a/examples/aorib/src/tle.cpp b/examples/aorib/src/tle.cpp deleted file mode 100644 index c55d503..0000000 --- a/examples/aorib/src/tle.cpp +++ /dev/null @@ -1,2 +0,0 @@ -int main(){ - while(true){} } diff --git a/examples/aorib/src/wa.cpp b/examples/aorib/src/wa.cpp deleted file mode 100644 index 59c52f1..0000000 --- a/examples/aorib/src/wa.cpp +++ /dev/null @@ -1,4 +0,0 @@ -#include -using namespace std; - -int main(){} diff --git a/examples/aorib/stage/aorib.bin b/examples/aorib/stage/aorib.bin deleted file mode 100755 index c5d63c9..0000000 Binary files a/examples/aorib/stage/aorib.bin and /dev/null differ diff --git a/examples/aorib/testmanifest b/examples/aorib/testmanifest deleted file mode 100644 index 83d2d86..0000000 --- a/examples/aorib/testmanifest +++ /dev/null @@ -1,2 +0,0 @@ -1 fixed 10 -18 random 90 diff --git a/examples/aorib/tests/aorib-1.in b/examples/aorib/tests/aorib-1.in deleted file mode 100644 index e69de29..0000000 diff --git a/examples/aorib/tests/aorib-1.ok b/examples/aorib/tests/aorib-1.ok deleted file mode 100644 index cb6e5ed..0000000 --- a/examples/aorib/tests/aorib-1.ok +++ /dev/null @@ -1,2 +0,0 @@ -5 -0 diff --git a/examples/aorib/tests/aorib-10.in b/examples/aorib/tests/aorib-10.in deleted file mode 100644 index e69de29..0000000 diff --git a/examples/aorib/tests/aorib-10.ok b/examples/aorib/tests/aorib-10.ok deleted file mode 100644 index cb6e5ed..0000000 --- a/examples/aorib/tests/aorib-10.ok +++ /dev/null @@ -1,2 +0,0 @@ -5 -0 diff --git a/examples/aorib/tests/aorib-11.in b/examples/aorib/tests/aorib-11.in deleted file mode 100644 index e69de29..0000000 diff --git a/examples/aorib/tests/aorib-11.ok b/examples/aorib/tests/aorib-11.ok deleted file mode 100644 index cb6e5ed..0000000 --- a/examples/aorib/tests/aorib-11.ok +++ /dev/null @@ -1,2 +0,0 @@ -5 -0 diff --git a/examples/aorib/tests/aorib-12.in b/examples/aorib/tests/aorib-12.in deleted file mode 100644 index e69de29..0000000 diff --git a/examples/aorib/tests/aorib-12.ok b/examples/aorib/tests/aorib-12.ok deleted file mode 100644 index cb6e5ed..0000000 --- a/examples/aorib/tests/aorib-12.ok +++ /dev/null @@ -1,2 +0,0 @@ -5 -0 diff --git a/examples/aorib/tests/aorib-13.in b/examples/aorib/tests/aorib-13.in deleted file mode 100644 index e69de29..0000000 diff --git a/examples/aorib/tests/aorib-13.ok b/examples/aorib/tests/aorib-13.ok deleted file mode 100644 index cb6e5ed..0000000 --- a/examples/aorib/tests/aorib-13.ok +++ /dev/null @@ -1,2 +0,0 @@ -5 -0 diff --git a/examples/aorib/tests/aorib-14.in b/examples/aorib/tests/aorib-14.in deleted file mode 100644 index e69de29..0000000 diff --git a/examples/aorib/tests/aorib-14.ok b/examples/aorib/tests/aorib-14.ok deleted file mode 100644 index cb6e5ed..0000000 --- a/examples/aorib/tests/aorib-14.ok +++ /dev/null @@ -1,2 +0,0 @@ -5 -0 diff --git a/examples/aorib/tests/aorib-15.in b/examples/aorib/tests/aorib-15.in deleted file mode 100644 index e69de29..0000000 diff --git a/examples/aorib/tests/aorib-15.ok b/examples/aorib/tests/aorib-15.ok deleted file mode 100644 index cb6e5ed..0000000 --- a/examples/aorib/tests/aorib-15.ok +++ /dev/null @@ -1,2 +0,0 @@ -5 -0 diff --git a/examples/aorib/tests/aorib-16.in b/examples/aorib/tests/aorib-16.in deleted file mode 100644 index e69de29..0000000 diff --git a/examples/aorib/tests/aorib-16.ok b/examples/aorib/tests/aorib-16.ok deleted file mode 100644 index cb6e5ed..0000000 --- a/examples/aorib/tests/aorib-16.ok +++ /dev/null @@ -1,2 +0,0 @@ -5 -0 diff --git a/examples/aorib/tests/aorib-17.in b/examples/aorib/tests/aorib-17.in deleted file mode 100644 index e69de29..0000000 diff --git a/examples/aorib/tests/aorib-17.ok b/examples/aorib/tests/aorib-17.ok deleted file mode 100644 index cb6e5ed..0000000 --- a/examples/aorib/tests/aorib-17.ok +++ /dev/null @@ -1,2 +0,0 @@ -5 -0 diff --git a/examples/aorib/tests/aorib-18.in b/examples/aorib/tests/aorib-18.in deleted file mode 100644 index e69de29..0000000 diff --git a/examples/aorib/tests/aorib-18.ok b/examples/aorib/tests/aorib-18.ok deleted file mode 100644 index cb6e5ed..0000000 --- a/examples/aorib/tests/aorib-18.ok +++ /dev/null @@ -1,2 +0,0 @@ -5 -0 diff --git a/examples/aorib/tests/aorib-2.in b/examples/aorib/tests/aorib-2.in deleted file mode 100644 index e69de29..0000000 diff --git a/examples/aorib/tests/aorib-2.ok b/examples/aorib/tests/aorib-2.ok deleted file mode 100644 index cb6e5ed..0000000 --- a/examples/aorib/tests/aorib-2.ok +++ /dev/null @@ -1,2 +0,0 @@ -5 -0 diff --git a/examples/aorib/tests/aorib-3.in b/examples/aorib/tests/aorib-3.in deleted file mode 100644 index e69de29..0000000 diff --git a/examples/aorib/tests/aorib-3.ok b/examples/aorib/tests/aorib-3.ok deleted file mode 100644 index cb6e5ed..0000000 --- a/examples/aorib/tests/aorib-3.ok +++ /dev/null @@ -1,2 +0,0 @@ -5 -0 diff --git a/examples/aorib/tests/aorib-4.in b/examples/aorib/tests/aorib-4.in deleted file mode 100644 index e69de29..0000000 diff --git a/examples/aorib/tests/aorib-4.ok b/examples/aorib/tests/aorib-4.ok deleted file mode 100644 index cb6e5ed..0000000 --- a/examples/aorib/tests/aorib-4.ok +++ /dev/null @@ -1,2 +0,0 @@ -5 -0 diff --git a/examples/aorib/tests/aorib-5.in b/examples/aorib/tests/aorib-5.in deleted file mode 100644 index e69de29..0000000 diff --git a/examples/aorib/tests/aorib-5.ok b/examples/aorib/tests/aorib-5.ok deleted file mode 100644 index cb6e5ed..0000000 --- a/examples/aorib/tests/aorib-5.ok +++ /dev/null @@ -1,2 +0,0 @@ -5 -0 diff --git a/examples/aorib/tests/aorib-6.in b/examples/aorib/tests/aorib-6.in deleted file mode 100644 index e69de29..0000000 diff --git a/examples/aorib/tests/aorib-6.ok b/examples/aorib/tests/aorib-6.ok deleted file mode 100644 index cb6e5ed..0000000 --- a/examples/aorib/tests/aorib-6.ok +++ /dev/null @@ -1,2 +0,0 @@ -5 -0 diff --git a/examples/aorib/tests/aorib-7.in b/examples/aorib/tests/aorib-7.in deleted file mode 100644 index e69de29..0000000 diff --git a/examples/aorib/tests/aorib-7.ok b/examples/aorib/tests/aorib-7.ok deleted file mode 100644 index cb6e5ed..0000000 --- a/examples/aorib/tests/aorib-7.ok +++ /dev/null @@ -1,2 +0,0 @@ -5 -0 diff --git a/examples/aorib/tests/aorib-8.in b/examples/aorib/tests/aorib-8.in deleted file mode 100644 index e69de29..0000000 diff --git a/examples/aorib/tests/aorib-8.ok b/examples/aorib/tests/aorib-8.ok deleted file mode 100644 index cb6e5ed..0000000 --- a/examples/aorib/tests/aorib-8.ok +++ /dev/null @@ -1,2 +0,0 @@ -5 -0 diff --git a/examples/aorib/tests/aorib-9.in b/examples/aorib/tests/aorib-9.in deleted file mode 100644 index e69de29..0000000 diff --git a/examples/aorib/tests/aorib-9.ok b/examples/aorib/tests/aorib-9.ok deleted file mode 100644 index cb6e5ed..0000000 --- a/examples/aorib/tests/aorib-9.ok +++ /dev/null @@ -1,2 +0,0 @@ -5 -0 diff --git a/examples/aorib/buildtests.sh b/examples/aplusb/buildtests similarity index 78% rename from examples/aorib/buildtests.sh rename to examples/aplusb/buildtests index d57de12..e7b74df 100755 --- a/examples/aorib/buildtests.sh +++ b/examples/aplusb/buildtests @@ -4,13 +4,31 @@ # Tamio-Vesa Nakajima # include the library -source lib.sh +source lib # include the configuration -source problemconfig.sh +source problemconfig + +############################ +# ARGUMENT PARSING +############################# + + +while getopts "r:h" opt; do + case $opt in + h) + echo "Usage: ./run -r(estore) [revision to restore]" + exit 0 + ;; + r) + rm -r tests + unzip oldtests/$OPTARG.zip + exit 0 + ;; + esac +done -# Make stage (as git deletes it) -mkdir -p stage +read -p "Name of this test revision: " testrevision # We will want to remember this: currtest=0 @@ -69,5 +87,6 @@ cat testmanifest | while read instr; do #update currtest currtest=$(($currtest + $numberoftests)) - done + +zip -r oldtests/$testrevision.zip tests/* diff --git a/examples/aplusb/buildtests.sh b/examples/aplusb/buildtests.sh deleted file mode 100755 index d57de12..0000000 --- a/examples/aplusb/buildtests.sh +++ /dev/null @@ -1,73 +0,0 @@ -#!/bin/bash -# -# This builds all tests using testmanifest -# Tamio-Vesa Nakajima - -# include the library -source lib.sh - -# include the configuration -source problemconfig.sh - -# Make stage (as git deletes it) -mkdir -p stage - -# We will want to remember this: -currtest=0 - -# Loop over lines of -cat testmanifest | while read instr; do - # Parse a line of testmanifest - set $instr - numberoftests=$1 - incf=$2 - totalpoints=$3 - points=$(($totalpoints / $numberoftests)) - - for nr in `seq $currtest $(($currtest + $numberoftests - 1))` ; do - echo $nr - ################# - # Build input: - ################# - - # Build input generator - try "cd ingen && make -s && cd .." "input generator build fail" - - # Copy ingen/ingen.bin and incf/$1 into stage - cp ingen/ingen.bin stage/$problemname.bin - try "cp incf/$incf stage/$problemname.cf" "incf/$incf doesn't exist" - - # Build input - try "cd stage && ./$problemname.bin > ../tests/$problemname-$nr.in && cd .." "input generation fail" - - # Clean stage - rm stage/* - - ################### - # Build ok - ################### - - # Build ok generator - try "cd okgen && make -s && cd .." "ok generator build fil" - - # Copy ok generator and input into stage - cp okgen/okgen.bin stage/$problemname.bin - cp tests/$problemname-$nr.in stage/$problemname.in - - # Indicate the number of points in the stage - echo $points > stage/$problemname.points - - # Build ok - try "cd stage && ./$problemname.bin && cd .." "ok generation fail" - - # Copy ok from stage into tests - cp stage/$problemname.ok tests/$problemname-$nr.ok - - # Clean stage - rm stage/* - done - - #update currtest - currtest=$(($currtest + $numberoftests)) - -done diff --git a/examples/aplusb/lib.sh b/examples/aplusb/lib similarity index 88% rename from examples/aplusb/lib.sh rename to examples/aplusb/lib index cfee486..d9526ac 100644 --- a/examples/aplusb/lib.sh +++ b/examples/aplusb/lib @@ -23,8 +23,8 @@ maybecp () { fi } -# Evaluates the binary $1 with test $2, returning the message in $message, the time used in $timeUsed and the points in $points -evaluate_src_test () { +# Run the binary $1 with test $2, returning the time used in timeUsed, and leaving the output file in stage/$problemname.out +run_src_test () { binary=$1 testname=$2 @@ -36,10 +36,10 @@ evaluate_src_test () { fi # Fetch the problem configuration - source problemconfig.sh + source problemconfig # clear any previous messages - echo -en " \r" + echo -en "\r \r" # Output an appropriate messgae echo -en "Doing $testname\r" @@ -54,7 +54,7 @@ evaluate_src_test () { cp tests/$testname.in stage/$problemname.in # Get the problem config - source problemconfig.sh + source problemconfig # This string runs the competitor's executable runExec="./$problemname.bin > /dev/null 2> /dev/null" @@ -69,7 +69,14 @@ evaluate_src_test () { | awk -F ' ' '{print $2}' \ | awk -F 'm' '{print $2}' \ | awk -F 's' '{print $1}' && cd ..) +} + +# Evaluates the binary $1 with test $2, returning the message in $message, the time used in $timeUsed and the points in $points +evaluate_src_test () { + binary=$1 + testname=$2 + run_src_test $binary $testname if (( $(echo "$timeUsed > $timelimit" | bc -l))) ; then # Set the return values # timeUsed is already set diff --git a/examples/aplusb/oldtests/big.zip b/examples/aplusb/oldtests/big.zip new file mode 100644 index 0000000..4417302 Binary files /dev/null and b/examples/aplusb/oldtests/big.zip differ diff --git a/examples/aplusb/oldtests/first.zip b/examples/aplusb/oldtests/first.zip new file mode 100644 index 0000000..a4c6955 Binary files /dev/null and b/examples/aplusb/oldtests/first.zip differ diff --git a/examples/aplusb/oldtests/ls.zip b/examples/aplusb/oldtests/ls.zip new file mode 100644 index 0000000..842136c Binary files /dev/null and b/examples/aplusb/oldtests/ls.zip differ diff --git a/examples/aplusb/oldtests/second.zip b/examples/aplusb/oldtests/second.zip new file mode 100644 index 0000000..7e0ff38 Binary files /dev/null and b/examples/aplusb/oldtests/second.zip differ diff --git a/examples/aplusb/problemconfig.sh b/examples/aplusb/problemconfig similarity index 100% rename from examples/aplusb/problemconfig.sh rename to examples/aplusb/problemconfig diff --git a/examples/tmp/run.sh b/examples/aplusb/run similarity index 93% rename from examples/tmp/run.sh rename to examples/aplusb/run index c5067cf..1289837 100755 --- a/examples/tmp/run.sh +++ b/examples/aplusb/run @@ -14,10 +14,10 @@ ######################### # include the library -source lib.sh +source lib # include the configuration -source problemconfig.sh +source problemconfig # make stage (as git deletes it) mkdir -p stage @@ -34,7 +34,7 @@ tests="" while getopts "hs:t:" opt; do case $opt in h) - echo "Usage: ./run.sh -s [source] -t [test]" + echo "Usage: ./run -s [source] -t [test]" exit 0 ;; s) @@ -90,7 +90,7 @@ for src in $srcs ; do done # Clear "Doing test ..." - echo -en " \r" + echo -en "\r \r" # Output the table column -t $table diff --git a/examples/aplusb/run.sh b/examples/aplusb/run.sh deleted file mode 100755 index c5067cf..0000000 --- a/examples/aplusb/run.sh +++ /dev/null @@ -1,107 +0,0 @@ -#!/bin/bash -# -# Runs sources on tests -# Tamio-Vesa Nakajima -# -# Use cases: -# ./run.sh -> runs all sources on all tests -# ./run.sh -s "a.cpp b.cpp" -s c.cpp -> runs a,b,c.cpp on all tests -# ./run.sh -t "00 01 02" -> runs all sources on tests 00, 01, 02 -# ./run.sh -s a.cpp -t 00 -> runs a.cpp on 00 - -########################## -# GENERAL SETUP -######################### - -# include the library -source lib.sh - -# include the configuration -source problemconfig.sh - -# make stage (as git deletes it) -mkdir -p stage - -############################ -# ARGUMENT PARSING -############################# - -# default values for used sources and used tests - -srcs="" -tests="" - -while getopts "hs:t:" opt; do - case $opt in - h) - echo "Usage: ./run.sh -s [source] -t [test]" - exit 0 - ;; - s) - for x in $OPTARG ; do - srcs="$srcs $x" - done - ;; - t) - for x in $OPTARG ; do - tests="$tests $problemname-$x" - done - ;; - esac -done - -if [ -z "$srcs" ] ; then - srcs=`ls -1 src | grep .cpp` -fi - -if [ -z "$tests" ] ; then - tests=`ls -1 tests | grep .in | awk -F '.' '{print $1}'` -fi - -tests=`echo $tests | sort -t '-' -k 1 -n` - - -########################### -# EVALUATING -########################## - -for src in $srcs ; do - # Copy the source into the stage - try "cp src/$src stage/$problemname.cpp" "source file missing" - - # Create a temporary file to hold the problem binary - binary=`mktemp` - - # Build the source - try "g++ stage/$problemname.cpp -std=c++11 -o $binary -O2" "Compile error" - - # Make a temporary file to hold the table: - table=`mktemp` - - # $table holds the score table - echo $src > $table - echo Test Message Time Points >> $table - - # For all tests - for testname in $tests ; do - # evaluate $binary on $testname, setting $message, $timeUsed, $points - evaluate_src_test $binary $testname - echo $testname.in $message $timeUsed $points >> $table - done - - # Clear "Doing test ..." - echo -en " \r" - - # Output the table - column -t $table - - # Calculate the score - echo SCORE: `awk -F ' ' '$1 != "Test" {sum += 0 $4} END {print sum}' $table` - - # Clear the temporary files - rm $table - rm $binary - - # And the stage - rm stage/* -done diff --git a/examples/aplusb/stage/aplusb.bin b/examples/aplusb/stage/aplusb.bin deleted file mode 100755 index c5d63c9..0000000 Binary files a/examples/aplusb/stage/aplusb.bin and /dev/null differ diff --git a/examples/aplusb/stage/aplusb.in b/examples/aplusb/stage/aplusb.in deleted file mode 100644 index e69de29..0000000 diff --git a/examples/aorib/incf/makefile b/examples/aplusb/tests/tests/aplusb-0.in similarity index 100% rename from examples/aorib/incf/makefile rename to examples/aplusb/tests/tests/aplusb-0.in diff --git a/examples/aorib/tests/aorib-0.ok b/examples/aplusb/tests/tests/aplusb-0.ok similarity index 100% rename from examples/aorib/tests/aorib-0.ok rename to examples/aplusb/tests/tests/aplusb-0.ok diff --git a/examples/aorib/src/makefile b/examples/aplusb/tests/tests/aplusb-1.in similarity index 100% rename from examples/aorib/src/makefile rename to examples/aplusb/tests/tests/aplusb-1.in diff --git a/examples/aplusb/tests/tests/aplusb-1.ok b/examples/aplusb/tests/tests/aplusb-1.ok new file mode 100644 index 0000000..f4b9eda --- /dev/null +++ b/examples/aplusb/tests/tests/aplusb-1.ok @@ -0,0 +1,2 @@ +30 +0 diff --git a/examples/aorib/stage/aorib.in b/examples/aplusb/tests/tests/aplusb-2.in similarity index 100% rename from examples/aorib/stage/aorib.in rename to examples/aplusb/tests/tests/aplusb-2.in diff --git a/examples/aplusb/tests/tests/aplusb-2.ok b/examples/aplusb/tests/tests/aplusb-2.ok new file mode 100644 index 0000000..f4b9eda --- /dev/null +++ b/examples/aplusb/tests/tests/aplusb-2.ok @@ -0,0 +1,2 @@ +30 +0 diff --git a/examples/aorib/tests/aorib-0.in b/examples/aplusb/tests/tests/aplusb-3.in similarity index 100% rename from examples/aorib/tests/aorib-0.in rename to examples/aplusb/tests/tests/aplusb-3.in diff --git a/examples/aplusb/tests/tests/aplusb-3.ok b/examples/aplusb/tests/tests/aplusb-3.ok new file mode 100644 index 0000000..f4b9eda --- /dev/null +++ b/examples/aplusb/tests/tests/aplusb-3.ok @@ -0,0 +1,2 @@ +30 +0 diff --git a/examples/tmp/buildtests.sh b/examples/tmp/buildtests.sh deleted file mode 100755 index d57de12..0000000 --- a/examples/tmp/buildtests.sh +++ /dev/null @@ -1,73 +0,0 @@ -#!/bin/bash -# -# This builds all tests using testmanifest -# Tamio-Vesa Nakajima - -# include the library -source lib.sh - -# include the configuration -source problemconfig.sh - -# Make stage (as git deletes it) -mkdir -p stage - -# We will want to remember this: -currtest=0 - -# Loop over lines of -cat testmanifest | while read instr; do - # Parse a line of testmanifest - set $instr - numberoftests=$1 - incf=$2 - totalpoints=$3 - points=$(($totalpoints / $numberoftests)) - - for nr in `seq $currtest $(($currtest + $numberoftests - 1))` ; do - echo $nr - ################# - # Build input: - ################# - - # Build input generator - try "cd ingen && make -s && cd .." "input generator build fail" - - # Copy ingen/ingen.bin and incf/$1 into stage - cp ingen/ingen.bin stage/$problemname.bin - try "cp incf/$incf stage/$problemname.cf" "incf/$incf doesn't exist" - - # Build input - try "cd stage && ./$problemname.bin > ../tests/$problemname-$nr.in && cd .." "input generation fail" - - # Clean stage - rm stage/* - - ################### - # Build ok - ################### - - # Build ok generator - try "cd okgen && make -s && cd .." "ok generator build fil" - - # Copy ok generator and input into stage - cp okgen/okgen.bin stage/$problemname.bin - cp tests/$problemname-$nr.in stage/$problemname.in - - # Indicate the number of points in the stage - echo $points > stage/$problemname.points - - # Build ok - try "cd stage && ./$problemname.bin && cd .." "ok generation fail" - - # Copy ok from stage into tests - cp stage/$problemname.ok tests/$problemname-$nr.ok - - # Clean stage - rm stage/* - done - - #update currtest - currtest=$(($currtest + $numberoftests)) - -done diff --git a/examples/tmp/eval/makefile b/examples/tmp/eval/makefile deleted file mode 100644 index e69de29..0000000 diff --git a/examples/tmp/incf/makefile b/examples/tmp/incf/makefile deleted file mode 100644 index e69de29..0000000 diff --git a/examples/tmp/ingen/makefile b/examples/tmp/ingen/makefile deleted file mode 100644 index e69de29..0000000 diff --git a/examples/tmp/lib.sh b/examples/tmp/lib.sh deleted file mode 100644 index cfee486..0000000 --- a/examples/tmp/lib.sh +++ /dev/null @@ -1,100 +0,0 @@ -#!/bin/bash -# -# Bash library for this project -# Tamio-Vesa Nakajima - -# Tries to execute $1 ; if this succeeds, do nothing -# otherwise, output $2 -try () { - if eval $1 ; then - : - else - echo $2 - exit 1 - fi -} - -# Tries to copy $1 to $2 ; if $1 doesn't exist, creates an empty $2 -maybecp () { - if [ -f $1 ] ; then - cp $1 $2 - else - touch $2 - fi -} - -# Evaluates the binary $1 with test $2, returning the message in $message, the time used in $timeUsed and the points in $points -evaluate_src_test () { - binary=$1 - testname=$2 - - # Get an appropriate timeout command - timeoutCommand=timeout - - if [[ "$OSTYPE" == "darwin"* ]] ; then - timeoutCommand=gtimeout - fi - - # Fetch the problem configuration - source problemconfig.sh - - # clear any previous messages - echo -en " \r" - - # Output an appropriate messgae - echo -en "Doing $testname\r" - - # Clean the stage - rm stage/* - - # Copy the binary into the stage - cp $binary stage/$problemname.bin - - # Copy the input into the stage - cp tests/$testname.in stage/$problemname.in - - # Get the problem config - source problemconfig.sh - - # This string runs the competitor's executable - runExec="./$problemname.bin > /dev/null 2> /dev/null" - - # This string runs the competitors executable with an appropriate timeout - runExecWithTimeout="$timeoutCommand $timelimit $runExec" - - # Run the competitors executable with a timeout, and store the time used in timeUsed - timeUsed=$(cd stage && { time $runExecWithTimeout ; } 2>&1 >/dev/null \ - | tail -3 \ - | head -1 \ - | awk -F ' ' '{print $2}' \ - | awk -F 'm' '{print $2}' \ - | awk -F 's' '{print $1}' && cd ..) - - if (( $(echo "$timeUsed > $timelimit" | bc -l))) ; then - # Set the return values - # timeUsed is already set - message=TLE - points=0 - else - # Make the evaluator - try "cd eval && make -s && cd .." "evaluator build fail" - - # Copy the evaluator into the stage - cp eval/eval.bin stage/eval.bin - - # Copy the ok file into the stage - cp tests/$testname.ok stage/$problemname.ok - - # Create temporary files to hold the points and the eval message - pointsFile=`mktemp` - messageFile=`mktemp` - - # Enter the stage and evaluate, storing the results in $pointsFile and $messageFile - try "cd stage && ./eval.bin > $pointsFile 2> $messageFile && cd .." "eval error" - - # Set the return values - # timeUsed is already set - points=`cat $pointsFile` - message=`cat $messageFile` - fi -} diff --git a/examples/tmp/okgen/makefile b/examples/tmp/okgen/makefile deleted file mode 100644 index e69de29..0000000 diff --git a/examples/tmp/problemconfig.sh b/examples/tmp/problemconfig.sh deleted file mode 100644 index 262bab5..0000000 --- a/examples/tmp/problemconfig.sh +++ /dev/null @@ -1,2 +0,0 @@ -problemname=tmp -timelimit=22 diff --git a/examples/tmp/src/makefile b/examples/tmp/src/makefile deleted file mode 100644 index e69de29..0000000 diff --git a/examples/tmp/testmanifest b/examples/tmp/testmanifest deleted file mode 100644 index e69de29..0000000 diff --git a/examples/tmp/todo b/examples/tmp/todo deleted file mode 100644 index 8f8b63e..0000000 --- a/examples/tmp/todo +++ /dev/null @@ -1,9 +0,0 @@ -TODO: - -- make an evaluator (should read from $problemname.out and $problemname.ok, write the evaluation message to stderr and the # of points to cout -- make an input generator (should read configuration from $problemname.cf and write the input to $problemname.in) -- make an ok generator (should read the # of points from $problemname.points, the input from $problemname.in, and write to ok to $problemname.ok) -- make a testmanifest (each line should contain a group of tests, described by the # of tests, the configuration file, and the # of points for that group) -- call ./buildtests.sh -- add source files to src -- call ./run.sh diff --git a/makeproject b/makeproject index cce5cbe..1515224 100755 --- a/makeproject +++ b/makeproject @@ -17,6 +17,7 @@ mkdir $1/$problemname/okgen mkdir $1/$problemname/src mkdir $1/$problemname/stage mkdir $1/$problemname/tests +mkdir $1/$problemname/oldtests touch $1/$problemname/eval/makefile touch $1/$problemname/incf/makefile diff --git a/src/buildtests b/src/buildtests index 2d201a4..e7b74df 100755 --- a/src/buildtests +++ b/src/buildtests @@ -9,6 +9,27 @@ source lib # include the configuration source problemconfig +############################ +# ARGUMENT PARSING +############################# + + +while getopts "r:h" opt; do + case $opt in + h) + echo "Usage: ./run -r(estore) [revision to restore]" + exit 0 + ;; + r) + rm -r tests + unzip oldtests/$OPTARG.zip + exit 0 + ;; + esac +done + +read -p "Name of this test revision: " testrevision + # We will want to remember this: currtest=0 @@ -66,5 +87,6 @@ cat testmanifest | while read instr; do #update currtest currtest=$(($currtest + $numberoftests)) - done + +zip -r oldtests/$testrevision.zip tests/* diff --git a/test/test_everything.sh b/test/test_everything.sh index 680c6de..bbad49a 100755 --- a/test/test_everything.sh +++ b/test/test_everything.sh @@ -11,13 +11,12 @@ cp test/aplusb/eval/* $project_directory/aplusb/eval cp test/aplusb/src/* $project_directory/aplusb/src cp test/aplusb/testmanifest $project_directory/aplusb/testmanifest - cd $project_directory/aplusb output_file=`mktemp` echo Running sources -./buildtests +echo first | ./buildtests ./run echo Cleanup