rbx.cp 0.5.73__py3-none-any.whl → 0.6.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. rbx/annotations.py +21 -1
  2. rbx/box/cli.py +10 -1
  3. rbx/box/code.py +140 -3
  4. rbx/box/contest/build_contest_statements.py +44 -34
  5. rbx/box/contest/schema.py +52 -8
  6. rbx/box/contest/statements.py +53 -25
  7. rbx/box/fields.py +35 -0
  8. rbx/box/lang.py +27 -0
  9. rbx/box/package.py +1 -1
  10. rbx/box/packaging/boca/packager.py +48 -5
  11. rbx/box/packaging/contest_main.py +13 -0
  12. rbx/box/packaging/main.py +13 -2
  13. rbx/box/packaging/packager.py +4 -4
  14. rbx/box/packaging/pkg/packager.py +142 -0
  15. rbx/box/packaging/polygon/packager.py +2 -24
  16. rbx/box/packaging/polygon/upload.py +35 -17
  17. rbx/box/remote.py +2 -2
  18. rbx/box/schema.py +68 -18
  19. rbx/box/solutions.py +6 -1
  20. rbx/box/statements/build_statements.py +44 -27
  21. rbx/box/statements/builders.py +18 -10
  22. rbx/box/statements/expander.py +49 -0
  23. rbx/box/statements/latex_jinja.py +61 -4
  24. rbx/box/statements/schema.py +33 -9
  25. rbx/box/testcase_utils.py +19 -47
  26. rbx/box/tooling/__init__.py +0 -0
  27. rbx/box/tooling/boca/__init__.py +0 -0
  28. rbx/box/tooling/boca/main.py +13 -0
  29. rbx/box/tooling/boca/scrape.py +34 -0
  30. rbx/box/{packaging/boca/upload.py → tooling/boca/scraper.py} +77 -8
  31. rbx/box/tooling/main.py +8 -0
  32. rbx/box/ui/widgets/interaction_box.py +19 -1
  33. rbx/grading/caching.py +18 -2
  34. rbx/grading/judge/sandbox.py +48 -5
  35. rbx/grading/judge/sandboxes/isolate.py +1 -0
  36. rbx/grading/judge/sandboxes/stupid_sandbox.py +11 -5
  37. rbx/grading/judge/sandboxes/timeit.py +36 -15
  38. rbx/grading/processing_context.py +62 -78
  39. rbx/grading/steps.py +91 -40
  40. rbx/resources/packagers/boca/checker.sh +4 -1
  41. rbx/resources/packagers/boca/compile/c +2 -6
  42. rbx/resources/packagers/boca/compile/cc +2 -6
  43. rbx/resources/packagers/boca/compile/cpp +2 -6
  44. rbx/resources/packagers/boca/compile/java +1 -6
  45. rbx/resources/packagers/boca/compile/kt +24 -28
  46. rbx/resources/packagers/boca/compile/py2 +2 -6
  47. rbx/resources/packagers/boca/compile/py3 +2 -6
  48. rbx/resources/packagers/boca/interactive/c +15 -83
  49. rbx/resources/packagers/boca/interactive/cc +15 -83
  50. rbx/resources/packagers/boca/interactive/cpp +15 -83
  51. rbx/resources/packagers/boca/interactive/java +15 -88
  52. rbx/resources/packagers/boca/interactive/kt +15 -88
  53. rbx/resources/packagers/boca/interactive/py2 +15 -88
  54. rbx/resources/packagers/boca/interactive/py3 +15 -88
  55. rbx/resources/packagers/boca/interactor_compile.sh +5 -2
  56. rbx/resources/packagers/boca/interactor_run.sh +174 -0
  57. rbx/resources/packagers/boca/safeexec.c +530 -0
  58. rbx/resources/packagers/boca/safeexec_compile.sh +49 -0
  59. rbx/resources/presets/default/contest/contest.rbx.yml +9 -8
  60. rbx/resources/presets/default/problem/problem.rbx.yml +27 -26
  61. rbx/resources/templates/rbx.h +2 -3
  62. {rbx_cp-0.5.73.dist-info → rbx_cp-0.6.0.dist-info}/METADATA +2 -1
  63. {rbx_cp-0.5.73.dist-info → rbx_cp-0.6.0.dist-info}/RECORD +66 -55
  64. rbx/resources/packagers/boca/compile/pas +0 -172
  65. {rbx_cp-0.5.73.dist-info → rbx_cp-0.6.0.dist-info}/LICENSE +0 -0
  66. {rbx_cp-0.5.73.dist-info → rbx_cp-0.6.0.dist-info}/WHEEL +0 -0
  67. {rbx_cp-0.5.73.dist-info → rbx_cp-0.6.0.dist-info}/entry_points.txt +0 -0
@@ -61,6 +61,10 @@ fi
61
61
  # make sure that directories below are correct.
62
62
  sf=$(which safeexec)
63
63
  [ -x "$sf" ] || sf=/usr/bin/safeexec
64
+ if [ -x "../safeexec.exe" ]; then
65
+ cp "../safeexec.exe" "safeexec.exe"
66
+ sf="./safeexec.exe"
67
+ fi
64
68
 
65
69
  if [ "$1" == "" -o "$2" == "" -o "$3" == "" ]; then
66
70
  echo "parameter problem"
@@ -80,8 +84,9 @@ if [ ! -x "$sf" ]; then
80
84
  fi
81
85
 
82
86
  time=$3
83
- if [ "$time" -gt "0" ]; then
84
- let "ttime = $time * 4"
87
+ rtime=$(awk "BEGIN {print int($time+0.9999999)}")
88
+ if [ "$rtime" -gt "0" ]; then
89
+ let "ttime = $rtime * 4"
85
90
  else
86
91
  time=1
87
92
  ttime=4
@@ -89,8 +94,8 @@ fi
89
94
 
90
95
  nruns=1
91
96
  if [ "$4" != "" ]; then
92
- if [ "$4" -gt "0" ]; then
93
- nruns=$4
97
+ if [ "$4" -gt "1" ]; then
98
+ echo "WARNING: nruns is set to $4, but it will be ignored because it's not supported by interactive problems"
94
99
  fi
95
100
  fi
96
101
  maxm=512000
@@ -120,79 +125,9 @@ cdir=$(pwd)
120
125
  echo "Current directory is $cdir -- chrooting on it" >&2
121
126
 
122
127
  ### START OF BOCA RUN COMMAND
123
- cat <<EOF >runit.sh
124
- #!/bin/bash
125
- mkfifo fifo.in fifo.out
126
-
127
- echo "Running solution as \$@" >&2
128
-
129
- "\$@" >fifo.out <fifo.in 2>/dev/null &
130
- SFPID=\$!
131
-
132
- ./interactor.exe "stdin0" "stdout0" <fifo.out >fifo.in 2>stderr0 &
133
- INTPID=\$!
134
-
135
- ECINT=0
136
- ECSF=0
137
-
138
- wait -p EXITID -n \$SFPID \$INTPID
139
- ECEXIT=\$?
140
- if [[ \$ECEXIT -ne 0 ]]; then
141
- kill -SIGTERM \$SFPID \$INTPID 2>/dev/null
142
- fi
143
-
144
- EXITFIRST=none
145
- if [[ \$EXITID -eq \$INTPID ]]; then
146
- wait \$SFPID
147
- ECSF=\$?
148
- ECINT=\$ECEXIT
149
- EXITFIRST=interactor
150
- else
151
- wait \$INTPID
152
- ECINT=\$?
153
- ECSF=\$ECEXIT
154
- EXITFIRST=solution
155
- fi
156
-
157
- rm -rf fifo.in fifo.out
158
-
159
- echo "Ran solution as \$@" &>>stderr0
160
- echo "interactor exitcode \$ECINT" &>>stderr0
161
- echo "solution exitcode \$ECSF" &>>stderr0
162
- echo "exit first \$EXITFIRST" &>>stderr0
163
-
164
- finish() {
165
- echo "exitting from runit.sh with exit code \$1" &>>stderr0
166
- exit \$1
167
- }
168
-
169
- # 1. Check for interactor errors.
170
- if [[ \$ECSF -eq -SIGPIPE ]] || [[ \$ECSF -eq -SIGTERM ]] || [[ \$ECSF -ne 0 ]] && ! cat stderr0 | grep -q "wrong output format Unexpected end of file"; then
171
- if [[ \$ECINT -ge 1 ]] && [[ \$ECINT -le 4 ]]; then
172
- echo "testlib exitcode \$ECINT" >stdout0
173
- finish 0
174
- elif [[ \$ECINT -ne 0 ]]; then
175
- finish 9
176
- fi
177
- fi
178
-
179
- # 2. Check for solution errors.
180
- if [[ \$ECSF -ne 0 ]]; then
181
- finish \$ECSF
182
- fi
183
-
184
- # 3. Check for interactor without looking at solution output.
185
- if [[ \$ECINT -ge 1 ]] && [[ \$ECINT -le 4 ]]; then
186
- echo "testlib exitcode \$ECINT" >stdout0
187
- finish 0
188
- elif [[ \$ECINT -ne 0 ]]; then
189
- finish 9
190
- fi
191
-
192
- # 4. Finish with zero and later check output.
193
- finish 0
128
+ cat >runit.sh <<"EOF"
129
+ {{runit_content}}
194
130
  EOF
195
-
196
131
  chmod 755 runit.sh
197
132
 
198
133
  ret=0
@@ -204,13 +139,14 @@ if [ $? -eq 0 ]; then
204
139
  cd "$cdir"
205
140
  [ -f /proc/cpuinfo ] || /bin/mount -t proc proc /proc
206
141
  [ -d /sys/kernel ] || /bin/mount -t sysfs sysfs /sys
207
- "$sf" -F10 -f$maxf -r$nruns -n0 -C. -U$bocau -G$bocag -d$maxm -m$maxm -t$time -T$ttime -ostdout0 -estderr0 -- ./runit.sh ./run.exe
142
+ ./runit.sh "$cdir" "$sf" "$ttime" -F10 -f$maxf -r$nruns -n0 -C. -U$bocau -G$bocag -d$maxm -m$maxm -t$time -T$ttime -- ./run.exe
208
143
  retval=\$?
209
144
  echo \$retval > runch.exitcode
210
145
  if [ ! -d /bocajail ]; then
211
146
  /bin/umount /proc 2>/dev/null
212
147
  /bin/umount /sys 2>/dev/null
213
148
  fi
149
+ rm -rf fifo.in fifo.out
214
150
  EOF
215
151
  chmod 755 runch.sh
216
152
  chroot /bocajail $cdir/runch.sh
@@ -222,12 +158,8 @@ EOF
222
158
  exit 49
223
159
  fi
224
160
  else
225
- echo "CODE NOT BEING CHROOTED. DO NOT RUN THIS ON THE MAIN SERVER" >&2
226
- echo "CODE NOT BEING CHROOTED. DO NOT RUN THIS ON THE MAIN SERVER" >&2
227
- echo "CODE NOT BEING CHROOTED. DO NOT RUN THIS ON THE MAIN SERVER" >&2
228
-
229
- "$sf" -F10 -f$maxf -r$nruns -n0 -C. -U$bocau -G$bocag -d$maxm -m$maxm -t$time -T$ttime -ostdout0 -estderr0 -- ./runit.sh ./run.exe
230
- ret=$?
161
+ echo "ERROR: CODE NOT BEING CHROOTED. DO NOT RUN THIS ON THE MAIN SERVER" >&2
162
+ exit 48
231
163
  fi
232
164
  ### END OF BOCA RUN COMMAND
233
165
 
@@ -61,6 +61,10 @@ fi
61
61
  # make sure that directories below are correct.
62
62
  sf=$(which safeexec)
63
63
  [ -x "$sf" ] || sf=/usr/bin/safeexec
64
+ if [ -x "../safeexec.exe" ]; then
65
+ cp "../safeexec.exe" "safeexec.exe"
66
+ sf="./safeexec.exe"
67
+ fi
64
68
 
65
69
  if [ "$1" == "" -o "$2" == "" -o "$3" == "" ]; then
66
70
  echo "parameter problem"
@@ -80,8 +84,9 @@ if [ ! -x "$sf" ]; then
80
84
  fi
81
85
 
82
86
  time=$3
83
- if [ "$time" -gt "0" ]; then
84
- let "ttime = $time * 4"
87
+ rtime=$(awk "BEGIN {print int($time+0.9999999)}")
88
+ if [ "$rtime" -gt "0" ]; then
89
+ let "ttime = $rtime * 4"
85
90
  else
86
91
  time=1
87
92
  ttime=4
@@ -89,8 +94,8 @@ fi
89
94
 
90
95
  nruns=1
91
96
  if [ "$4" != "" ]; then
92
- if [ "$4" -gt "0" ]; then
93
- nruns=$4
97
+ if [ "$4" -gt "1" ]; then
98
+ echo "WARNING: nruns is set to $4, but it will be ignored because it's not supported by interactive problems"
94
99
  fi
95
100
  fi
96
101
  maxm=512000
@@ -120,79 +125,9 @@ cdir=$(pwd)
120
125
  echo "Current directory is $cdir -- chrooting on it" >&2
121
126
 
122
127
  ### START OF BOCA RUN COMMAND
123
- cat <<EOF >runit.sh
124
- #!/bin/bash
125
- mkfifo fifo.in fifo.out
126
-
127
- echo "Running solution as \$@" >&2
128
-
129
- "\$@" >fifo.out <fifo.in 2>/dev/null &
130
- SFPID=\$!
131
-
132
- ./interactor.exe "stdin0" "stdout0" <fifo.out >fifo.in 2>stderr0 &
133
- INTPID=\$!
134
-
135
- ECINT=0
136
- ECSF=0
137
-
138
- wait -p EXITID -n \$SFPID \$INTPID
139
- ECEXIT=\$?
140
- if [[ \$ECEXIT -ne 0 ]]; then
141
- kill -SIGTERM \$SFPID \$INTPID 2>/dev/null
142
- fi
143
-
144
- EXITFIRST=none
145
- if [[ \$EXITID -eq \$INTPID ]]; then
146
- wait \$SFPID
147
- ECSF=\$?
148
- ECINT=\$ECEXIT
149
- EXITFIRST=interactor
150
- else
151
- wait \$INTPID
152
- ECINT=\$?
153
- ECSF=\$ECEXIT
154
- EXITFIRST=solution
155
- fi
156
-
157
- rm -rf fifo.in fifo.out
158
-
159
- echo "Ran solution as \$@" &>>stderr0
160
- echo "interactor exitcode \$ECINT" &>>stderr0
161
- echo "solution exitcode \$ECSF" &>>stderr0
162
- echo "exit first \$EXITFIRST" &>>stderr0
163
-
164
- finish() {
165
- echo "exitting from runit.sh with exit code \$1" &>>stderr0
166
- exit \$1
167
- }
168
-
169
- # 1. Check for interactor errors.
170
- if [[ \$ECSF -eq -SIGPIPE ]] || [[ \$ECSF -eq -SIGTERM ]] || [[ \$ECSF -ne 0 ]] && ! cat stderr0 | grep -q "wrong output format Unexpected end of file"; then
171
- if [[ \$ECINT -ge 1 ]] && [[ \$ECINT -le 4 ]]; then
172
- echo "testlib exitcode \$ECINT" >stdout0
173
- finish 0
174
- elif [[ \$ECINT -ne 0 ]]; then
175
- finish 9
176
- fi
177
- fi
178
-
179
- # 2. Check for solution errors.
180
- if [[ \$ECSF -ne 0 ]]; then
181
- finish \$ECSF
182
- fi
183
-
184
- # 3. Check for interactor without looking at solution output.
185
- if [[ \$ECINT -ge 1 ]] && [[ \$ECINT -le 4 ]]; then
186
- echo "testlib exitcode \$ECINT" >stdout0
187
- finish 0
188
- elif [[ \$ECINT -ne 0 ]]; then
189
- finish 9
190
- fi
191
-
192
- # 4. Finish with zero and later check output.
193
- finish 0
128
+ cat >runit.sh <<"EOF"
129
+ {{runit_content}}
194
130
  EOF
195
-
196
131
  chmod 755 runit.sh
197
132
 
198
133
  ret=0
@@ -204,13 +139,14 @@ if [ $? -eq 0 ]; then
204
139
  cd "$cdir"
205
140
  [ -f /proc/cpuinfo ] || /bin/mount -t proc proc /proc
206
141
  [ -d /sys/kernel ] || /bin/mount -t sysfs sysfs /sys
207
- "$sf" -F10 -f$maxf -r$nruns -n0 -C. -U$bocau -G$bocag -d$maxm -m$maxm -t$time -T$ttime -ostdout0 -estderr0 -- ./runit.sh ./run.exe
142
+ ./runit.sh "$cdir" "$sf" "$ttime" -F10 -f$maxf -r$nruns -n0 -C. -U$bocau -G$bocag -d$maxm -m$maxm -t$time -T$ttime -- ./run.exe
208
143
  retval=\$?
209
144
  echo \$retval > runch.exitcode
210
145
  if [ ! -d /bocajail ]; then
211
146
  /bin/umount /proc 2>/dev/null
212
147
  /bin/umount /sys 2>/dev/null
213
148
  fi
149
+ rm -rf fifo.in fifo.out
214
150
  EOF
215
151
  chmod 755 runch.sh
216
152
  chroot /bocajail $cdir/runch.sh
@@ -222,12 +158,8 @@ EOF
222
158
  exit 49
223
159
  fi
224
160
  else
225
- echo "CODE NOT BEING CHROOTED. DO NOT RUN THIS ON THE MAIN SERVER" >&2
226
- echo "CODE NOT BEING CHROOTED. DO NOT RUN THIS ON THE MAIN SERVER" >&2
227
- echo "CODE NOT BEING CHROOTED. DO NOT RUN THIS ON THE MAIN SERVER" >&2
228
-
229
- "$sf" -F10 -f$maxf -r$nruns -n0 -C. -U$bocau -G$bocag -d$maxm -m$maxm -t$time -T$ttime -ostdout0 -estderr0 -- ./runit.sh ./run.exe
230
- ret=$?
161
+ echo "ERROR: CODE NOT BEING CHROOTED. DO NOT RUN THIS ON THE MAIN SERVER" >&2
162
+ exit 48
231
163
  fi
232
164
  ### END OF BOCA RUN COMMAND
233
165
 
@@ -61,6 +61,10 @@ fi
61
61
  # make sure that directories below are correct.
62
62
  sf=$(which safeexec)
63
63
  [ -x "$sf" ] || sf=/usr/bin/safeexec
64
+ if [ -x "../safeexec.exe" ]; then
65
+ cp "../safeexec.exe" "safeexec.exe"
66
+ sf="./safeexec.exe"
67
+ fi
64
68
 
65
69
  if [ "$1" == "" -o "$2" == "" -o "$3" == "" ]; then
66
70
  echo "parameter problem"
@@ -80,8 +84,9 @@ if [ ! -x "$sf" ]; then
80
84
  fi
81
85
 
82
86
  time=$3
83
- if [ "$time" -gt "0" ]; then
84
- let "ttime = $time * 4"
87
+ rtime=$(awk "BEGIN {print int($time+0.9999999)}")
88
+ if [ "$rtime" -gt "0" ]; then
89
+ let "ttime = $rtime * 4"
85
90
  else
86
91
  time=1
87
92
  ttime=4
@@ -89,8 +94,8 @@ fi
89
94
 
90
95
  nruns=1
91
96
  if [ "$4" != "" ]; then
92
- if [ "$4" -gt "0" ]; then
93
- nruns=$4
97
+ if [ "$4" -gt "1" ]; then
98
+ echo "WARNING: nruns is set to $4, but it will be ignored because it's not supported by interactive problems"
94
99
  fi
95
100
  fi
96
101
  maxm=512000
@@ -120,79 +125,9 @@ cdir=$(pwd)
120
125
  echo "Current directory is $cdir -- chrooting on it" >&2
121
126
 
122
127
  ### START OF BOCA RUN COMMAND
123
- cat <<EOF >runit.sh
124
- #!/bin/bash
125
- mkfifo fifo.in fifo.out
126
-
127
- echo "Running solution as \$@" >&2
128
-
129
- "\$@" >fifo.out <fifo.in 2>/dev/null &
130
- SFPID=\$!
131
-
132
- ./interactor.exe "stdin0" "stdout0" <fifo.out >fifo.in 2>stderr0 &
133
- INTPID=\$!
134
-
135
- ECINT=0
136
- ECSF=0
137
-
138
- wait -p EXITID -n \$SFPID \$INTPID
139
- ECEXIT=\$?
140
- if [[ \$ECEXIT -ne 0 ]]; then
141
- kill -SIGTERM \$SFPID \$INTPID 2>/dev/null
142
- fi
143
-
144
- EXITFIRST=none
145
- if [[ \$EXITID -eq \$INTPID ]]; then
146
- wait \$SFPID
147
- ECSF=\$?
148
- ECINT=\$ECEXIT
149
- EXITFIRST=interactor
150
- else
151
- wait \$INTPID
152
- ECINT=\$?
153
- ECSF=\$ECEXIT
154
- EXITFIRST=solution
155
- fi
156
-
157
- rm -rf fifo.in fifo.out
158
-
159
- echo "Ran solution as \$@" &>>stderr0
160
- echo "interactor exitcode \$ECINT" &>>stderr0
161
- echo "solution exitcode \$ECSF" &>>stderr0
162
- echo "exit first \$EXITFIRST" &>>stderr0
163
-
164
- finish() {
165
- echo "exitting from runit.sh with exit code \$1" &>>stderr0
166
- exit \$1
167
- }
168
-
169
- # 1. Check for interactor errors.
170
- if [[ \$ECSF -eq -SIGPIPE ]] || [[ \$ECSF -eq -SIGTERM ]] || [[ \$ECSF -ne 0 ]] && ! cat stderr0 | grep -q "wrong output format Unexpected end of file"; then
171
- if [[ \$ECINT -ge 1 ]] && [[ \$ECINT -le 4 ]]; then
172
- echo "testlib exitcode \$ECINT" >stdout0
173
- finish 0
174
- elif [[ \$ECINT -ne 0 ]]; then
175
- finish 9
176
- fi
177
- fi
178
-
179
- # 2. Check for solution errors.
180
- if [[ \$ECSF -ne 0 ]]; then
181
- finish \$ECSF
182
- fi
183
-
184
- # 3. Check for interactor without looking at solution output.
185
- if [[ \$ECINT -ge 1 ]] && [[ \$ECINT -le 4 ]]; then
186
- echo "testlib exitcode \$ECINT" >stdout0
187
- finish 0
188
- elif [[ \$ECINT -ne 0 ]]; then
189
- finish 9
190
- fi
191
-
192
- # 4. Finish with zero and later check output.
193
- finish 0
128
+ cat >runit.sh <<"EOF"
129
+ {{runit_content}}
194
130
  EOF
195
-
196
131
  chmod 755 runit.sh
197
132
 
198
133
  ret=0
@@ -204,13 +139,14 @@ if [ $? -eq 0 ]; then
204
139
  cd "$cdir"
205
140
  [ -f /proc/cpuinfo ] || /bin/mount -t proc proc /proc
206
141
  [ -d /sys/kernel ] || /bin/mount -t sysfs sysfs /sys
207
- "$sf" -F10 -f$maxf -r$nruns -n0 -C. -U$bocau -G$bocag -d$maxm -m$maxm -t$time -T$ttime -ostdout0 -estderr0 -- ./runit.sh ./run.exe
142
+ ./runit.sh "$cdir" "$sf" "$ttime" -F10 -f$maxf -r$nruns -n0 -C. -U$bocau -G$bocag -d$maxm -m$maxm -t$time -T$ttime -- ./run.exe
208
143
  retval=\$?
209
144
  echo \$retval > runch.exitcode
210
145
  if [ ! -d /bocajail ]; then
211
146
  /bin/umount /proc 2>/dev/null
212
147
  /bin/umount /sys 2>/dev/null
213
148
  fi
149
+ rm -rf fifo.in fifo.out
214
150
  EOF
215
151
  chmod 755 runch.sh
216
152
  chroot /bocajail $cdir/runch.sh
@@ -222,12 +158,8 @@ EOF
222
158
  exit 49
223
159
  fi
224
160
  else
225
- echo "CODE NOT BEING CHROOTED. DO NOT RUN THIS ON THE MAIN SERVER" >&2
226
- echo "CODE NOT BEING CHROOTED. DO NOT RUN THIS ON THE MAIN SERVER" >&2
227
- echo "CODE NOT BEING CHROOTED. DO NOT RUN THIS ON THE MAIN SERVER" >&2
228
-
229
- "$sf" -F10 -f$maxf -r$nruns -n0 -C. -U$bocau -G$bocag -d$maxm -m$maxm -t$time -T$ttime -ostdout0 -estderr0 -- ./runit.sh ./run.exe
230
- ret=$?
161
+ echo "ERROR: CODE NOT BEING CHROOTED. DO NOT RUN THIS ON THE MAIN SERVER" >&2
162
+ exit 48
231
163
  fi
232
164
  ### END OF BOCA RUN COMMAND
233
165
 
@@ -61,6 +61,10 @@ fi
61
61
  # make sure that directories below are correct.
62
62
  sf=$(which safeexec)
63
63
  [ -x "$sf" ] || sf=/usr/bin/safeexec
64
+ if [ -x "../safeexec.exe" ]; then
65
+ cp "../safeexec.exe" "safeexec.exe"
66
+ sf="./safeexec.exe"
67
+ fi
64
68
 
65
69
  if [ "$1" == "" -o "$2" == "" -o "$3" == "" ]; then
66
70
  echo "parameter problem"
@@ -98,8 +102,9 @@ if [ ! -x "$sf" ]; then
98
102
  fi
99
103
 
100
104
  time=$3
101
- if [ "$time" -gt "0" ]; then
102
- let "ttime = $time * 4"
105
+ rtime=$(awk "BEGIN {print int($time+0.9999999)}")
106
+ if [ "$rtime" -gt "0" ]; then
107
+ let "ttime = $rtime * 4"
103
108
  else
104
109
  time=1
105
110
  ttime=4
@@ -107,8 +112,8 @@ fi
107
112
 
108
113
  nruns=1
109
114
  if [ "$4" != "" ]; then
110
- if [ "$4" -gt "0" ]; then
111
- nruns=$4
115
+ if [ "$4" -gt "1" ]; then
116
+ echo "WARNING: nruns is set to $4, but it will be ignored because it's not supported by interactive problems"
112
117
  fi
113
118
  fi
114
119
  maxm=512000
@@ -133,79 +138,9 @@ cdir=$(pwd)
133
138
  echo "Current directory is $cdir -- chrooting on it" >&2
134
139
 
135
140
  ### START OF BOCA RUN COMMAND
136
- cat <<EOF >runit.sh
137
- #!/bin/bash
138
- mkfifo fifo.in fifo.out
139
-
140
- echo "Running solution as \$@" >&2
141
-
142
- "\$@" >fifo.out <fifo.in 2>/dev/null &
143
- SFPID=\$!
144
-
145
- ./interactor.exe "stdin0" "stdout0" <fifo.out >fifo.in 2>stderr0 &
146
- INTPID=\$!
147
-
148
- ECINT=0
149
- ECSF=0
150
-
151
- wait -p EXITID -n \$SFPID \$INTPID
152
- ECEXIT=\$?
153
- if [[ \$ECEXIT -ne 0 ]]; then
154
- kill -SIGTERM \$SFPID \$INTPID 2>/dev/null
155
- fi
156
-
157
- EXITFIRST=none
158
- if [[ \$EXITID -eq \$INTPID ]]; then
159
- wait \$SFPID
160
- ECSF=\$?
161
- ECINT=\$ECEXIT
162
- EXITFIRST=interactor
163
- else
164
- wait \$INTPID
165
- ECINT=\$?
166
- ECSF=\$ECEXIT
167
- EXITFIRST=solution
168
- fi
169
-
170
- rm -rf fifo.in fifo.out
171
-
172
- echo "Ran solution as \$@" &>>stderr0
173
- echo "interactor exitcode \$ECINT" &>>stderr0
174
- echo "solution exitcode \$ECSF" &>>stderr0
175
- echo "exit first \$EXITFIRST" &>>stderr0
176
-
177
- finish() {
178
- echo "exitting from runit.sh with exit code \$1" &>>stderr0
179
- exit \$1
180
- }
181
-
182
- # 1. Check for interactor errors.
183
- if [[ \$ECSF -eq -SIGPIPE ]] || [[ \$ECSF -eq -SIGTERM ]] || [[ \$ECSF -ne 0 ]] && ! cat stderr0 | grep -q "wrong output format Unexpected end of file"; then
184
- if [[ \$ECINT -ge 1 ]] && [[ \$ECINT -le 4 ]]; then
185
- echo "testlib exitcode \$ECINT" >stdout0
186
- finish 0
187
- elif [[ \$ECINT -ne 0 ]]; then
188
- finish 9
189
- fi
190
- fi
191
-
192
- # 2. Check for solution errors.
193
- if [[ \$ECSF -ne 0 ]]; then
194
- finish \$ECSF
195
- fi
196
-
197
- # 3. Check for interactor without looking at solution output.
198
- if [[ \$ECINT -ge 1 ]] && [[ \$ECINT -le 4 ]]; then
199
- echo "testlib exitcode \$ECINT" >stdout0
200
- finish 0
201
- elif [[ \$ECINT -ne 0 ]]; then
202
- finish 9
203
- fi
204
-
205
- # 4. Finish with zero and later check output.
206
- finish 0
141
+ cat >runit.sh <<"EOF"
142
+ {{runit_content}}
207
143
  EOF
208
-
209
144
  chmod 755 runit.sh
210
145
 
211
146
  ret=0
@@ -223,13 +158,14 @@ if [ $? -eq 0 ]; then
223
158
  echo "\$java not found or it's not executable"
224
159
  exit 47
225
160
  fi
226
- "$sf" -r$nruns -t$time -T$ttime -istdin0 -F256 -u256 -ostdout0 -estderr0 -U$bocau -G$bocag -n0 -C. -f20000 -d20000000 -m20000000 -- ./runit.sh "\$java" -jar run.jar -Xmx${maxm}K -Xss${maxms}K -Xms${maxm}K
161
+ ./runit.sh "$cdir" "$sf" "$ttime" -r$nruns -t$time -T$ttime -F256 -u256 -U$bocau -G$bocag -n0 -C. -f20000 -d20000000 -m20000000 -- "\$java" -jar run.jar -Xmx${maxm}K -Xss${maxms}K -Xms${maxm}K
227
162
  retval=\$?
228
163
  echo \$retval > runch.exitcode
229
164
  if [ ! -d /bocajail ]; then
230
165
  /bin/umount /proc 2>/dev/null
231
166
  /bin/umount /sys 2>/dev/null
232
167
  fi
168
+ rm -rf fifo.in fifo.out
233
169
  EOF
234
170
  chmod 755 runch.sh
235
171
  chroot /bocajail $cdir/runch.sh
@@ -241,17 +177,8 @@ EOF
241
177
  exit 49
242
178
  fi
243
179
  else
244
- echo "CODE NOT BEING CHROOTED. DO NOT RUN THIS ON THE MAIN SERVER" >&2
245
- echo "CODE NOT BEING CHROOTED. DO NOT RUN THIS ON THE MAIN SERVER" >&2
246
- echo "CODE NOT BEING CHROOTED. DO NOT RUN THIS ON THE MAIN SERVER" >&2
247
- java=$(which java)
248
- [ -x "$java" ] || java=/usr/bin/java
249
- if [ ! -x "$java" ]; then
250
- echo "$java not found or it's not executable"
251
- exit 47
252
- fi
253
- "$sf" -r$nruns -t$time -T$ttime -istdin0 -F256 -u256 -U$bocau -G$bocag -ostdout0 -estderr0 -n0 -C. -d20000000 -m20000000 -- ./runit.sh "$java" -jar run.jar -Xmx${maxm}K -Xss${maxms}K -Xms${maxm}K
254
- ret=$?
180
+ echo "ERROR: CODE NOT BEING CHROOTED. DO NOT RUN THIS ON THE MAIN SERVER" >&2
181
+ exit 48
255
182
  fi
256
183
  ### END OF BOCA RUN COMMAND
257
184