5
5
from sio .assertion_utils import ok_ , eq_
6
6
from sio .compilers .job import run as run_compiler
7
7
import sio .executors .unsafe_exec
8
+ import sio .executors .sio2jail_exec
8
9
from sio .testing_utils import str_to_bool
9
10
from sio .workers import ft
10
11
from sio .workers .util import TemporaryCwd , tempcwd
11
12
12
13
13
14
15
+ EXECUTORS = {
16
+ 'sio2jail' : sio .executors .sio2jail_exec ,
17
+ 'unsafe' : sio .executors .unsafe_exec
18
+ }
14
19
# Stolen from a sample problem package I used to test the encdec
15
- EXECUTORS = {'unsafe' : sio .executors .unsafe_exec }
16
20
RLE_TESTS = ['0a' , '1' ]
17
21
SOURCES = os .path .join (os .path .abspath (os .path .dirname (__file__ )), 'sources' )
18
22
@@ -41,11 +45,13 @@ def common_preparations():
41
45
42
46
def compile_file (file ):
43
47
with TemporaryCwd ('compile_code' ):
44
- run_compiler ({
48
+ renv = run_compiler ({
45
49
'source_file' : '/%s.cpp' % file ,
46
50
'compiler' : 'system-cpp' ,
47
51
'out_file' : '/%s.e' % file ,
48
52
})
53
+ eq_ (renv ['result_code' ], 'OK' )
54
+ return renv
49
55
50
56
51
57
def in_ (a , b , msg = None ):
@@ -54,11 +60,12 @@ def in_(a, b, msg=None):
54
60
raise AssertionError (msg or "%r not in %r" % (a , b ))
55
61
56
62
57
- def make_run_env (file , test , new_settings = None ):
63
+ def make_run_env (compile_renv , file , test , new_settings = None ):
58
64
result = {
59
65
'chn_file' : '/rlechn.e' ,
60
66
'chk_file' : '/rlechk.e' ,
61
67
'exe_file' : '/%s.e' % file ,
68
+ 'exec_info' : compile_renv ['exec_info' ],
62
69
'hint_file' : '/rle%s.hint' % test ,
63
70
'in_file' : '/rle%s.in' % test ,
64
71
'encoder_memory_limit' : '65536' ,
@@ -84,11 +91,12 @@ def print_env(env):
84
91
85
92
86
93
def run_all_configurations (file , func , new_settings = None ):
94
+ compile_renv = compile_file (file )
87
95
for execname , executor in EXECUTORS .items ():
88
96
for t in RLE_TESTS :
89
97
with TemporaryCwd ('run_%s_%s' % (execname , t )):
90
98
print ('Running test %s under executor %s' % (t , execname ))
91
- renv = executor .encdec_run (make_run_env (file , t , new_settings (execname , t ) if new_settings else None ))
99
+ renv = executor .encdec_run (make_run_env (compile_renv , file , t , new_settings (execname , t ) if new_settings else None ))
92
100
print_env (renv )
93
101
func (execname , t , renv )
94
102
@@ -104,7 +112,6 @@ def upload_files():
104
112
105
113
def test_encdec_run ():
106
114
common_preparations ()
107
- compile_file ('rle' )
108
115
def check (execname , t , renv ):
109
116
not_in_ ('failed_step' , renv )
110
117
eq_ (renv ['checker_result_percentage' ], 100. )
@@ -113,7 +120,6 @@ def check(execname, t, renv):
113
120
114
121
def test_encdec_encoder_timeout ():
115
122
common_preparations ()
116
- compile_file ('rleloopenc' )
117
123
def check (execname , t , renv ):
118
124
eq_ (renv ['failed_step' ], 'encoder' )
119
125
eq_ (renv ['encoder_result_code' ], 'TLE' )
@@ -122,17 +128,39 @@ def check(execname, t, renv):
122
128
123
129
def test_encdec_encoder_outofmem ():
124
130
common_preparations ()
125
- compile_file ('rlememenc' )
126
131
def check (execname , t , renv ):
127
132
eq_ (renv ['failed_step' ], 'encoder' )
128
133
in_ (renv ['encoder_result_code' ], ('MLE' , 'RE' ))
129
134
run_all_configurations ('rlememenc' , check )
130
135
131
136
137
+ def test_encdec_encoder_crash ():
138
+ common_preparations ()
139
+ def check (execname , t , renv ):
140
+ eq_ (renv ['failed_step' ], 'encoder' )
141
+ in_ (renv ['encoder_result_code' ], ('RE' ))
142
+ run_all_configurations ('rlecrashenc' , check )
143
+
144
+
132
145
def test_encdec_decoder_timeout ():
133
146
common_preparations ()
134
- compile_file ('rleloopdec' )
135
147
def check (execname , t , renv ):
136
148
eq_ (renv ['failed_step' ], 'decoder' )
137
149
eq_ (renv ['decoder_result_code' ], 'TLE' )
138
150
run_all_configurations ('rleloopdec' , check )
151
+
152
+
153
+ def test_encdec_decoder_outofmem ():
154
+ common_preparations ()
155
+ def check (execname , t , renv ):
156
+ eq_ (renv ['failed_step' ], 'decoder' )
157
+ in_ (renv ['decoder_result_code' ], ('MLE' , 'RE' ))
158
+ run_all_configurations ('rlememdec' , check )
159
+
160
+
161
+ def test_encdec_decoder_crash ():
162
+ common_preparations ()
163
+ def check (execname , t , renv ):
164
+ eq_ (renv ['failed_step' ], 'decoder' )
165
+ in_ (renv ['decoder_result_code' ], ('RE' ))
166
+ run_all_configurations ('rlecrashdec' , check )
0 commit comments