返回 exit_status 并增加相关测试用例

This commit is contained in:
virusdefender 2016-02-02 11:53:42 +08:00
parent b50775c417
commit b6255b4c96
8 changed files with 25 additions and 3 deletions

View File

@ -4,7 +4,7 @@
static PyObject *judger_run(PyObject *self, PyObject *args, PyObject *kwargs) {
struct config config;
struct result result = {0, 0, 0, 0, 0};
struct result result = {0, 0, 0, 0, 0, 0};
PyObject *args_list = NULL, *env_list = NULL, *use_sandbox = NULL, *next = NULL, *args_iter = NULL, *env_iter = NULL;
int count = 0;
static char *kwargs_list[] = {"path", "in_file", "out_file", "max_cpu_time",
@ -90,9 +90,9 @@ static PyObject *judger_run(PyObject *self, PyObject *args, PyObject *kwargs) {
}
run(&config, &result);
return Py_BuildValue("{s:i, s:l, s:i, s:i, s:i}",
return Py_BuildValue("{s:i, s:l, s:i, s:i, s:i, s:i}",
"cpu_time", result.cpu_time, "memory", result.memory, "real_time", result.real_time, "signal",
result.signal, "flag", result.flag);
result.signal, "flag", result.flag, "exit_status", result.exit_status);
}

View File

@ -73,6 +73,7 @@ void run(struct config *config, struct result *result) {
return;
}
LOG_DEBUG("exit status: %d", WEXITSTATUS(status));
result->exit_status = WEXITSTATUS(status);
result->cpu_time = (int) (resource_usage.ru_utime.tv_sec * 1000 +
resource_usage.ru_utime.tv_usec / 1000 +
resource_usage.ru_stime.tv_sec * 1000 +

View File

@ -32,6 +32,7 @@ struct result {
int real_time;
int signal;
int flag;
int exit_status;
};

15
tests/15/Main.c Normal file
View File

@ -0,0 +1,15 @@
/*
*
*/
#include <stdio.h>
#include <string.h>
int main()
{
char input[100];
scanf("%s", input);
fprintf(stdout, "%s\n", input);
fprintf(stderr, "%s\n", input);
return 17;
}

1
tests/15/config Normal file
View File

@ -0,0 +1 @@
{"language": "c", "max_cpu_time": 2000, "max_memory": 20000000}

1
tests/15/in Normal file
View File

@ -0,0 +1 @@
1234567890

2
tests/15/out Normal file
View File

@ -0,0 +1,2 @@
1234567890
1234567890

1
tests/15/result Normal file
View File

@ -0,0 +1 @@
{"flag": 4, "signal": 0, "exit_status": 17}