From 290ab612a951f67bd0f4358a60899519d7979e24 Mon Sep 17 00:00:00 2001 From: Mateusz Masiarz Date: Wed, 6 Sep 2023 15:28:42 +0200 Subject: [PATCH 1/4] Pass input test's name to inwer --- sio/executors/inwer.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sio/executors/inwer.py b/sio/executors/inwer.py index 9ed90ae..8cb8b4f 100644 --- a/sio/executors/inwer.py +++ b/sio/executors/inwer.py @@ -32,7 +32,7 @@ def _run_in_executor(environ, command, executor, **kwargs): def _run_inwer(environ, use_sandboxes=False): - command = [tempcwd('inwer')] + command = [tempcwd('inwer'), environ['in_file_name']] if use_sandboxes: executor = SupervisedExecutor() else: @@ -49,6 +49,9 @@ def run(environ): ``in_file``: the file redirected to the program's stdin + ``in_file_name``: the name of the input file. It's passed to inwer as + the second argument. + ``use_sandboxes``: if this key equals ``True``, the program is executed in the SupervisedExecutor, otherwise the UnsafeExecutor is used From de90a70eead0df7992ae78a24af2afab6fc6e954 Mon Sep 17 00:00:00 2001 From: Mateusz Masiarz Date: Wed, 6 Sep 2023 18:19:33 +0200 Subject: [PATCH 2/4] Fix tests --- sio/workers/test/test_executors.py | 1 + 1 file changed, 1 insertion(+) diff --git a/sio/workers/test/test_executors.py b/sio/workers/test/test_executors.py index 233a20f..995c49d 100644 --- a/sio/workers/test/test_executors.py +++ b/sio/workers/test/test_executors.py @@ -449,6 +449,7 @@ def test_inwer(inwer, in_file, use_sandboxes, callback): with TemporaryCwd(): env = { 'in_file': in_file, + 'in_file_name': os.path.basename(in_file), 'exe_file': inwer_bin, 'use_sandboxes': use_sandboxes, 'inwer_output_limit': SMALL_OUTPUT_LIMIT, From 26f83a7bb5f9bc94a36238ccf9439417439d0b43 Mon Sep 17 00:00:00 2001 From: Mateusz Masiarz Date: Wed, 6 Sep 2023 18:39:59 +0200 Subject: [PATCH 3/4] Add inwer tests for passing test name as an argument --- sio/workers/test/sources/inwer_argument.c | 14 ++++++++++++++ sio/workers/test/test_executors.py | 2 ++ 2 files changed, 16 insertions(+) create mode 100644 sio/workers/test/sources/inwer_argument.c diff --git a/sio/workers/test/sources/inwer_argument.c b/sio/workers/test/sources/inwer_argument.c new file mode 100644 index 0000000..6283f69 --- /dev/null +++ b/sio/workers/test/sources/inwer_argument.c @@ -0,0 +1,14 @@ +#include + +int main(int argc, char *argv[]) { + if (argc != 2) { + printf("WRONG\nWrong number of arguments"); + return 1; + } + if (strcmp(argv[1], "inwer_ok") != 0) { + printf("WRONG\nWrong test name"); + return 1; + } + printf("OK\n"); + return 0; +} diff --git a/sio/workers/test/test_executors.py b/sio/workers/test/test_executors.py index 995c49d..1a43de7 100644 --- a/sio/workers/test/test_executors.py +++ b/sio/workers/test/test_executors.py @@ -436,6 +436,8 @@ def inner(env): yield '/inwer_big_output.c', '/inwer_ok', use_sandboxes, check_inwer_big_output( use_sandboxes ) + yield '/inwer_argument.c', '/inwer_ok', use_sandboxes, check_inwer_ok + yield '/inwer_argument.c', '/inwer_wrong', use_sandboxes, check_inwer_wrong @pytest.mark.parametrize( From 18ba3e4434b2cc067cba0ec3593a4050dfd5d9d2 Mon Sep 17 00:00:00 2001 From: Mateusz Masiarz Date: Thu, 16 Nov 2023 20:10:57 +0100 Subject: [PATCH 4/4] Check if 'in_file_name' exists in environ --- sio/executors/inwer.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sio/executors/inwer.py b/sio/executors/inwer.py index 8cb8b4f..a163ac0 100644 --- a/sio/executors/inwer.py +++ b/sio/executors/inwer.py @@ -32,7 +32,9 @@ def _run_in_executor(environ, command, executor, **kwargs): def _run_inwer(environ, use_sandboxes=False): - command = [tempcwd('inwer'), environ['in_file_name']] + command = [tempcwd('inwer')] + if 'in_file_name' in environ: + command.append(environ['in_file_name']) if use_sandboxes: executor = SupervisedExecutor() else: