rbx.cp 0.5.46__py3-none-any.whl → 0.5.47__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 (58) hide show
  1. rbx/box/checkers.py +81 -28
  2. rbx/box/cli.py +12 -10
  3. rbx/box/packaging/boca/packager.py +44 -7
  4. rbx/box/packaging/main.py +7 -0
  5. rbx/box/packaging/moj/packager.py +88 -8
  6. rbx/box/packaging/packager.py +7 -2
  7. rbx/box/packaging/polygon/packager.py +5 -4
  8. rbx/box/solutions.py +2 -2
  9. rbx/box/stresses.py +0 -1
  10. rbx/box/tasks.py +6 -4
  11. rbx/grading/judge/sandbox.py +29 -1
  12. rbx/grading/judge/sandboxes/isolate.py +10 -0
  13. rbx/grading/judge/sandboxes/stupid_sandbox.py +16 -4
  14. rbx/grading/judge/sandboxes/timeit.py +12 -3
  15. rbx/grading/processing_context.py +48 -0
  16. rbx/grading/steps.py +24 -13
  17. rbx/resources/packagers/boca/checker.sh +8 -6
  18. rbx/resources/packagers/boca/compare.sh +48 -0
  19. rbx/resources/packagers/boca/interactive/c +207 -0
  20. rbx/resources/packagers/boca/interactive/cc +207 -0
  21. rbx/resources/packagers/boca/interactive/cpp +207 -0
  22. rbx/resources/packagers/boca/interactive/java +240 -0
  23. rbx/resources/packagers/boca/interactive/kt +231 -0
  24. rbx/resources/packagers/boca/interactive/py2 +209 -0
  25. rbx/resources/packagers/boca/interactive/py3 +209 -0
  26. rbx/resources/packagers/boca/interactor_compile.sh +45 -0
  27. rbx/resources/packagers/boca/run/bkp +163 -0
  28. rbx/resources/packagers/boca/run/c +19 -19
  29. rbx/resources/packagers/boca/run/cc +19 -19
  30. rbx/resources/packagers/boca/run/cpp +19 -19
  31. rbx/resources/packagers/boca/run/java +51 -51
  32. rbx/resources/packagers/boca/run/kt +30 -30
  33. rbx/resources/packagers/boca/run/py2 +42 -42
  34. rbx/resources/packagers/boca/run/py3 +42 -42
  35. rbx/resources/packagers/moj/scripts/c/compile.sh +19 -0
  36. rbx/resources/packagers/moj/scripts/c/prep.sh +5 -0
  37. rbx/resources/packagers/moj/scripts/c/run.sh +16 -0
  38. rbx/resources/packagers/moj/scripts/compare.sh +32 -6
  39. rbx/resources/packagers/moj/scripts/cpp/compile.sh +19 -0
  40. rbx/resources/packagers/moj/scripts/cpp/prep.sh +5 -0
  41. rbx/resources/packagers/moj/scripts/cpp/run.sh +16 -0
  42. rbx/resources/packagers/moj/scripts/interactor_prep.sh +14 -0
  43. rbx/resources/packagers/moj/scripts/interactor_run.sh +38 -0
  44. rbx/resources/packagers/moj/scripts/java/compile.sh +12 -0
  45. rbx/resources/packagers/moj/scripts/java/prep.sh +8 -0
  46. rbx/resources/packagers/moj/scripts/java/run.sh +17 -0
  47. rbx/resources/packagers/moj/scripts/py2/compile.sh +7 -0
  48. rbx/resources/packagers/moj/scripts/py2/prep.sh +5 -0
  49. rbx/resources/packagers/moj/scripts/py2/run.sh +16 -0
  50. rbx/resources/packagers/moj/scripts/py3/compile.sh +7 -0
  51. rbx/resources/packagers/moj/scripts/py3/prep.sh +5 -0
  52. rbx/resources/packagers/moj/scripts/py3/run.sh +16 -0
  53. {rbx_cp-0.5.46.dist-info → rbx_cp-0.5.47.dist-info}/METADATA +1 -1
  54. {rbx_cp-0.5.46.dist-info → rbx_cp-0.5.47.dist-info}/RECORD +57 -30
  55. rbx/resources/packagers/boca/compare +0 -53
  56. {rbx_cp-0.5.46.dist-info → rbx_cp-0.5.47.dist-info}/LICENSE +0 -0
  57. {rbx_cp-0.5.46.dist-info → rbx_cp-0.5.47.dist-info}/WHEEL +0 -0
  58. {rbx_cp-0.5.46.dist-info → rbx_cp-0.5.47.dist-info}/entry_points.txt +0 -0
@@ -0,0 +1,231 @@
1
+ #!/bin/bash
2
+ # ////////////////////////////////////////////////////////////////////////////////
3
+ # //BOCA Online Contest Administrator
4
+ # // Copyright (C) 2003-2014 by BOCA System (bocasystem@gmail.com)
5
+ # //
6
+ # // This program is free software: you can redistribute it and/or modify
7
+ # // it under the terms of the GNU General Public License as published by
8
+ # // the Free Software Foundation, either version 3 of the License, or
9
+ # // (at your option) any later version.
10
+ # //
11
+ # // This program is distributed in the hope that it will be useful,
12
+ # // but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ # // GNU General Public License for more details.
15
+ # // You should have received a copy of the GNU General Public License
16
+ # // along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+ # ////////////////////////////////////////////////////////////////////////////////
18
+ #Last modified: 21/aug/2014 by cassio@ime.usp.br
19
+ #
20
+ # parameters are:
21
+ # $1 exe_file
22
+ # $2 input_file
23
+ # $3 timelimit (limit to run all the repetitions, by default only one repetition)
24
+ # $4 number_of_repetitions_to_run (optional, can be used for better tuning the timelimit)
25
+ # $5 maximum allowed memory (in MBytes)
26
+ # $6 maximum allowed output size (in KBytes)
27
+ #
28
+ # the output of the submission should be directed to the standard output
29
+ #
30
+ # the return code show what happened (according to safeexec):
31
+ # 0 ok
32
+ # 1 compile error
33
+ # 2 runtime error
34
+ # 3 timelimit exceeded
35
+ # 4 internal error
36
+ # 5 parameter error
37
+ # 6 internal error
38
+ # 7 memory limit exceeded
39
+ # 8 security threat
40
+ # 9 runtime error
41
+ # other_codes are unknown to boca: in this case BOCA will present the
42
+ # last line of standard output to the judge
43
+
44
+ umask 0022
45
+ id -u bocajail >/dev/null 2>/dev/null
46
+ if [ $? == 0 ]; then
47
+ bocau=$(id -u bocajail)
48
+ bocag=$(id -g bocajail)
49
+ chown bocajail.nogroup .
50
+ else
51
+ bocau=$(id -u nobody)
52
+ bocag=$(id -g nobody)
53
+ chown nobody.nogroup .
54
+ fi
55
+ if [ "$bocau" == "" -o "$bocag" == "" ]; then
56
+ echo "error finding user to run script"
57
+ exit 43
58
+ fi
59
+
60
+ # this script makes use of safeexec to execute the code with less privilegies
61
+ # make sure that directories below are correct.
62
+ sf=$(which safeexec)
63
+ [ -x "$sf" ] || sf=/usr/bin/safeexec
64
+
65
+ if [ "$1" == "" -o "$2" == "" -o "$3" == "" ]; then
66
+ echo "parameter problem"
67
+ exit 43
68
+ fi
69
+ if [ ! -x "$1" ]; then
70
+ echo "$1 not found (or is not in the current dir) or it's not executable"
71
+ exit 44
72
+ fi
73
+ name=$(basename "$1")
74
+ if [ "${name##*.}" == "class" -a "${name##*.}" == "CLASS" ]; then
75
+ echo "WARNING: removing .class file extension"
76
+ fi
77
+ if [ "${name##*.}" == "class" ]; then
78
+ name=$(basename "$1" .class)
79
+ fi
80
+ if [ "${name##*.}" == "CLASS" ]; then
81
+ name=$(basename "$1" .CLASS)
82
+ fi
83
+ if [ ! -r "$2" ]; then
84
+ echo "$2 not found (or is not in the current dir) or it's not readable"
85
+ exit 45
86
+ fi
87
+ if [ ! -x "$sf" ]; then
88
+ echo "$sf not found or it's not executable"
89
+ exit 46
90
+ fi
91
+
92
+ time=$3
93
+ if [ "$time" -gt "0" ]; then
94
+ let "ttime = $time + 30"
95
+ else
96
+ time=1
97
+ ttime=30
98
+ fi
99
+
100
+ nruns=1
101
+ if [ "$4" != "" ]; then
102
+ if [ "$4" -gt "0" ]; then
103
+ nruns=$4
104
+ fi
105
+ fi
106
+ maxm=512000
107
+ if [ "$5" != "" ]; then
108
+ if [ "$5" -gt "0" ]; then
109
+ maxm=${5}000
110
+ fi
111
+ fi
112
+ maxf=1024
113
+ if [ "$6" != "" ]; then
114
+ if [ "$6" -gt "0" ]; then
115
+ maxf=${6}
116
+ fi
117
+ fi
118
+
119
+ cp "$2" stdin0 2>/dev/null
120
+ cp "$1" run.exe 2>/dev/null
121
+ cp ../interactor.exe interactor.exe 2>/dev/null
122
+
123
+ cdir=$(pwd)
124
+ echo "Current directory is $cdir -- chrooting on it" >&2
125
+
126
+ ### START OF BOCA RUN COMMAND
127
+ cat <<EOF >runit.sh
128
+ #!/bin/bash
129
+ mkfifo fifo.in fifo.out
130
+
131
+ echo "Running solution as \$@" >&2
132
+
133
+ "\$@" >fifo.out <fifo.in 2>/dev/null &
134
+ SFPID=\$!
135
+
136
+ ./interactor.exe "stdin0" "stdout0" <fifo.out >fifo.in 2>stderr0 &
137
+ INTPID=\$!
138
+
139
+ wait \$SFPID
140
+ ECSF=\$?
141
+
142
+ wait \$INTPID
143
+ ECINT=\$?
144
+
145
+ rm -rf fifo.in fifo.out
146
+
147
+ echo "interactor \$INTPID -> \$ECINT" >&2
148
+ echo "solution \$SFPID -> \$ECSF" >&2
149
+
150
+ echo "interactor exitcode \$ECINT" >&2
151
+ echo "solution exitcode \$ECSF" >&2
152
+
153
+ ret=0
154
+ if [[ \$ECINT -ge 1 ]] && [[ \$ECINT -le 4 ]]; then
155
+ echo "testlib exitcode \$ECINT" >stdout0
156
+ ret=0
157
+ elif [[ \$ECSF -ne 0 ]]; then
158
+ ret=\$ECSF
159
+ elif [[ \$ECINT -ne 0 ]]; then
160
+ ret=9
161
+ fi
162
+
163
+ exit \$ret
164
+ EOF
165
+
166
+ chmod 755 runit.sh
167
+
168
+ ret=0
169
+ echo $cdir | grep -q "/bocajail"
170
+ if [ $? -eq 0 ]; then
171
+ cdir=$(echo $cdir | sed "s/.*\/bocajail//")
172
+ cat <<EOF >runch.sh
173
+ #!/bin/bash
174
+ cd "$cdir"
175
+ [ -f /proc/cpuinfo ] || /bin/mount -t proc proc /proc
176
+ [ -d /sys/kernel ] || /bin/mount -t sysfs sysfs /sys
177
+ kotlin=$(which kotlin)
178
+ [ -x "\$kotlin" ] || kotlin=/usr/bin/kotlin
179
+ if [ ! -x "\$kotlin" ]; then
180
+ echo "\$kotlin not found or it's not executable"
181
+ exit 47
182
+ fi
183
+ export CLASSPATH=.:./run.jar:$CLASSPATH
184
+ "$sf" -r$nruns -t$time -T$ttime -istdin0 -F512 -u512 -U$bocau -G$bocag -ostdout0 -estderr0 -n0 -C. -d40000000000 -m40000000000 -- "\$kotlin" -cp run.jar -J-Xmx${maxm}K -J-Xss${maxms}K -J-Xms${maxm}K "$name"
185
+ retval=\$?
186
+ echo \$retval > runch.exitcode
187
+ if [ ! -d /bocajail ]; then
188
+ /bin/umount /proc 2>/dev/null
189
+ /bin/umount /sys 2>/dev/null
190
+ fi
191
+ EOF
192
+ chmod 755 runch.sh
193
+ chroot /bocajail $cdir/runch.sh
194
+ if [ -r runch.exitcode ]; then
195
+ ret=$(cat runch.exitcode)
196
+ fi
197
+ if [ "$ret" == "" ]; then
198
+ echo "Execution error - check autojudging"
199
+ exit 49
200
+ fi
201
+ else
202
+ echo "CODE NOT BEING CHROOTED. DO NOT RUN THIS ON THE MAIN SERVER" >&2
203
+ echo "CODE NOT BEING CHROOTED. DO NOT RUN THIS ON THE MAIN SERVER" >&2
204
+ echo "CODE NOT BEING CHROOTED. DO NOT RUN THIS ON THE MAIN SERVER" >&2
205
+ kotlin=$(which kotlin)
206
+ [ -x "$kotlin" ] || kotlin=/usr/bin/kotlin
207
+ if [ ! -x "$kotlin" ]; then
208
+ echo "$kotlin not found or it's not executable"
209
+ exit 47
210
+ fi
211
+ "$sf" -r$nruns -t$time -T$ttime -istdin0 -F512 -u512 -U$bocau -G$bocag -ostdout0 -estderr0 -n0 -C. -d40000000000 -m40000000000 -- "$kotlin" -cp run.jar -J-Xmx${maxm}K -J-Xss${maxms}K -J-Xms${maxm}K "$name"
212
+ ret=$?
213
+ fi
214
+ ### END OF BOCA RUN COMMAND
215
+
216
+ if [ $ret -gt 10 ]; then
217
+ echo "execution error with code $ret" >&2
218
+ if [ -r stderr0 ]; then
219
+ grep -q "not find or load main class" stderr0
220
+ if [ $? == 0 ]; then
221
+ echo "> > > Nonzero return code - possible class name mismatch - do check < < <"
222
+ else
223
+ echo "> > > Nonzero return code - possible runtime error - do check < < <"
224
+ fi
225
+ ret=9
226
+ fi
227
+ fi
228
+ if [ -f stdout0 ]; then
229
+ cat stdout0
230
+ fi
231
+ exit $ret
@@ -0,0 +1,209 @@
1
+ #!/bin/bash
2
+ # ////////////////////////////////////////////////////////////////////////////////
3
+ # //BOCA Online Contest Administrator
4
+ # // Copyright (C) 2003-2014 by BOCA System (bocasystem@gmail.com)
5
+ # //
6
+ # // This program is free software: you can redistribute it and/or modify
7
+ # // it under the terms of the GNU General Public License as published by
8
+ # // the Free Software Foundation, either version 3 of the License, or
9
+ # // (at your option) any later version.
10
+ # //
11
+ # // This program is distributed in the hope that it will be useful,
12
+ # // but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ # // GNU General Public License for more details.
15
+ # // You should have received a copy of the GNU General Public License
16
+ # // along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+ # ////////////////////////////////////////////////////////////////////////////////
18
+ #Last modified: 21/aug/2014 by cassio@ime.usp.br
19
+ #
20
+ # parameters are:
21
+ # $1 exe_file
22
+ # $2 input_file
23
+ # $3 timelimit (limit to run all the repetitions, by default only one repetition)
24
+ # $4 number_of_repetitions_to_run (optional, can be used for better tuning the timelimit)
25
+ # $5 maximum allowed memory (in MBytes)
26
+ # $6 maximum allowed output size (in KBytes)
27
+ #
28
+ # the output of the submission should be directed to the standard output
29
+ #
30
+ # the return code show what happened (according to safeexec):
31
+ # 0 ok
32
+ # 1 compile error
33
+ # 2 runtime error
34
+ # 3 timelimit exceeded
35
+ # 4 internal error
36
+ # 5 parameter error
37
+ # 6 internal error
38
+ # 7 memory limit exceeded
39
+ # 8 security threat
40
+ # 9 runtime error
41
+ # other_codes are unknown to boca: in this case BOCA will present the
42
+ # last line of standard output to the judge
43
+
44
+ umask 0022
45
+ id -u bocajail >/dev/null 2>/dev/null
46
+ if [ $? == 0 ]; then
47
+ bocau=$(id -u bocajail)
48
+ bocag=$(id -g bocajail)
49
+ chown bocajail.nogroup .
50
+ else
51
+ bocau=$(id -u nobody)
52
+ bocag=$(id -g nobody)
53
+ chown nobody.nogroup .
54
+ fi
55
+ if [ "$bocau" == "" -o "$bocag" == "" ]; then
56
+ echo "error finding user to run script"
57
+ exit 43
58
+ fi
59
+
60
+ # this script makes use of safeexec to execute the code with less privilegies
61
+ # make sure that directories below are correct.
62
+ sf=$(which safeexec)
63
+ [ -x "$sf" ] || sf=/usr/bin/safeexec
64
+
65
+ if [ "$1" == "" -o "$2" == "" -o "$3" == "" ]; then
66
+ echo "parameter problem"
67
+ exit 43
68
+ fi
69
+ name=$(basename "$1")
70
+ if [ ! -r "$2" ]; then
71
+ echo "$2 not found (or is not in the current dir) or it's not readable"
72
+ exit 45
73
+ fi
74
+ if [ ! -x "$sf" ]; then
75
+ echo "$sf not found or it's not executable"
76
+ exit 46
77
+ fi
78
+
79
+ time=$3
80
+ if [ "$time" -gt "0" ]; then
81
+ let "ttime = $time + 30"
82
+ else
83
+ time=1
84
+ ttime=30
85
+ fi
86
+
87
+ nruns=1
88
+ if [ "$4" != "" ]; then
89
+ if [ "$4" -gt "0" ]; then
90
+ nruns=$4
91
+ fi
92
+ fi
93
+ maxm=512000
94
+ if [ "$5" != "" ]; then
95
+ if [ "$5" -gt "0" ]; then
96
+ maxm=${5}000
97
+ fi
98
+ fi
99
+ maxf=1024
100
+ if [ "$6" != "" ]; then
101
+ if [ "$6" -gt "0" ]; then
102
+ maxf=${6}
103
+ fi
104
+ fi
105
+
106
+ cp "$2" stdin0 2>/dev/null
107
+ cp "$1" run.exe 2>/dev/null
108
+ cp ../interactor.exe interactor.exe 2>/dev/null
109
+
110
+ cdir=$(pwd)
111
+ echo "Current directory is $cdir -- chrooting on it" >&2
112
+
113
+ ### START OF BOCA RUN COMMAND
114
+ cat <<EOF >runit.sh
115
+ #!/bin/bash
116
+ mkfifo fifo.in fifo.out
117
+
118
+ echo "Running solution as \$@" >&2
119
+
120
+ "\$@" >fifo.out <fifo.in 2>/dev/null &
121
+ SFPID=\$!
122
+
123
+ ./interactor.exe "stdin0" "stdout0" <fifo.out >fifo.in 2>stderr0 &
124
+ INTPID=\$!
125
+
126
+ wait \$SFPID
127
+ ECSF=\$?
128
+
129
+ wait \$INTPID
130
+ ECINT=\$?
131
+
132
+ rm -rf fifo.in fifo.out
133
+
134
+ echo "interactor \$INTPID -> \$ECINT" >&2
135
+ echo "solution \$SFPID -> \$ECSF" >&2
136
+
137
+ echo "interactor exitcode \$ECINT" >&2
138
+ echo "solution exitcode \$ECSF" >&2
139
+
140
+ ret=0
141
+ if [[ \$ECINT -ge 1 ]] && [[ \$ECINT -le 4 ]]; then
142
+ echo "testlib exitcode \$ECINT" >stdout0
143
+ ret=0
144
+ elif [[ \$ECSF -ne 0 ]]; then
145
+ ret=\$ECSF
146
+ elif [[ \$ECINT -ne 0 ]]; then
147
+ ret=9
148
+ fi
149
+
150
+ exit \$ret
151
+ EOF
152
+
153
+ chmod 755 runit.sh
154
+
155
+ ret=0
156
+ echo $cdir | grep -q "/bocajail"
157
+ if [ $? -eq 0 ]; then
158
+ cdir=$(echo $cdir | sed "s/.*\/bocajail//")
159
+ cat <<EOF >runch.sh
160
+ #!/bin/bash
161
+ cd "$cdir"
162
+ [ -f /proc/cpuinfo ] || /bin/mount -t proc proc /proc
163
+ [ -d /sys/kernel ] || /bin/mount -t sysfs sysfs /sys
164
+ python2=$(which python2)
165
+ [ -x "\$python2" ] || python2=/usr/bin/python2
166
+ if [ ! -x "\$python2" ]; then
167
+ echo "\$python2 not found or it's not executable"
168
+ exit 47
169
+ fi
170
+ "$sf" -F256 -u256 -f$maxf -r$nruns -n0 -C. -U$bocau -G$bocag -d$maxm -m$maxm -t$time -T$ttime -ostdout0 -estderr0 -- ./runit.sh "\$python2" "$name"
171
+ retval=\$?
172
+ echo \$retval > runch.exitcode
173
+ if [ ! -d /bocajail ]; then
174
+ /bin/umount /proc 2>/dev/null
175
+ /bin/umount /sys 2>/dev/null
176
+ fi
177
+ EOF
178
+ chmod 755 runch.sh
179
+ chroot /bocajail $cdir/runch.sh
180
+ if [ -r runch.exitcode ]; then
181
+ ret=$(cat runch.exitcode)
182
+ fi
183
+ if [ "$ret" == "" ]; then
184
+ echo "Execution error - check autojudging"
185
+ exit 49
186
+ fi
187
+ else
188
+ echo "CODE NOT BEING CHROOTED. DO NOT RUN THIS ON THE MAIN SERVER" >&2
189
+ echo "CODE NOT BEING CHROOTED. DO NOT RUN THIS ON THE MAIN SERVER" >&2
190
+ echo "CODE NOT BEING CHROOTED. DO NOT RUN THIS ON THE MAIN SERVER" >&2
191
+ python2=$(which python2)
192
+ [ -x "$python2" ] || python2=/usr/bin/python2
193
+ if [ ! -x "$python2" ]; then
194
+ echo "$python2 not found or it's not executable"
195
+ exit 47
196
+ fi
197
+ "$sf" -F256 -u256 -f$maxf -r$nruns -n0 -C. -U$bocau -G$bocag -d$maxm -m$maxm -t$time -T$ttime -ostdout0 -estderr0 -- ./runit.sh "$python2" "$name"
198
+ ret=$?
199
+ fi
200
+ ### END OF BOCA RUN COMMAND
201
+
202
+ if [ $ret -gt 10 ]; then
203
+ echo "execution error with code $ret" >&2
204
+ ret=0
205
+ fi
206
+ if [ -f stdout0 ]; then
207
+ cat stdout0
208
+ fi
209
+ exit $ret
@@ -0,0 +1,209 @@
1
+ #!/bin/bash
2
+ # ////////////////////////////////////////////////////////////////////////////////
3
+ # //BOCA Online Contest Administrator
4
+ # // Copyright (C) 2003-2014 by BOCA System (bocasystem@gmail.com)
5
+ # //
6
+ # // This program is free software: you can redistribute it and/or modify
7
+ # // it under the terms of the GNU General Public License as published by
8
+ # // the Free Software Foundation, either version 3 of the License, or
9
+ # // (at your option) any later version.
10
+ # //
11
+ # // This program is distributed in the hope that it will be useful,
12
+ # // but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ # // GNU General Public License for more details.
15
+ # // You should have received a copy of the GNU General Public License
16
+ # // along with this program. If not, see <http://www.gnu.org/licenses/>.
17
+ # ////////////////////////////////////////////////////////////////////////////////
18
+ #Last modified: 21/aug/2014 by cassio@ime.usp.br
19
+ #
20
+ # parameters are:
21
+ # $1 exe_file
22
+ # $2 input_file
23
+ # $3 timelimit (limit to run all the repetitions, by default only one repetition)
24
+ # $4 number_of_repetitions_to_run (optional, can be used for better tuning the timelimit)
25
+ # $5 maximum allowed memory (in MBytes)
26
+ # $6 maximum allowed output size (in KBytes)
27
+ #
28
+ # the output of the submission should be directed to the standard output
29
+ #
30
+ # the return code show what happened (according to safeexec):
31
+ # 0 ok
32
+ # 1 compile error
33
+ # 2 runtime error
34
+ # 3 timelimit exceeded
35
+ # 4 internal error
36
+ # 5 parameter error
37
+ # 6 internal error
38
+ # 7 memory limit exceeded
39
+ # 8 security threat
40
+ # 9 runtime error
41
+ # other_codes are unknown to boca: in this case BOCA will present the
42
+ # last line of standard output to the judge
43
+
44
+ umask 0022
45
+ id -u bocajail >/dev/null 2>/dev/null
46
+ if [ $? == 0 ]; then
47
+ bocau=$(id -u bocajail)
48
+ bocag=$(id -g bocajail)
49
+ chown bocajail.nogroup .
50
+ else
51
+ bocau=$(id -u nobody)
52
+ bocag=$(id -g nobody)
53
+ chown nobody.nogroup .
54
+ fi
55
+ if [ "$bocau" == "" -o "$bocag" == "" ]; then
56
+ echo "error finding user to run script"
57
+ exit 43
58
+ fi
59
+
60
+ # this script makes use of safeexec to execute the code with less privilegies
61
+ # make sure that directories below are correct.
62
+ sf=$(which safeexec)
63
+ [ -x "$sf" ] || sf=/usr/bin/safeexec
64
+
65
+ if [ "$1" == "" -o "$2" == "" -o "$3" == "" ]; then
66
+ echo "parameter problem"
67
+ exit 43
68
+ fi
69
+ name=$(basename "$1")
70
+ if [ ! -r "$2" ]; then
71
+ echo "$2 not found (or is not in the current dir) or it's not readable"
72
+ exit 45
73
+ fi
74
+ if [ ! -x "$sf" ]; then
75
+ echo "$sf not found or it's not executable"
76
+ exit 46
77
+ fi
78
+
79
+ time=$3
80
+ if [ "$time" -gt "0" ]; then
81
+ let "ttime = $time + 30"
82
+ else
83
+ time=1
84
+ ttime=30
85
+ fi
86
+
87
+ nruns=1
88
+ if [ "$4" != "" ]; then
89
+ if [ "$4" -gt "0" ]; then
90
+ nruns=$4
91
+ fi
92
+ fi
93
+ maxm=512000
94
+ if [ "$5" != "" ]; then
95
+ if [ "$5" -gt "0" ]; then
96
+ maxm=${5}000
97
+ fi
98
+ fi
99
+ maxf=1024
100
+ if [ "$6" != "" ]; then
101
+ if [ "$6" -gt "0" ]; then
102
+ maxf=${6}
103
+ fi
104
+ fi
105
+
106
+ cp "$2" stdin0 2>/dev/null
107
+ cp "$1" run.exe 2>/dev/null
108
+ cp ../interactor.exe interactor.exe 2>/dev/null
109
+
110
+ cdir=$(pwd)
111
+ echo "Current directory is $cdir -- chrooting on it" >&2
112
+
113
+ ### START OF BOCA RUN COMMAND
114
+ cat <<EOF >runit.sh
115
+ #!/bin/bash
116
+ mkfifo fifo.in fifo.out
117
+
118
+ echo "Running solution as \$@" >&2
119
+
120
+ "\$@" >fifo.out <fifo.in 2>/dev/null &
121
+ SFPID=\$!
122
+
123
+ ./interactor.exe "stdin0" "stdout0" <fifo.out >fifo.in 2>stderr0 &
124
+ INTPID=\$!
125
+
126
+ wait \$SFPID
127
+ ECSF=\$?
128
+
129
+ wait \$INTPID
130
+ ECINT=\$?
131
+
132
+ rm -rf fifo.in fifo.out
133
+
134
+ echo "interactor \$INTPID -> \$ECINT" >&2
135
+ echo "solution \$SFPID -> \$ECSF" >&2
136
+
137
+ echo "interactor exitcode \$ECINT" >&2
138
+ echo "solution exitcode \$ECSF" >&2
139
+
140
+ ret=0
141
+ if [[ \$ECINT -ge 1 ]] && [[ \$ECINT -le 4 ]]; then
142
+ echo "testlib exitcode \$ECINT" >stdout0
143
+ ret=0
144
+ elif [[ \$ECSF -ne 0 ]]; then
145
+ ret=\$ECSF
146
+ elif [[ \$ECINT -ne 0 ]]; then
147
+ ret=9
148
+ fi
149
+
150
+ exit \$ret
151
+ EOF
152
+
153
+ chmod 755 runit.sh
154
+
155
+ ret=0
156
+ echo $cdir | grep -q "/bocajail"
157
+ if [ $? -eq 0 ]; then
158
+ cdir=$(echo $cdir | sed "s/.*\/bocajail//")
159
+ cat <<EOF >runch.sh
160
+ #!/bin/bash
161
+ cd "$cdir"
162
+ [ -f /proc/cpuinfo ] || /bin/mount -t proc proc /proc
163
+ [ -d /sys/kernel ] || /bin/mount -t sysfs sysfs /sys
164
+ python3=$(which python3)
165
+ [ -x "\$python3" ] || python3=/usr/bin/python3
166
+ if [ ! -x "\$python3" ]; then
167
+ echo "\$python3 not found or it's not executable"
168
+ exit 47
169
+ fi
170
+ "$sf" -F256 -u256 -f$maxf -r$nruns -n0 -C. -U$bocau -G$bocag -d$maxm -m$maxm -t$time -T$ttime -ostdout0 -estderr0 -- ./runit.sh "\$python3" "$name"
171
+ retval=\$?
172
+ echo \$retval > runch.exitcode
173
+ if [ ! -d /bocajail ]; then
174
+ /bin/umount /proc 2>/dev/null
175
+ /bin/umount /sys 2>/dev/null
176
+ fi
177
+ EOF
178
+ chmod 755 runch.sh
179
+ chroot /bocajail $cdir/runch.sh
180
+ if [ -r runch.exitcode ]; then
181
+ ret=$(cat runch.exitcode)
182
+ fi
183
+ if [ "$ret" == "" ]; then
184
+ echo "Execution error - check autojudging"
185
+ exit 49
186
+ fi
187
+ else
188
+ echo "CODE NOT BEING CHROOTED. DO NOT RUN THIS ON THE MAIN SERVER" >&2
189
+ echo "CODE NOT BEING CHROOTED. DO NOT RUN THIS ON THE MAIN SERVER" >&2
190
+ echo "CODE NOT BEING CHROOTED. DO NOT RUN THIS ON THE MAIN SERVER" >&2
191
+ python3=$(which python3)
192
+ [ -x "$python3" ] || python3=/usr/bin/python3
193
+ if [ ! -x "$python3" ]; then
194
+ echo "$python3 not found or it's not executable"
195
+ exit 47
196
+ fi
197
+ "$sf" -F256 -u256 -f$maxf -r$nruns -n0 -C. -U$bocau -G$bocag -d$maxm -m$maxm -t$time -T$ttime -ostdout0 -estderr0 -- ./runit.sh "$python3" "$name"
198
+ ret=$?
199
+ fi
200
+ ### END OF BOCA RUN COMMAND
201
+
202
+ if [ $ret -gt 10 ]; then
203
+ echo "execution error with code $ret" >&2
204
+ ret=0
205
+ fi
206
+ if [ -f stdout0 ]; then
207
+ cat stdout0
208
+ fi
209
+ exit $ret
@@ -0,0 +1,45 @@
1
+ ### START OF INTERACTOR COMPILATION
2
+ # Assumes testlib was added by checker
3
+ INTERACTOR_PATH="interactor.cpp"
4
+ INTERACTOR_OUT="interactor.exe"
5
+
6
+ function LOG() {
7
+ echo "$*" >&2
8
+ }
9
+
10
+ # find compiler
11
+ cc=$(which g++)
12
+ [ -x "$cc" ] || cc=/usr/bin/g++
13
+ if [ ! -x "$cc" ]; then
14
+ echo "$cc not found or it's not executable"
15
+ exit 47
16
+ fi
17
+
18
+ read -r -d '' InteractorContent <<"EOF"
19
+ {{interactor_content}}
20
+ EOF
21
+
22
+ printf "%s" "${InteractorContent}" >$INTERACTOR_PATH
23
+
24
+ interactor_hash=($(md5sum $INTERACTOR_PATH))
25
+ interactor_cache="/tmp/boca-int-${interactor_hash}"
26
+
27
+ echo "Interactor hash: $interactor_hash"
28
+ echo "Copying interactor to $CDIR/$INTERACTOR_OUT"
29
+ if [ -f "$interactor_cache" ]; then
30
+ echo "Recovering interactor from cache: $interactor_cache"
31
+ cp "$interactor_cache" $INTERACTOR_OUT -f
32
+ else
33
+ echo "Compiling interactor: $INTERACTOR_PATH"
34
+ $cc {{rbxFlags}} $INTERACTOR_PATH -o $INTERACTOR_OUT
35
+
36
+ if [ $? -ne 0 ]; then
37
+ echo "Interactor could not be compiled"
38
+ exit 47
39
+ fi
40
+
41
+ cp $INTERACTOR_OUT "$interactor_cache" -f
42
+ fi
43
+
44
+ chmod 0755 $INTERACTOR_OUT
45
+ ### END OF INTERACTOR COMPILATION