Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 40 additions & 25 deletions images/java/evaluate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,36 +32,51 @@ function cleanup() {
#
# output file = {id} + "-output.txt"

touch $1-code-output.txt

# compile the java file
javac $3/$1_main.$2
a = 1
flag = 0
while [-e "$3/$1-input/input-$a.txt" ]
do
touch $1-code-output.txt
javac $3/$1_main.$2

if [ $? != 0 ]; then
echo "compile failed"
cleanup $1 $3
exit
fi
res = $?

cd $3
# run the code and trap the output
java $1_main < $1-input.txt > ../$1-code-output.txt
if [ $? != 0 ]; then
echo "compile failed"
flag = 1
cleanup $1 $3
exit
fi

if [ $? != 0 ]; then
echo "run failed"
cleanup $1 $3
exit
fi
cd $3
# run the code and trap the output
java $1_main < $1-input-$a.txt > ../$1-code-output.txt

if [ $? != 0 ]; then
echo "run failed"
flag = 1
cleanup $1 $3
exit
fi

cd ..

cd ..
# Check if output matches
diff --strip-trailing-cr $1-code-output.txt $3/$1-output-$a.txt > $1-diff-messages.txt
if [ $? != 0 ]; then
echo "wrong output"
flag = 1
cleanup $1 $3
exit
fi

# Check if output matches
diff --strip-trailing-cr $1-code-output.txt $3/$1-output.txt > $1-diff-messages.txt
if [ $? != 0 ]; then
echo "wrong output"
cleanup $1 $3
exit
fi
a=$((a+1))
done



cleanup $1 $3
echo "successfully executed"
if [ $flag -eq 0 ]; then
echo "successfully executed"
fi
56 changes: 40 additions & 16 deletions images/pypy3/evaluate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,48 @@ function cleanup() {
#
# output file = {id} + "-output.txt"

touch $1-code-output.txt
a = 1
flag = 0
while [-e "$3/$1-input/input-$a.txt" ]
do
touch $1-code-output.txt

# Execute and trap output
pypy3 $3/$1-main.$2 < $3/$1-input.txt &> $1-code-output.txt
# Execute and trap output
timeout $4 pypy3 $3/$1-main.$2 < $3/$1-input-$a.txt &> $1-code-output.txt

if [ $? != 0 ]; then
echo "run failed"
cleanup $1
exit
fi
res=$?

if [ $res -eq 124 ]; then
echo "time limit exceeded on test $a"
cleanup $1
flag=1
exit
elif [ $res -eq 137 ]; then
echo "memory limit exceeded on test $a"
cleanup $1
flag=1
exit
elif [ $res != 0 ]; then
echo "run failed on test $a", $res
cleanup $1
flag=1
exit
fi

# Check if output matches
diff --strip-trailing-cr $1-code-output.txt $3/$1-output/output-$a.txt > $1-diff-messages.txt
if [ $? != 0 ]; then
echo "wrong output on test case $a"
cleanup $1
flag=1
exit
fi

# Check if output matches
diff $1-code-output.txt $3/$1-output.txt > $1-diff-messages.txt
if [ $? != 0 ]; then
echo "wrong output"
cleanup $1
exit
fi

cleanup $1
echo "successfully executed"
a=$((a+1))
done

if [ $flag -eq 0 ]; then
echo "successfully executed"
fi