def test_outputting_non_utf8(): if ENABLE_SANDBOXES: with TemporaryCwd(): upload_files() renv = compile_and_run('/output-non-utf8.c', { 'in_file': '/input', 'check_output': True, 'hint_file': '/input', }, SupervisedExecutor(), use_sandboxes=True) print_env(renv) in_('42', renv['result_string']) ok_(renv['result_string'])
def test_uploading_out(): with TemporaryCwd(): upload_files() renv = compile_and_run('/add_print.c', { 'in_file': '/input', 'out_file': '/output', 'upload_out': True, }, DetailedUnprotectedExecutor()) print_env(renv) ft.download({'path': '/output'}, 'path', 'd_out') in_('84', open(tempcwd('d_out')).read())
def inner(env): eq_(env['return_code'], 0) eq_(env['stdout'], expected_output) collected = env['collected_files'] eq_(len(expected_files), len(collected)) for filename, path in six.iteritems(collected): in_(filename, expected_files) unversioned_path = '/%s/%s' % (upload_dir, filename) upload_re_str = '%s@\d+' % (unversioned_path) upload_re = re.compile(upload_re_str) ok_(upload_re.match(path), 'Unexpected filetracker path') ft.download({'in': unversioned_path}, 'in', filename) eq_(expected_files[filename], open(tempcwd(filename)).read())
def test_execute(): with TemporaryCwd(): rc, out = execute(['echo', '2']) eq_(rc, 0) eq_(out, b'2\n') rc, out = execute(['exit', '1'], ignore_errors=True) eq_(rc, 1) assert_raises(ExecError, execute, ['exit', '1']) rc, out = execute(['mkdir', tempcwd('spam')]) eq_(rc, 0) rc, out = execute(['ls', tempcwd()]) in_(b'spam', out)
def inner(env): eq_(env['return_code'], 0) eq_(env['stdout'], expected_output) collected = env['collected_files'] eq_(len(expected_files), len(collected)) for filename, path in six.iteritems(collected): in_(filename, expected_files) unversioned_path = '/%s/%s' % (upload_dir, filename) upload_re_str = r'%s@\d+' % (unversioned_path) upload_re = re.compile(upload_re_str) ok_(upload_re.match(path), 'Unexpected filetracker path') ft.download({'in': unversioned_path}, 'in', filename) eq_(expected_files[filename], open(tempcwd(filename)).read())
def with_stderr(env): in_(b'stdout', env['stdout']) in_(b'stderr', env['stdout'])
def only_stdout(env): in_(b'stdout', env['stdout']) not_in_(b'stderr', env['stdout'])
def inner(env): res_re('due to signal')(env) in_(str(code), env['result_string'])
def check_inwer_wrong(env): not_eq_(env['result_code'], "OK") in_(b"WRONG", env['stdout'][0])
def inner(env): eq_('RV', env['result_code']) in_(msg, env['result_string'])
def syscall_limit(env): eq_('TLE', env['result_code']) in_('syscalls', env['result_string'])
def inner(env): eq_('RE', env['result_code']) in_(str(reason), env['result_string'])