diff --git a/examples/aplusb/buildtests b/examples/aplusb/buildtests index c54ff74..1287e8d 100755 --- a/examples/aplusb/buildtests +++ b/examples/aplusb/buildtests @@ -3,12 +3,39 @@ # This builds all tests using testmanifest # Tamio-Vesa Nakajima -# include the library -source lib +################################# +# Build necesisties +################################# -# include the configuration +cd eval || exit +make -s +cd .. || exit + +cd okgen || exit +make -s +cd .. || exit + +cd ingen || exit +make -s +cd .. || exit + +################################# +# PROBLEM CONFIGURATION +################################# + +# initialize problemconfig variables +problemname="" +timelimit="" + +# shellcheck disable=SC1091 source problemconfig +# Check if problemconfig variables are set +if [ -z "$problemname" ] || [ -z "$timelimit" ] ; then + echo Bad config file + exit 1 +fi + ############################ # ARGUMENT PARSING ############################# @@ -17,73 +44,71 @@ rebuild_inputs=true while getopts "r:ho" opt; do case $opt in - h) - echo "Usage: ./run -r(estore) [revision to restore]" + h) # Help: + echo "Usage: ./run [-r REVISION] [-o]" + echo " -r REVISION -- restores REVISION" + echo " -o -- rebuilds only the .ok files" exit 0 ;; - r) + r) # Restore old revision rm -r tests - unzip oldtests/$OPTARG.zip + unzip "oldtests/$OPTARG.zip" exit 0 ;; - o) + o) # DO only the ok's again rebuild_inputs=false ;; + *) + echo "Bad options" + exit 1 + ;; esac done -read -p "Name of this test revision: " testrevision -# We will want to remember this: -currtest=0 +############################ +# Building tests +############################ -# Loop over lines of -cat testmanifest | while read instr; do +# Get test revision name +read -p "Name of this test revision: " -r testrevision + +# For all lines of the test manifest: +currtest=0 +while read -r instr; do # Parse a line of testmanifest + + # shellcheck disable=SC2086 set $instr numberoftests=$1 incf=$2 totalpoints=$3 - points=$(($totalpoints / $numberoftests)) - for nr in `seq $currtest $(($currtest + $numberoftests - 1))` ; do - echo $nr - ################# - # Build input: - ################# + # Get the number of points per test + points=$((totalpoints / numberoftests)) + + # For all tests of this kind: + for ((nr=$"currtest"; nr<"$currtest"+"$numberoftests" ; nr++)) ; do + ( + echo Building test "$nr" if [ $rebuild_inputs = true ] ; then - build_test_number $nr $incf + ./lib/build_test_number "$nr" "$incf" fi - ################### - # Build ok - ################### - - # Build ok generator - cd okgen && make -s && cd .. - - # Copy ok generator and input into stage - cp okgen/okgen.bin stage/$problemname.bin - cp tests/$problemname-$nr.in stage/$problemname.in + ./lib/build_ok_number "$nr" "$points" - # Indicate the number of points in the stage - echo $points > stage/$problemname.points - - # Build ok - cd stage && ./$problemname.bin && cd .. - - # Copy ok from stage into tests - cp stage/$problemname.ok tests/$problemname-$nr.ok - - # Clean stage - rm stage/* + echo Done test "$nr" + ) & done #update currtest - currtest=$(($currtest + $numberoftests)) -done + currtest=$((currtest + numberoftests)) +done < testmanifest + +wait -if [ -n $testrevision ] ; then - zip -r oldtests/$testrevision.zip tests/* +# Store this revision in oldtests +if [ -n "$testrevision" ] ; then + zip -r "oldtests/$testrevision.zip" tests/* fi diff --git a/examples/aplusb/compare b/examples/aplusb/compare index 6a81689..d6d0498 100755 --- a/examples/aplusb/compare +++ b/examples/aplusb/compare @@ -1,18 +1,28 @@ #!/bin/bash # -# compare -s "s1 s2" -s s3 -c "c1 c2" -c c3 compares sources s1, s2, s3 with configurations c1 c2 c3 until they diverge +# compares sources # Tamio-Vesa Nakajima -source lib +problemname="" +timelimit="" + +# shellcheck disable=SC1091 source problemconfig +if [ -z "$problemname" ] || [ -z "$timelimit" ] ; then + echo Bad config file + exit 1 +fi + srcs="" configs="" while getopts "hs:c:" opt ; do case $opt in h) - echo "Usage: ./compare -s \"source1\" -s \"source2\" -c \"config1\" \"config2\"" + echo "Usage: ./compare -s SRC1 ... -s SRCn -c CONF1 ... -c CONFm" + echo " -s SRC1 ... -s SRCn -- compares SRC1 to ... to SRCn" + echo " -c CONF1 ... -s CONm -- using config files CONF1 ... CONFm" exit 0 ;; s) @@ -21,68 +31,72 @@ while getopts "hs:c:" opt ; do c) configs="$configs $OPTARG" ;; + *) + echo Bad options + exit 1 + ;; esac done if [ -z "$srcs" ] ; then - echo No sources provided + echo No sources provided >&2 exit 1 fi if [ -z "$configs" ] ; then - echo No configs provided + echo No configs provided >&2 exit 1 fi -srcs_arr=($srcs) +# shellcheck disable=SC2086 +srcs_arr=() +read -a srcs_arr -r <<< "$srcs" nr_srcs=${#srcs_arr[@]} outputs_arr=() binary_arr=() -input_file=`mktemp` -for i in `seq 0 $(($nr_srcs-1))` ; do - outputs_arr[$i]=`mktemp` - binary_arr[$i]=`mktemp` +for ((i=0; i /dev/null - echo -en " \r" - echo Doing test $curr_test - curr_test=$(($curr_test + 1)) + echo -en " \\r" >&2 + echo Doing test $curr_test >&2 + curr_test=$((curr_test + 1)) - build_test_number 999 $conf + ./lib/build_test_number 999 "$conf" hasTle=false - for i in `seq 0 $(($nr_srcs-1))` ; do - run_src_test ${binary_arr[$i]} $problemname-999 + for((i=0; i $timelimit" | bc -l ) )) ; then hasTle=true fi - - cp stage/$problemname.out ${outputs_arr[$i]} done + + # shellcheck disable=SC2086 if [ $hasTle = true ] || ! diff --from-file ${outputs_arr[*]} > /dev/null ; then - echo -en " \r" - echo Has failed on: + echo -en " \\r" >&2 + echo Has failed on: >&2 cat tests/$problemname-999.in - echo With outputs: - for i in `seq 0 $(($nr_srcs-1))` ; do - echo ${srcs_arr[$i]}: + echo With outputs: >&2 + for((i=0 ; i&2 cat ${outputs_arr[$i]} - echo + echo >&2 done exit 0 fi diff --git a/examples/aplusb/eval/eval.bin b/examples/aplusb/eval/eval.bin deleted file mode 100755 index c3c63e4..0000000 Binary files a/examples/aplusb/eval/eval.bin and /dev/null differ diff --git a/examples/aplusb/incf/fixed b/examples/aplusb/incf/fixed index 4271727..722ff38 100644 --- a/examples/aplusb/incf/fixed +++ b/examples/aplusb/incf/fixed @@ -1 +1 @@ -1 0 0 +1 0 1 diff --git a/examples/aplusb/incf/fixed2 b/examples/aplusb/incf/fixed2 deleted file mode 100644 index 8cd5e6d..0000000 --- a/examples/aplusb/incf/fixed2 +++ /dev/null @@ -1 +0,0 @@ -1 100 200 diff --git a/examples/aplusb/src/makefile b/examples/aplusb/incf/makefile similarity index 100% rename from examples/aplusb/src/makefile rename to examples/aplusb/incf/makefile diff --git a/examples/aplusb/ingen/ingen.bin b/examples/aplusb/ingen/ingen.bin deleted file mode 100755 index 40aa67d..0000000 Binary files a/examples/aplusb/ingen/ingen.bin and /dev/null differ diff --git a/examples/aplusb/ingen/ingen.cpp b/examples/aplusb/ingen/ingen.cpp index 223d9c2..800845e 100644 --- a/examples/aplusb/ingen/ingen.cpp +++ b/examples/aplusb/ingen/ingen.cpp @@ -1,6 +1,5 @@ #include #include -#include using namespace std; int main(){ @@ -10,9 +9,7 @@ int main(){ int x, y; f >> fixed >> x >> y; - if(fixed){ - g << x << ' ' << y << endl; - } + if(fixed) g << x << ' ' << y << endl; else{ unsigned seed1 = std::chrono::system_clock::now().time_since_epoch().count(); srand(seed1); diff --git a/examples/aplusb/lib b/examples/aplusb/lib deleted file mode 100644 index e8bf9c7..0000000 --- a/examples/aplusb/lib +++ /dev/null @@ -1,129 +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 -} - -# Builds test number $1 with incf $2 -build_test_number () { - source problemconfig - - nr=$1 - incf=$2 - - # Build input generator - cd ingen && make -s && cd .. - - # Copy ingen/ingen.bin and incf/$1 into stage - cp ingen/ingen.bin stage/$problemname.bin - cp incf/$incf stage/$problemname.cf - - # Build input - cd stage && ./$problemname.bin && cp $problemname.in ../tests/$problemname-$nr.in && cd .. - - # Clean stage - rm stage/* 2> /dev/null - -} - -# 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 - - # Get an appropriate timeout command - timeoutCommand=timeout - - if [[ "$OSTYPE" == "darwin"* ]] ; then - timeoutCommand=gtimeout - fi - - # Fetch the problem configuration - source problemconfig - - # clear any previous messages - echo -en "\r \r" - - # Output an appropriate messgae - echo -en "Doing $testname\r" - - # Clean the stage - rm stage/* 2> /dev/null - - # 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 - - # 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 ..) -} - -# 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 - 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/aplusb/lib/build_ok_number b/examples/aplusb/lib/build_ok_number new file mode 100755 index 0000000..fd4d406 --- /dev/null +++ b/examples/aplusb/lib/build_ok_number @@ -0,0 +1,39 @@ +#!/bin/bash +# + +# include the configuration +problemname="" +timelimit="" + +# shellcheck disable=SC1091 +source problemconfig + +if [ -z "$problemname" ] || [ -z "$timelimit" ] ; then + echo Bad config file + exit 1 +fi + +nr="$1" +points="$2" + +# make a stage +stage=$(mktemp -d) + +# 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 +currdir=$PWD +cd "$stage" || exit +./"$problemname.bin" +cd "$currdir" || exit + +# Copy ok from stage into tests +cp "$stage/$problemname.ok" "tests/$problemname-$nr.ok" + +# Clean stage +rm -rf "$stage" diff --git a/examples/aplusb/lib/build_test_number b/examples/aplusb/lib/build_test_number new file mode 100755 index 0000000..e6a8d39 --- /dev/null +++ b/examples/aplusb/lib/build_test_number @@ -0,0 +1,40 @@ +#!/bin/bash +# +# Tamio-Vesa Nakajima +# Builds test number $1 with incf $2 + + +# include the configuration +problemname="" +timelimit="" + +# shellcheck disable=SC1091 +source problemconfig + +if [ -z "$problemname" ] || [ -z "$timelimit" ] ; then + echo Bad config file + exit 1 +fi + +nr=$1 +incf=$2 + +# Build input generator +cd ingen && make -s && cd .. + +# Make a stage +stage=$(mktemp -d) + +# Copy ingen/ingen.bin and incf/$1 into stage +cp ingen/ingen.bin "$stage/$problemname.bin" +cp "incf/$incf" "$stage/$problemname.cf" + +# Build input +currdir=$PWD +cd "$stage" || exit +./"$problemname.bin" +cp "$problemname.in" "$currdir/tests/$problemname-$nr.in" +cd "$currdir" || exit + +# Clean stage +rm -rf "$stage" diff --git a/examples/aplusb/lib/evaluate_src_test b/examples/aplusb/lib/evaluate_src_test new file mode 100755 index 0000000..414016f --- /dev/null +++ b/examples/aplusb/lib/evaluate_src_test @@ -0,0 +1,60 @@ +#!/bin/bash +# +# Tamio-Vesa Nakajima +# Evaluates the binary $1 with test $2, returning the message in $message, the time used in $timeUsed and the points in $points + +# include the configuration +problemname="" +timelimit="" + +# shellcheck disable=SC1091 +source problemconfig + +if [ -z "$problemname" ] || [ -z "$timelimit" ] ; then + echo Bad config file + exit 1 +fi + +binary=$1 +testname=$2 +output_location=$(mktemp) +timeUsed=$(./lib/run_src_test "$output_location" "$binary" "$testname") + +if (( $(echo "$timeUsed > $timelimit" | bc -l))) ; then + # Set the return values + # timeUsed is already set + message=TLE + points=0 +elif [ ! -e "$output_location" ] ; then + message="MissingOutput" + points=0 +else + # Make a stage + stage=$(mktemp -d) + + # Move output into stage + mv "$output_location" "$stage/$problemname.out" + + # 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 + curr_file=$PWD + cd "$stage" || exit + ./eval.bin > "$pointsFile" 2> "$messageFile" + cd "$curr_file" || exit + + # Set the return values + # timeUsed is already set + points=$(cat "$pointsFile") + message=$(cat "$messageFile") +fi + +echo "$message" "$timeUsed" "$points" diff --git a/examples/aplusb/lib/run_src_test b/examples/aplusb/lib/run_src_test new file mode 100755 index 0000000..f3d7a5c --- /dev/null +++ b/examples/aplusb/lib/run_src_test @@ -0,0 +1,64 @@ +#!/bin/bash +# +# Run the binary $2 with test $3, returning the time used stdout, and leaving the output file in $1 +output_location="$1" +binary=$2 +testname=$3 + +# include the configuration +problemname="" +timelimit="" + +# shellcheck disable=SC1091 +source problemconfig + +if [ -z "$problemname" ] || [ -z "$timelimit" ] ; then + echo Bad config file + exit 1 +fi + +# Get an appropriate timeout command +timeoutCommand=timeout + +if [[ "$OSTYPE" == "darwin"* ]] ; then + timeoutCommand=gtimeout +fi + +# clear any previous messages +echo -en "\\r \\r" >&2 + +# Output an appropriate messgae +echo -en "Doing $testname \\r" >&2 + +# Make a stage +stage=$(mktemp -d) + +# Copy the binary into the stage +cp "$binary" "$stage/$problemname.bin" + +# Copy the input into the stage +cp "tests/$testname.in" "$stage/$problemname.in" + +# This string runs the competitor's executable +runExec="./$problemname.bin" + +# 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 +curr_dirr=$PWD +cd "$stage" || exit +timeUsed=$({ time $runExecWithTimeout ; } 2>&1 >/dev/null \ + | awk -F ' ' '{ if($1=="user" || $1 == "sys") { print $2 } }' \ + | awk -F 'm' '{print $2}' \ + | awk -F 's' '{print $1}' \ + | awk 'BEGIN { total = 0; } { total += $1; } END { print total; }' ) +cd "$curr_dirr" || exit + + +cp "$stage/$problemname.out" "$output_location" 2> /dev/null + +echo "$timeUsed" + +rm -rf "$stage" diff --git a/examples/aplusb/okgen/okgen.bin b/examples/aplusb/okgen/okgen.bin deleted file mode 100755 index 0b4dca0..0000000 Binary files a/examples/aplusb/okgen/okgen.bin and /dev/null differ diff --git a/examples/aplusb/oldtests/.zip b/examples/aplusb/oldtests/.zip deleted file mode 100644 index 850c4be..0000000 Binary files a/examples/aplusb/oldtests/.zip and /dev/null differ diff --git a/examples/aplusb/oldtests/asdfjkl;.zip b/examples/aplusb/oldtests/asdfjkl;.zip deleted file mode 100644 index be9054b..0000000 Binary files a/examples/aplusb/oldtests/asdfjkl;.zip and /dev/null differ diff --git a/examples/aplusb/oldtests/big.zip b/examples/aplusb/oldtests/big.zip deleted file mode 100644 index 4417302..0000000 Binary files a/examples/aplusb/oldtests/big.zip and /dev/null differ diff --git a/examples/aplusb/oldtests/first.zip b/examples/aplusb/oldtests/first.zip deleted file mode 100644 index 700c671..0000000 Binary files a/examples/aplusb/oldtests/first.zip and /dev/null differ diff --git a/examples/aplusb/oldtests/frths.zip b/examples/aplusb/oldtests/frths.zip deleted file mode 100644 index 2175ab4..0000000 Binary files a/examples/aplusb/oldtests/frths.zip and /dev/null differ diff --git a/examples/aplusb/oldtests/lll.zip b/examples/aplusb/oldtests/lll.zip deleted file mode 100644 index 8156fa4..0000000 Binary files a/examples/aplusb/oldtests/lll.zip and /dev/null differ diff --git a/examples/aplusb/oldtests/ls.zip b/examples/aplusb/oldtests/ls.zip deleted file mode 100644 index 842136c..0000000 Binary files a/examples/aplusb/oldtests/ls.zip and /dev/null differ diff --git a/examples/aplusb/oldtests/newtests.zip b/examples/aplusb/oldtests/newtests.zip deleted file mode 100644 index c8cb9ae..0000000 Binary files a/examples/aplusb/oldtests/newtests.zip and /dev/null differ diff --git a/examples/aplusb/oldtests/newtests2.zip b/examples/aplusb/oldtests/newtests2.zip deleted file mode 100644 index 9756376..0000000 Binary files a/examples/aplusb/oldtests/newtests2.zip and /dev/null differ diff --git a/examples/aplusb/oldtests/second.zip b/examples/aplusb/oldtests/second.zip deleted file mode 100644 index 7e0ff38..0000000 Binary files a/examples/aplusb/oldtests/second.zip and /dev/null differ diff --git a/examples/aplusb/oldtests/snd.zip b/examples/aplusb/oldtests/snd.zip deleted file mode 100644 index e544d0e..0000000 Binary files a/examples/aplusb/oldtests/snd.zip and /dev/null differ diff --git a/examples/aplusb/oldtests/thrd.zip b/examples/aplusb/oldtests/thrd.zip deleted file mode 100644 index 1db81d2..0000000 Binary files a/examples/aplusb/oldtests/thrd.zip and /dev/null differ diff --git a/examples/aplusb/problemconfig b/examples/aplusb/problemconfig index 6cfe193..61253ac 100644 --- a/examples/aplusb/problemconfig +++ b/examples/aplusb/problemconfig @@ -1,2 +1,2 @@ problemname=aplusb -timelimit=0.1 +timelimit=1 diff --git a/examples/aplusb/run b/examples/aplusb/run index 1289837..3562e21 100755 --- a/examples/aplusb/run +++ b/examples/aplusb/run @@ -2,106 +2,154 @@ # # 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 -######################### +################################# +# Build necesisties +################################# + +cd eval || exit +make -s +cd .. || exit + +cd okgen || exit +make -s +cd .. || exit -# include the library -source lib +cd ingen || exit +make -s +cd .. || exit -# include the configuration +################################# +# PROBLEM CONFIGURATION +################################# + +# initialize problemconfig variables +problemname="" +timelimit="" + +# shellcheck disable=SC1091 source problemconfig -# make stage (as git deletes it) -mkdir -p stage +# Check if problemconfig variables are set +if [ -z "$problemname" ] || [ -z "$timelimit" ] ; then + echo Bad config file + exit 1 +fi ############################ # ARGUMENT PARSING ############################# +run_in_parallel=false + # default values for used sources and used tests -srcs="" -tests="" +srcs=() +tests=() -while getopts "hs:t:" opt; do +while getopts "hs:t:p" opt; do case $opt in h) - echo "Usage: ./run -s [source] -t [test]" + echo "Usage: ./run [-s SRC1] ... [-s SRCn] [-t TEST1] ... [-t TESTm] [-p]" + echo " -s SRC1 ... -s SRCn -- run SRC1 ... SRCn ; if no -s is included, run all sources" + echo " -t TEST1 ... -t TESTm -- run on TEST1 ... TESTm ; if no -t is included, run on all tests" + echo " -p -- run all sources in parallel" exit 0 ;; s) for x in $OPTARG ; do - srcs="$srcs $x" + srcs+=("$x") done ;; t) for x in $OPTARG ; do - tests="$tests $problemname-$x" + tests+=("$problemname-$x") done ;; + p) + run_in_parallel=true + ;; + *) + echo Bad option + exit 1 + ;; esac done -if [ -z "$srcs" ] ; then - srcs=`ls -1 src | grep .cpp` +if [ ${#src[@]} -eq 0 ] ; then + cd src || exit + srcs=(*) + cd .. || exit fi -if [ -z "$tests" ] ; then - tests=`ls -1 tests | grep .in | awk -F '.' '{print $1}'` +if [ ${#tests[@]} -eq 0 ] ; then + cd tests || exit + for x in *.in ; do + tests+=( "$( echo "$x" | cut -f 1 -d '.')" ) + done + cd .. || exit fi -tests=`echo $tests | sort -t '-' -k 1 -n` - - ########################### # EVALUATING ########################## -for src in $srcs ; do +for src in "${srcs[@]}" ; do + # Make a stage + stage=$(mktemp -d) + # Copy the source into the stage - try "cp src/$src stage/$problemname.cpp" "source file missing" + cp "src/$src" "$stage/$problemname.cpp" # Create a temporary file to hold the problem binary - binary=`mktemp` + binary=$(mktemp) # Build the source - try "g++ stage/$problemname.cpp -std=c++11 -o $binary -O2" "Compile error" + g++ "$stage/$problemname.cpp" -std=c++11 -o "$binary" -O2 + + # Delete the stage + rm -rf "$stage" # Make a temporary file to hold the table: - table=`mktemp` + table=$(mktemp) # $table holds the score table - echo $src > $table - echo Test Message Time Points >> $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 + for testname in "${tests[@]}" ; do + fun (){ + # evaluate $binary on $testname, setting $message, $timeUsed, $points + set "$(./lib/evaluate_src_test "$binary" "$testname")" + message=$1 + timeUsed=$2 + points=$3 + + echo "$testname.in" "$message" "$timeUsed" "$points" >> "$table" + } + if [ "$run_in_parallel" == "true" ] ; then + ( fun ) & + else + fun + fi done + if [ "$run_in_parallel" == "true" ] ; then + wait + fi + # Clear "Doing test ..." - echo -en "\r \r" + echo -en "\\r \\r" >&2 # Output the table - column -t $table + column -t "$table" # Calculate the score - echo SCORE: `awk -F ' ' '$1 != "Test" {sum += 0 $4} END {print sum}' $table` + echo SCORE: "$(awk -F ' ' '$1 != "Test" {sum += 0 $4} END {print sum}' "$table")" >&2 # Clear the temporary files - rm $table - rm $binary + rm "$table" + rm "$binary" - # And the stage - rm stage/* done diff --git a/examples/aplusb/src/almost_ok.cpp b/examples/aplusb/src/almost_ok.cpp index 9464e09..475adf6 100644 --- a/examples/aplusb/src/almost_ok.cpp +++ b/examples/aplusb/src/almost_ok.cpp @@ -6,6 +6,6 @@ int main(){ ofstream g("aplusb.out"); long long x, y; f >> x >> y; - if((x+y)%100 == 0) g << -1 << endl; + if((x+y)%10 == 0) g << -1 << endl; else g << x+y << endl; return 0; } diff --git a/examples/aplusb/src/wa.cpp b/examples/aplusb/src/wa.cpp index 7134bde..e06c3ea 100644 --- a/examples/aplusb/src/wa.cpp +++ b/examples/aplusb/src/wa.cpp @@ -4,4 +4,5 @@ using namespace std; int main(){ ofstream g("aplusb.out"); - g << -1 << endl; } + g << -1; +} diff --git a/examples/aplusb/stage/aplusb.bin b/examples/aplusb/stage/aplusb.bin deleted file mode 100755 index 51e0c25..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 ac00f99..0000000 --- a/examples/aplusb/stage/aplusb.in +++ /dev/null @@ -1 +0,0 @@ -468168176 122451424 diff --git a/examples/aplusb/stage/aplusb.out b/examples/aplusb/stage/aplusb.out deleted file mode 100644 index 3a2e3f4..0000000 --- a/examples/aplusb/stage/aplusb.out +++ /dev/null @@ -1 +0,0 @@ --1 diff --git a/examples/aplusb/testmanifest b/examples/aplusb/testmanifest index 9e68729..83d2d86 100644 --- a/examples/aplusb/testmanifest +++ b/examples/aplusb/testmanifest @@ -1,3 +1,2 @@ 1 fixed 10 -1 fixed2 10 18 random 90 diff --git a/examples/aplusb/tests/aplusb-0.in b/examples/aplusb/tests/aplusb-0.in deleted file mode 100644 index 65cd68b..0000000 --- a/examples/aplusb/tests/aplusb-0.in +++ /dev/null @@ -1 +0,0 @@ -0 2 diff --git a/examples/aplusb/tests/aplusb-0.ok b/examples/aplusb/tests/aplusb-0.ok deleted file mode 100644 index 77f4b16..0000000 --- a/examples/aplusb/tests/aplusb-0.ok +++ /dev/null @@ -1,2 +0,0 @@ -10 -2 diff --git a/examples/aplusb/tests/aplusb-1.in b/examples/aplusb/tests/aplusb-1.in deleted file mode 100644 index 10ec153..0000000 --- a/examples/aplusb/tests/aplusb-1.in +++ /dev/null @@ -1 +0,0 @@ -100 200 diff --git a/examples/aplusb/tests/aplusb-1.ok b/examples/aplusb/tests/aplusb-1.ok deleted file mode 100644 index 222b847..0000000 --- a/examples/aplusb/tests/aplusb-1.ok +++ /dev/null @@ -1,2 +0,0 @@ -10 -300 diff --git a/examples/aplusb/tests/aplusb-10.in b/examples/aplusb/tests/aplusb-10.in deleted file mode 100644 index 32ce837..0000000 --- a/examples/aplusb/tests/aplusb-10.in +++ /dev/null @@ -1 +0,0 @@ -1405884291 2082194543 diff --git a/examples/aplusb/tests/aplusb-10.ok b/examples/aplusb/tests/aplusb-10.ok deleted file mode 100644 index 275004c..0000000 --- a/examples/aplusb/tests/aplusb-10.ok +++ /dev/null @@ -1,2 +0,0 @@ -5 -3488078834 diff --git a/examples/aplusb/tests/aplusb-11.in b/examples/aplusb/tests/aplusb-11.in deleted file mode 100644 index 32ce837..0000000 --- a/examples/aplusb/tests/aplusb-11.in +++ /dev/null @@ -1 +0,0 @@ -1405884291 2082194543 diff --git a/examples/aplusb/tests/aplusb-11.ok b/examples/aplusb/tests/aplusb-11.ok deleted file mode 100644 index 275004c..0000000 --- a/examples/aplusb/tests/aplusb-11.ok +++ /dev/null @@ -1,2 +0,0 @@ -5 -3488078834 diff --git a/examples/aplusb/tests/aplusb-12.in b/examples/aplusb/tests/aplusb-12.in deleted file mode 100644 index 32ce837..0000000 --- a/examples/aplusb/tests/aplusb-12.in +++ /dev/null @@ -1 +0,0 @@ -1405884291 2082194543 diff --git a/examples/aplusb/tests/aplusb-12.ok b/examples/aplusb/tests/aplusb-12.ok deleted file mode 100644 index 275004c..0000000 --- a/examples/aplusb/tests/aplusb-12.ok +++ /dev/null @@ -1,2 +0,0 @@ -5 -3488078834 diff --git a/examples/aplusb/tests/aplusb-13.in b/examples/aplusb/tests/aplusb-13.in deleted file mode 100644 index 32ce837..0000000 --- a/examples/aplusb/tests/aplusb-13.in +++ /dev/null @@ -1 +0,0 @@ -1405884291 2082194543 diff --git a/examples/aplusb/tests/aplusb-13.ok b/examples/aplusb/tests/aplusb-13.ok deleted file mode 100644 index 275004c..0000000 --- a/examples/aplusb/tests/aplusb-13.ok +++ /dev/null @@ -1,2 +0,0 @@ -5 -3488078834 diff --git a/examples/aplusb/tests/aplusb-14.in b/examples/aplusb/tests/aplusb-14.in deleted file mode 100644 index 32ce837..0000000 --- a/examples/aplusb/tests/aplusb-14.in +++ /dev/null @@ -1 +0,0 @@ -1405884291 2082194543 diff --git a/examples/aplusb/tests/aplusb-14.ok b/examples/aplusb/tests/aplusb-14.ok deleted file mode 100644 index 275004c..0000000 --- a/examples/aplusb/tests/aplusb-14.ok +++ /dev/null @@ -1,2 +0,0 @@ -5 -3488078834 diff --git a/examples/aplusb/tests/aplusb-15.in b/examples/aplusb/tests/aplusb-15.in deleted file mode 100644 index 32ce837..0000000 --- a/examples/aplusb/tests/aplusb-15.in +++ /dev/null @@ -1 +0,0 @@ -1405884291 2082194543 diff --git a/examples/aplusb/tests/aplusb-15.ok b/examples/aplusb/tests/aplusb-15.ok deleted file mode 100644 index 275004c..0000000 --- a/examples/aplusb/tests/aplusb-15.ok +++ /dev/null @@ -1,2 +0,0 @@ -5 -3488078834 diff --git a/examples/aplusb/tests/aplusb-16.in b/examples/aplusb/tests/aplusb-16.in deleted file mode 100644 index 32ce837..0000000 --- a/examples/aplusb/tests/aplusb-16.in +++ /dev/null @@ -1 +0,0 @@ -1405884291 2082194543 diff --git a/examples/aplusb/tests/aplusb-16.ok b/examples/aplusb/tests/aplusb-16.ok deleted file mode 100644 index 275004c..0000000 --- a/examples/aplusb/tests/aplusb-16.ok +++ /dev/null @@ -1,2 +0,0 @@ -5 -3488078834 diff --git a/examples/aplusb/tests/aplusb-17.in b/examples/aplusb/tests/aplusb-17.in deleted file mode 100644 index 32ce837..0000000 --- a/examples/aplusb/tests/aplusb-17.in +++ /dev/null @@ -1 +0,0 @@ -1405884291 2082194543 diff --git a/examples/aplusb/tests/aplusb-17.ok b/examples/aplusb/tests/aplusb-17.ok deleted file mode 100644 index 275004c..0000000 --- a/examples/aplusb/tests/aplusb-17.ok +++ /dev/null @@ -1,2 +0,0 @@ -5 -3488078834 diff --git a/examples/aplusb/tests/aplusb-18.in b/examples/aplusb/tests/aplusb-18.in deleted file mode 100644 index ca06237..0000000 --- a/examples/aplusb/tests/aplusb-18.in +++ /dev/null @@ -1 +0,0 @@ -1405901098 217186145 diff --git a/examples/aplusb/tests/aplusb-18.ok b/examples/aplusb/tests/aplusb-18.ok deleted file mode 100644 index 9391515..0000000 --- a/examples/aplusb/tests/aplusb-18.ok +++ /dev/null @@ -1,2 +0,0 @@ -5 -1623087243 diff --git a/examples/aplusb/tests/aplusb-19.in b/examples/aplusb/tests/aplusb-19.in deleted file mode 100644 index ca06237..0000000 --- a/examples/aplusb/tests/aplusb-19.in +++ /dev/null @@ -1 +0,0 @@ -1405901098 217186145 diff --git a/examples/aplusb/tests/aplusb-19.ok b/examples/aplusb/tests/aplusb-19.ok deleted file mode 100644 index 9391515..0000000 --- a/examples/aplusb/tests/aplusb-19.ok +++ /dev/null @@ -1,2 +0,0 @@ -5 -1623087243 diff --git a/examples/aplusb/tests/aplusb-2.in b/examples/aplusb/tests/aplusb-2.in deleted file mode 100644 index 3cb1cbe..0000000 --- a/examples/aplusb/tests/aplusb-2.in +++ /dev/null @@ -1 +0,0 @@ -1405867484 1799719294 diff --git a/examples/aplusb/tests/aplusb-2.ok b/examples/aplusb/tests/aplusb-2.ok deleted file mode 100644 index 4919a58..0000000 --- a/examples/aplusb/tests/aplusb-2.ok +++ /dev/null @@ -1,2 +0,0 @@ -5 -3205586778 diff --git a/examples/aplusb/tests/aplusb-3.in b/examples/aplusb/tests/aplusb-3.in deleted file mode 100644 index 3cb1cbe..0000000 --- a/examples/aplusb/tests/aplusb-3.in +++ /dev/null @@ -1 +0,0 @@ -1405867484 1799719294 diff --git a/examples/aplusb/tests/aplusb-3.ok b/examples/aplusb/tests/aplusb-3.ok deleted file mode 100644 index 4919a58..0000000 --- a/examples/aplusb/tests/aplusb-3.ok +++ /dev/null @@ -1,2 +0,0 @@ -5 -3205586778 diff --git a/examples/aplusb/tests/aplusb-4.in b/examples/aplusb/tests/aplusb-4.in deleted file mode 100644 index 3cb1cbe..0000000 --- a/examples/aplusb/tests/aplusb-4.in +++ /dev/null @@ -1 +0,0 @@ -1405867484 1799719294 diff --git a/examples/aplusb/tests/aplusb-4.ok b/examples/aplusb/tests/aplusb-4.ok deleted file mode 100644 index 4919a58..0000000 --- a/examples/aplusb/tests/aplusb-4.ok +++ /dev/null @@ -1,2 +0,0 @@ -5 -3205586778 diff --git a/examples/aplusb/tests/aplusb-5.in b/examples/aplusb/tests/aplusb-5.in deleted file mode 100644 index 3cb1cbe..0000000 --- a/examples/aplusb/tests/aplusb-5.in +++ /dev/null @@ -1 +0,0 @@ -1405867484 1799719294 diff --git a/examples/aplusb/tests/aplusb-5.ok b/examples/aplusb/tests/aplusb-5.ok deleted file mode 100644 index 4919a58..0000000 --- a/examples/aplusb/tests/aplusb-5.ok +++ /dev/null @@ -1,2 +0,0 @@ -5 -3205586778 diff --git a/examples/aplusb/tests/aplusb-6.in b/examples/aplusb/tests/aplusb-6.in deleted file mode 100644 index 3cb1cbe..0000000 --- a/examples/aplusb/tests/aplusb-6.in +++ /dev/null @@ -1 +0,0 @@ -1405867484 1799719294 diff --git a/examples/aplusb/tests/aplusb-6.ok b/examples/aplusb/tests/aplusb-6.ok deleted file mode 100644 index 4919a58..0000000 --- a/examples/aplusb/tests/aplusb-6.ok +++ /dev/null @@ -1,2 +0,0 @@ -5 -3205586778 diff --git a/examples/aplusb/tests/aplusb-7.in b/examples/aplusb/tests/aplusb-7.in deleted file mode 100644 index 3cb1cbe..0000000 --- a/examples/aplusb/tests/aplusb-7.in +++ /dev/null @@ -1 +0,0 @@ -1405867484 1799719294 diff --git a/examples/aplusb/tests/aplusb-7.ok b/examples/aplusb/tests/aplusb-7.ok deleted file mode 100644 index 4919a58..0000000 --- a/examples/aplusb/tests/aplusb-7.ok +++ /dev/null @@ -1,2 +0,0 @@ -5 -3205586778 diff --git a/examples/aplusb/tests/aplusb-8.in b/examples/aplusb/tests/aplusb-8.in deleted file mode 100644 index 3cb1cbe..0000000 --- a/examples/aplusb/tests/aplusb-8.in +++ /dev/null @@ -1 +0,0 @@ -1405867484 1799719294 diff --git a/examples/aplusb/tests/aplusb-8.ok b/examples/aplusb/tests/aplusb-8.ok deleted file mode 100644 index 4919a58..0000000 --- a/examples/aplusb/tests/aplusb-8.ok +++ /dev/null @@ -1,2 +0,0 @@ -5 -3205586778 diff --git a/examples/aplusb/tests/aplusb-9.in b/examples/aplusb/tests/aplusb-9.in deleted file mode 100644 index 3cb1cbe..0000000 --- a/examples/aplusb/tests/aplusb-9.in +++ /dev/null @@ -1 +0,0 @@ -1405867484 1799719294 diff --git a/examples/aplusb/tests/aplusb-9.ok b/examples/aplusb/tests/aplusb-9.ok deleted file mode 100644 index 4919a58..0000000 --- a/examples/aplusb/tests/aplusb-9.ok +++ /dev/null @@ -1,2 +0,0 @@ -5 -3205586778 diff --git a/examples/xxx/eval/makefile b/examples/xxx/eval/makefile deleted file mode 100644 index e69de29..0000000 diff --git a/examples/xxx/incf/makefile b/examples/xxx/incf/makefile deleted file mode 100644 index e69de29..0000000 diff --git a/examples/xxx/ingen/makefile b/examples/xxx/ingen/makefile deleted file mode 100644 index e69de29..0000000 diff --git a/examples/xxx/okgen/makefile b/examples/xxx/okgen/makefile deleted file mode 100644 index e69de29..0000000 diff --git a/examples/xxx/problemconfig b/examples/xxx/problemconfig deleted file mode 100644 index 35b1076..0000000 --- a/examples/xxx/problemconfig +++ /dev/null @@ -1,2 +0,0 @@ -problemname=xxx -timelimit=1 diff --git a/examples/xxx/src/buildtests b/examples/xxx/src/buildtests deleted file mode 100755 index 5c912ce..0000000 --- a/examples/xxx/src/buildtests +++ /dev/null @@ -1,89 +0,0 @@ -#!/bin/bash -# -# This builds all tests using testmanifest -# Tamio-Vesa Nakajima - -# include the library -source lib - -# include the configuration -source problemconfig - -############################ -# ARGUMENT PARSING -############################# - -rebuild_inputs=true - -while getopts "r:ho" 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 - ;; - o) - rebuild_inputs=false - ;; - esac -done - -read -p "Name of this test revision: " testrevision - -# 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: - ################# - - if [ $rebuild_inputs = true ] ; then - ./lib/build_test_number $nr $incf - fi - - ################### - # Build ok - ################### - - # Build ok generator - cd okgen && make -s && cd .. - - # 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 - cd stage && ./$problemname.bin && cd .. - - # 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 - -if [ -n $testrevision ] ; then - zip -r oldtests/$testrevision.zip tests/* -fi diff --git a/examples/xxx/src/compare b/examples/xxx/src/compare deleted file mode 100755 index 6a81689..0000000 --- a/examples/xxx/src/compare +++ /dev/null @@ -1,90 +0,0 @@ -#!/bin/bash -# -# compare -s "s1 s2" -s s3 -c "c1 c2" -c c3 compares sources s1, s2, s3 with configurations c1 c2 c3 until they diverge -# Tamio-Vesa Nakajima - -source lib -source problemconfig - -srcs="" -configs="" - -while getopts "hs:c:" opt ; do - case $opt in - h) - echo "Usage: ./compare -s \"source1\" -s \"source2\" -c \"config1\" \"config2\"" - exit 0 - ;; - s) - srcs="$srcs $OPTARG" - ;; - c) - configs="$configs $OPTARG" - ;; - esac -done - -if [ -z "$srcs" ] ; then - echo No sources provided - exit 1 -fi - -if [ -z "$configs" ] ; then - echo No configs provided - exit 1 -fi - -srcs_arr=($srcs) -nr_srcs=${#srcs_arr[@]} -outputs_arr=() -binary_arr=() -input_file=`mktemp` - -for i in `seq 0 $(($nr_srcs-1))` ; do - outputs_arr[$i]=`mktemp` - binary_arr[$i]=`mktemp` -done - -for i in `seq 0 $(($nr_srcs-1))` ; do - g++ src/${srcs_arr[$i]} -std=c++11 -O2 -o ${binary_arr[$i]} -done - -curr_test=0 - -path_to_tests=`realpath tests` -trap "rm $path_to_tests/$problemname-999.in" EXIT - -while : ; do - for conf in $configs ; do - rm stage/* 2> /dev/null - echo -en " \r" - echo Doing test $curr_test - curr_test=$(($curr_test + 1)) - - build_test_number 999 $conf - - hasTle=false - - for i in `seq 0 $(($nr_srcs-1))` ; do - run_src_test ${binary_arr[$i]} $problemname-999 - - if (( $(echo "$timeUsed > $timelimit" | bc -l ) )) ; then - hasTle=true - fi - - cp stage/$problemname.out ${outputs_arr[$i]} - done - if [ $hasTle = true ] || ! diff --from-file ${outputs_arr[*]} > /dev/null ; then - echo -en " \r" - echo Has failed on: - cat tests/$problemname-999.in - echo With outputs: - for i in `seq 0 $(($nr_srcs-1))` ; do - echo ${srcs_arr[$i]}: - cat ${outputs_arr[$i]} - echo - done - exit 0 - fi - done -done diff --git a/examples/xxx/src/lib/build_test_number b/examples/xxx/src/lib/build_test_number deleted file mode 100755 index efd7bfa..0000000 --- a/examples/xxx/src/lib/build_test_number +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/bash -# -# Tamio-Vesa Nakajima -# Builds test number $1 with incf $2 -build_test_number () { - source problemconfig - - nr=$1 - incf=$2 - - # Build input generator - cd ingen && make -s && cd .. - - # Copy ingen/ingen.bin and incf/$1 into stage - cp ingen/ingen.bin stage/$problemname.bin - cp incf/$incf stage/$problemname.cf - - # Build input - cd stage && ./$problemname.bin && cp $problemname.in ../tests/$problemname-$nr.in && cd .. - - # Clean stage - rm stage/* 2> /dev/null - -} - - diff --git a/examples/xxx/src/lib/evaluate_src_test b/examples/xxx/src/lib/evaluate_src_test deleted file mode 100755 index fbf4038..0000000 --- a/examples/xxx/src/lib/evaluate_src_test +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/bash -# -# Tamio-Vesa Nakajima - -# 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 - - ./lib/run_src_test $binary $testname - if (( $(echo "$timeUsed > $timelimit" | bc -l))) ; then - # Set the return values - # timeUsed is already set - message=TLE - points=0 - else - # Make the evaluator - cd eval && make -s && cd .. - - # 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 - cd stage && ./eval.bin > $pointsFile 2> $messageFile && cd .. - - # Set the return values - # timeUsed is already set - points=`cat $pointsFile` - message=`cat $messageFile` - fi -} diff --git a/examples/xxx/src/lib/run_src_test b/examples/xxx/src/lib/run_src_test deleted file mode 100755 index 488cf7f..0000000 --- a/examples/xxx/src/lib/run_src_test +++ /dev/null @@ -1,51 +0,0 @@ -#!/bin/bash -# -# 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 - - # Get an appropriate timeout command - timeoutCommand=timeout - - if [[ "$OSTYPE" == "darwin"* ]] ; then - timeoutCommand=gtimeout - fi - - # Fetch the problem configuration - source problemconfig - - # clear any previous messages - echo -en "\r \r" - - # Output an appropriate messgae - echo -en "Doing $testname\r" - - # Clean the stage - rm stage/* 2> /dev/null - - # 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 - - # 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 ..) -} - - diff --git a/examples/xxx/src/makefile b/examples/xxx/src/makefile deleted file mode 100644 index e69de29..0000000 diff --git a/examples/xxx/src/run b/examples/xxx/src/run deleted file mode 100755 index 3e9943e..0000000 --- a/examples/xxx/src/run +++ /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 - -# include the configuration -source problemconfig - -# 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 -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 - cp src/$src stage/$problemname.cpp - - # Create a temporary file to hold the problem binary - binary=`mktemp` - - # Build the source - g++ stage/$problemname.cpp -std=c++11 -o $binary -O2 - - # 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 - ./lib/evaluate_src_test $binary $testname - echo $testname.in $message $timeUsed $points >> $table - done - - # Clear "Doing test ..." - echo -en "\r \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/xxx/src/todo b/examples/xxx/src/todo deleted file mode 100644 index 8f8b63e..0000000 --- a/examples/xxx/src/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/examples/xxx/testmanifest b/examples/xxx/testmanifest deleted file mode 100644 index e69de29..0000000 diff --git a/src/buildtests b/src/buildtests index e91383f..1287e8d 100755 --- a/src/buildtests +++ b/src/buildtests @@ -45,7 +45,9 @@ rebuild_inputs=true while getopts "r:ho" opt; do case $opt in h) # Help: - echo "Usage: ./run -r(estore) [revision to restore]" + echo "Usage: ./run [-r REVISION] [-o]" + echo " -r REVISION -- restores REVISION" + echo " -o -- rebuilds only the .ok files" exit 0 ;; r) # Restore old revision diff --git a/src/compare b/src/compare index 3e02187..d6d0498 100755 --- a/src/compare +++ b/src/compare @@ -1,6 +1,6 @@ #!/bin/bash # -# compare -s "s1 s2" -s s3 -c "c1 c2" -c c3 compares sources s1, s2, s3 with configurations c1 c2 c3 until they diverge +# compares sources # Tamio-Vesa Nakajima problemname="" @@ -20,7 +20,9 @@ configs="" while getopts "hs:c:" opt ; do case $opt in h) - echo "Usage: ./compare -s \"source1\" -s \"source2\" -c \"config1\" \"config2\"" >&2 + echo "Usage: ./compare -s SRC1 ... -s SRCn -c CONF1 ... -c CONFm" + echo " -s SRC1 ... -s SRCn -- compares SRC1 to ... to SRCn" + echo " -c CONF1 ... -s CONm -- using config files CONF1 ... CONFm" exit 0 ;; s) diff --git a/src/run b/src/run index 74cf583..3562e21 100755 --- a/src/run +++ b/src/run @@ -2,13 +2,6 @@ # # Runs sources on tests # Tamio-Vesa Nakajima -# -# Use cases: -# ./run -> runs all sources on all tests -# ./run -s "a.cpp b.cpp" -s c.cpp -> runs a,b,c.cpp on all tests -# ./run -t "00 01 02" -> runs all sources on tests 00, 01, 02 -# ./run -s a.cpp -t 00 -> runs a.cpp on 00 -# ./run -n ---- same as above, but without paralelism ################################# # Build necesisties @@ -57,7 +50,10 @@ tests=() while getopts "hs:t:p" opt; do case $opt in h) - echo "Usage: ./run -s [source] -t [test] -p [[if parallelism is desired]]" >&2 + echo "Usage: ./run [-s SRC1] ... [-s SRCn] [-t TEST1] ... [-t TESTm] [-p]" + echo " -s SRC1 ... -s SRCn -- run SRC1 ... SRCn ; if no -s is included, run all sources" + echo " -t TEST1 ... -t TESTm -- run on TEST1 ... TESTm ; if no -t is included, run on all tests" + echo " -p -- run all sources in parallel" exit 0 ;; s)