]> mj.ucw.cz Git - eval.git/blobdiff - bin/lib
Split installation process.
[eval.git] / bin / lib
diff --git a/bin/lib b/bin/lib
index 48c1a8f254d0b21f37344c7589c67cef063accb1..27ea9b428420de5da78fe85cb20b1e007c451766 100644 (file)
--- a/bin/lib
+++ b/bin/lib
@@ -93,7 +93,7 @@ EOF
 
 function locate-source
 {
 
 function locate-source
 {
-       pstart "Locating source... "
+       pstart "Finding source... "
        for a in $EXTENSIONS ; do
                if [ -f $SDIR/$PROBLEM.$a ] ; then
                        [ -z "$SRCN" ] || die "Multiple source files found: $SDIR/$PROBLEM.$a and $SDIR/$SRCN. Please fix."
        for a in $EXTENSIONS ; do
                if [ -f $SDIR/$PROBLEM.$a ] ; then
                        [ -z "$SRCN" ] || die "Multiple source files found: $SDIR/$PROBLEM.$a and $SDIR/$SRCN. Please fix."
@@ -128,6 +128,7 @@ function compile
 
        echo "Compiler input files:"
        ls -Al $BOXDIR
 
        echo "Compiler input files:"
        ls -Al $BOXDIR
+       echo "Compiler output:"
        if ! $BOXCMD $COMP_SANDBOX_OPTS -- $CCMD 2>$TDIR/compile.out ; then
                COMPILE_MSG="`cat $TDIR/compile.out`"
                pend "FAILED: $COMPILE_MSG"
        if ! $BOXCMD $COMP_SANDBOX_OPTS -- $CCMD 2>$TDIR/compile.out ; then
                COMPILE_MSG="`cat $TDIR/compile.out`"
                pend "FAILED: $COMPILE_MSG"
@@ -151,13 +152,14 @@ function compile
 
 # Running of test program with file input/output
 
 
 # Running of test program with file input/output
 
-function test-run-with-files
+function test-run
 {
        pcont "<init> "
        box-clean
        echo "Executable file: $TDIR/$PROBLEM"
        cp $TDIR/$PROBLEM $BOXDIR/
        echo "Input: $TDIR/$PROBLEM"
 {
        pcont "<init> "
        box-clean
        echo "Executable file: $TDIR/$PROBLEM"
        cp $TDIR/$PROBLEM $BOXDIR/
        echo "Input: $TDIR/$PROBLEM"
+       ln $PDIR/$TEST.in $TDIR/$TEST.in
        cp $PDIR/$TEST.in $BOXDIR/$PROBLEM.in
        echo "Input files:"
        ls -Al $BOXDIR
        cp $PDIR/$TEST.in $BOXDIR/$PROBLEM.in
        echo "Input files:"
        ls -Al $BOXDIR
@@ -171,7 +173,7 @@ function test-run-with-files
                TEST_MSG="`cat $TDIR/exec.out`"
                pend "$TEST_MSG"
                echo "$TEST_MSG"
                TEST_MSG="`cat $TDIR/exec.out`"
                pend "$TEST_MSG"
                echo "$TEST_MSG"
-               echo >$PTSFILE "0 $TEST_MSG"
+               echo >>$PTSFILE "0 $TEST_MSG"
                return 1
        fi
        cat $TDIR/exec.out
                return 1
        fi
        cat $TDIR/exec.out
@@ -181,7 +183,7 @@ function test-run-with-files
        if [ ! -s $BOXDIR/$PROBLEM.out ] ; then
                pend "No output file."
                echo "No output file."
        if [ ! -s $BOXDIR/$PROBLEM.out ] ; then
                pend "No output file."
                echo "No output file."
-               echo >$PTSFILE "0 No output."
+               echo >>$PTSFILE "0 No output."
                return 1
        fi
        cp $BOXDIR/$PROBLEM.out $TDIR/$TEST.out
                return 1
        fi
        cp $BOXDIR/$PROBLEM.out $TDIR/$TEST.out
@@ -198,7 +200,7 @@ function syntax-check
        $SCHECK && return 0
        pend "Wrong syntax."
        echo "Wrong syntax."
        $SCHECK && return 0
        pend "Wrong syntax."
        echo "Wrong syntax."
-       echo >$PTSFILE "0 Wrong syntax."
+       echo >>$PTSFILE "0 Wrong syntax."
        return 1
 }
 
        return 1
 }
 
@@ -213,6 +215,26 @@ function output-check
        $OCHECK && return 0
        pend "Wrong answer."
        echo "Wrong answer."
        $OCHECK && return 0
        pend "Wrong answer."
        echo "Wrong answer."
-       echo >$PTSFILE "0 Wrong answer."
+       echo >>$PTSFILE "0 Wrong answer."
        return 1
 }
        return 1
 }
+
+# Setup of public commands
+
+function public-setup
+{
+       PDIR=$MO_PUBLIC/problems/$PROBLEM
+       SDIR=.
+       TDIR=~/.test
+       [ -d $PDIR ] || die "Unknown problem $PROBLEM"
+
+       pstart "Initializing... "
+       mkdir -p $TDIR
+       rm -rf $TDIR/*
+       BOXDIR=~/.box
+       mkdir -p $BOXDIR
+       rm -rf $BOXDIR/*
+       BOXCMD="$MO_PUBLIC/bin/box -c$BOXDIR"
+       exec >log
+       pend "OK  (see 'log' for details)"
+}