]> mj.ucw.cz Git - moe.git/commitdiff
Fixed stdio tasks.
authorMartin Mares <mj@ucw.cz>
Sat, 5 Jun 2004 14:56:50 +0000 (14:56 +0000)
committerMartin Mares <mj@ucw.cz>
Sat, 5 Jun 2004 14:56:50 +0000 (14:56 +0000)
TODO
bin/lib
src/box.c

diff --git a/TODO b/TODO
index 99499268c5a1113b17de72e930c4c587b962df3f..d7462f4074cc02768a6f4d7c2213b50c285abd8d 100644 (file)
--- a/TODO
+++ b/TODO
@@ -4,7 +4,6 @@ box: konfigurovatelny pristup k timerum a /proc/self/stat (pripadne /proc/self/f
 score: better formatting of the score table
 interactive tasks: solve deadlocks?
 interactive tasks: logging of messages
-STDIO TASKS!!!
 
 guide: compile <file>, not only <task>
 guide: status
diff --git a/bin/lib b/bin/lib
index 7eed64eb9736f6953a98300b6a53b55fde314644..cb5e2150d2f9402a35d424a1cc2ebf44563f9884 100644 (file)
--- a/bin/lib
+++ b/bin/lib
@@ -202,7 +202,8 @@ function test-prolog
                        ;;
                stdio)  echo "Input file: <stdin> (from $PDIR/$TEST.in)"
                        ln $PDIR/$TEST.in $TDIR/$TEST.in
-                       BOX_EXTRAS="$BOX_EXTRAS -i$TDIR/$TEST.in"
+                       cp $PDIR/$TEST.in $BOXDIR/.stdin
+                       BOX_EXTRAS="$BOX_EXTRAS -i.stdin"
                        ;;
                none)   echo "Input file: <none>"
                        ;;
@@ -214,7 +215,7 @@ function test-prolog
                        BOX_EXTRAS="$BOX_EXTRAS -o/dev/null"
                        ;;
                stdio)  echo "Output file: <stdout>"
-                       BOX_EXTRAS="$BOX_EXTRAS -o$TDIR/$TEST.out"
+                       BOX_EXTRAS="$BOX_EXTRAS -o.stdout"
                        ;;
                none)   echo "Output file: <none>"
                        ;;
@@ -236,7 +237,8 @@ function test-epilog
                file)   [ -f $BOXDIR/$PROBLEM.out ] || test-result 0 "No output file."
                        cp $BOXDIR/$PROBLEM.out $TDIR/$TEST.out
                        ;;
-               stdio)  [ -f $TDIR/$TEST.out ] || test-result 0 "No output file."
+               stdio)  [ -f $BOXDIR/.stdout ] || test-result 0 "No output file."
+                       cp $BOXDIR/.stdout $TDIR/$TEST.out
                        ;;
        esac
 }
index 783b11b98c2054e79f1d13d65bc8a0de81da0aac..bcfe233f84345b2043d0f4dbe5a22f18c12c8332 100644 (file)
--- a/src/box.c
+++ b/src/box.c
@@ -1,7 +1,7 @@
 /*
  *     A Simple Testing Sandbox
  *
- *     (c) 2001 Martin Mares <mj@ucw.cz>
+ *     (c) 2001--2004 Martin Mares <mj@ucw.cz>
  */
 
 #define _LARGEFILE64_SOURCE
@@ -431,6 +431,8 @@ box_inside(int argc, char **argv)
 
   memcpy(args, argv, argc * sizeof(char *));
   args[argc] = NULL;
+  if (set_cwd && chdir(set_cwd))
+    die("chdir: %m");
   if (redir_stdin)
     {
       close(0);
@@ -443,8 +445,6 @@ box_inside(int argc, char **argv)
       if (open(redir_stdout, O_WRONLY | O_CREAT | O_TRUNC, 0666) != 1)
        die("open(\"%s\"): %m", redir_stdout);
     }
-  if (set_cwd && chdir(set_cwd))
-    die("chdir: %m");
   dup2(1, 2);
   setpgrp();
   if (memory_limit)