judge: use /dev/null

pull/56/head
undefined 4 years ago
parent e670f703f1
commit e3355aa43c

@ -1,7 +1,10 @@
{
"name": "@hydrooj/hydrojudge",
"bin": "bin/hydrojudge.js",
"version": "2.4.3",
"version": "2.4.4",
"os": [
"linux"
],
"main": "package.json",
"author": "undefined <i@undefined.moe>",
"repository": "https://github.com/hydro-dev/Hydro.git",

@ -235,8 +235,8 @@ export async function readYamlCases(folder: string, cfg: Dictionary<any> = {}, a
for (const c of cfg.cases) {
config.count++;
config.subtasks[0].cases.push({
input: c.input ? checkFile(c.input, 'Cannot find input file {0}.') : null,
output: c.output ? checkFile(c.output, 'Cannot find output file {0}.') : null,
input: c.input ? checkFile(c.input, 'Cannot find input file {0}.') : '/dev/null',
output: c.output ? checkFile(c.output, 'Cannot find output file {0}.') : '/dev/null',
id: config.count,
});
}
@ -246,8 +246,8 @@ export async function readYamlCases(folder: string, cfg: Dictionary<any> = {}, a
for (const c of subtask.cases) {
config.count++;
cases.push({
input: c.input ? checkFile(c.input, 'Cannot find input file {0}.') : null,
output: c.output ? checkFile(c.output, 'Cannot find output file {0}.') : null,
input: c.input ? checkFile(c.input, 'Cannot find input file {0}.') : '/dev/null',
output: c.output ? checkFile(c.output, 'Cannot find output file {0}.') : '/dev/null',
id: config.count,
});
}

@ -111,6 +111,7 @@ export const judge = async (ctx) => {
);
})(),
]);
ctx.clean.push(ctx.executeUser.clean, ctx.executeInteractor.clean);
ctx.next({ status: STATUS.STATUS_JUDGING, progress: 0 });
const tasks = [];
ctx.total_status = ctx.total_score = ctx.total_memory_usage_kb = ctx.total_time_usage_ms = 0;

@ -10,6 +10,7 @@ import { Logger } from './log';
const logger = new Logger('sandbox');
const env = ['PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', 'HOME=/w'];
const axios = Axios.create({ baseURL: getConfig('sandbox_host') });
let callId = 0;
const statusMap = {
'Time Limit Exceeded': STATUS.STATUS_TIME_LIMIT_EXCEEDED,
@ -90,9 +91,10 @@ export async function runMultiple(execute) {
body.cmd[0].files[1] = null;
body.cmd[1].files[0] = null;
body.cmd[1].files[1] = null;
if (argv['show-sandbox-call']) logger.debug(JSON.stringify(body));
const id = callId++;
if (argv['show-sandbox-call']) logger.debug('%d %s', id, JSON.stringify(body));
res = await axios.post('/run', body);
if (argv['show-sandbox-call']) logger.debug(JSON.stringify(res.data));
if (argv['show-sandbox-call']) logger.debug('%d %s', id, JSON.stringify(res.data));
} catch (e) {
throw new SystemError('Sandbox Error');
}
@ -111,9 +113,10 @@ export async function run(execute, params?) {
if (typeof execute === 'object') return await runMultiple(execute);
try {
const body = { cmd: [proc({ execute, ...params })] };
if (argv['show-sandbox-call']) logger.debug(JSON.stringify(body));
const id = callId++;
if (argv['show-sandbox-call']) logger.debug('%d %s', id, JSON.stringify(body));
const res = await axios.post('/run', body);
if (argv['show-sandbox-call']) logger.debug(JSON.stringify(res.data));
if (argv['show-sandbox-call']) logger.debug('%d %s', id, JSON.stringify(res.data));
[result] = res.data;
} catch (e) {
// FIXME request body larger than maxBodyLength limit

Loading…
Cancel
Save