Skip to content

Commit

Permalink
Add tests for sio2jail with measuring real-time
Browse files Browse the repository at this point in the history
  • Loading branch information
otargowski committed Dec 3, 2024
1 parent 52bb933 commit 3bd6350
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 17 deletions.
1 change: 1 addition & 0 deletions sio/workers/test/sources/openrw.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <fcntl.h>
#include <unistd.h>

int main() {
char ch[] = "1337";
Expand Down
37 changes: 20 additions & 17 deletions sio/workers/test/test_executors.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
SandboxExecutor,
SupervisedExecutor,
Sio2JailExecutor,
RealTimeSio2JailExecutor,
ExecError,
)
from sio.workers.file_runners import get_file_runner
Expand Down Expand Up @@ -137,7 +138,10 @@ def fail(*args, **kwargs):
SANDBOXED_CHECKING_EXECUTORS = [SupervisedExecutor]

if not NO_SIO2JAIL_TESTS:
SANDBOXED_CHECKING_EXECUTORS.append(Sio2JailExecutor)
SANDBOXED_CHECKING_EXECUTORS += (
Sio2JailExecutor,
RealTimeSio2JailExecutor,
)

# Status helpers
def res_ok(env):
Expand Down Expand Up @@ -290,8 +294,12 @@ def _make_common_time_limiting_cases():
yield '/time_verylong.java', 5000, executor(), res_ok

if issubclass(executor, Sio2JailExecutor):
yield "/time_s2j_200ms.c", 100, executor(), res_tle
yield "/time_s2j_200ms.c", 1000, executor(), res_ok
if issubclass(executor, RealTimeSio2JailExecutor):
yield "/time_verylong.c", 100, executor(), res_tle
yield "/time_verylong.c", 10000, executor(), res_ok
else:
yield "/time_s2j_200ms.c", 100, executor(), res_tle
yield "/time_s2j_200ms.c", 1000, executor(), res_ok

@pytest.mark.parametrize(
"source,time_limit,executor,callback",
Expand Down Expand Up @@ -794,22 +802,17 @@ def syscall_limit(env):
in_('syscalls', env['result_string'])

checking_executors = CHECKING_EXECUTORS
if ENABLE_SANDBOXES and not NO_SIO2JAIL_TESTS:
checking_executors.append(RealTimeSio2JailExecutor)

for executor in checking_executors:
yield [
'/time_infinite.c',
executor(),
real_tle,
{'real_time_limit': 1000, 'time_limit': 10000},
]

for executor in CHECKING_EXECUTORS:
yield [
'/iospam.c',
executor(),
real_tle,
{'real_time_limit': 1000, 'time_limit': 10000},
]
for file in ('/time_infinite.c', '/iospam.c'):
yield [
file,
executor(),
real_tle,
{'real_time_limit': 1000, 'time_limit': 10000},
]


@pytest.mark.parametrize(
Expand Down

0 comments on commit 3bd6350

Please sign in to comment.