From: Martin Mares Date: Sat, 5 Jun 2004 14:56:50 +0000 (+0000) Subject: Fixed stdio tasks. X-Git-Tag: python-dummy-working~450 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=ec0ab4919197e1fed514c677e5db2cd5d3ef2183;p=moe.git Fixed stdio tasks. --- diff --git a/TODO b/TODO index 9949926..d7462f4 100644 --- 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 , not only guide: status diff --git a/bin/lib b/bin/lib index 7eed64e..cb5e215 100644 --- a/bin/lib +++ b/bin/lib @@ -202,7 +202,8 @@ function test-prolog ;; stdio) echo "Input file: (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: " ;; @@ -214,7 +215,7 @@ function test-prolog BOX_EXTRAS="$BOX_EXTRAS -o/dev/null" ;; stdio) echo "Output file: " - BOX_EXTRAS="$BOX_EXTRAS -o$TDIR/$TEST.out" + BOX_EXTRAS="$BOX_EXTRAS -o.stdout" ;; none) echo "Output file: " ;; @@ -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 } diff --git a/src/box.c b/src/box.c index 783b11b..bcfe233 100644 --- a/src/box.c +++ b/src/box.c @@ -1,7 +1,7 @@ /* * A Simple Testing Sandbox * - * (c) 2001 Martin Mares + * (c) 2001--2004 Martin Mares */ #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)