mirror of
https://github.com/QingdaoU/Judger.git
synced 2024-12-29 00:11:41 +00:00
返回 exit_status 并增加相关测试用例
This commit is contained in:
parent
b50775c417
commit
b6255b4c96
6
judger.c
6
judger.c
@ -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);
|
||||
|
||||
}
|
||||
|
||||
|
1
runner.c
1
runner.c
@ -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 +
|
||||
|
1
runner.h
1
runner.h
@ -32,6 +32,7 @@ struct result {
|
||||
int real_time;
|
||||
int signal;
|
||||
int flag;
|
||||
int exit_status;
|
||||
};
|
||||
|
||||
|
||||
|
15
tests/15/Main.c
Normal file
15
tests/15/Main.c
Normal 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
1
tests/15/config
Normal file
@ -0,0 +1 @@
|
||||
{"language": "c", "max_cpu_time": 2000, "max_memory": 20000000}
|
1
tests/15/in
Normal file
1
tests/15/in
Normal file
@ -0,0 +1 @@
|
||||
1234567890
|
2
tests/15/out
Normal file
2
tests/15/out
Normal file
@ -0,0 +1,2 @@
|
||||
1234567890
|
||||
1234567890
|
1
tests/15/result
Normal file
1
tests/15/result
Normal file
@ -0,0 +1 @@
|
||||
{"flag": 4, "signal": 0, "exit_status": 17}
|
Loading…
Reference in New Issue
Block a user