Testing: add subprocess resource limits (M-TESTING-05)
This commit is contained in:
1 parent
80e6ed9afc
commit
404bf4ce2f
4 files changed
+71
No files matched your search
@@ -287,4 +287,23 @@ Void::Testing::Test testing_subprocess_isolation_exit_crash_timeout_and_flood()
|
||||
expect_eq(res.stdout_captured.size(), std::size_t{4096});
|
||||
expect_eq(res.stderr_captured.size(), std::size_t{4096});
|
||||
}
|
||||
|
||||
// 7. Resource limits: a large allocation fails under a tight address-space
|
||||
// cap instead of succeeding.
|
||||
{
|
||||
const std::vector<std::string> args{"--selftest-child", "alloc"};
|
||||
const auto uncapped = run_isolated_subprocess(exe, args);
|
||||
expect(uncapped.outcome == ProcessOutcome::passed);
|
||||
|
||||
const auto capped = run_isolated_subprocess(
|
||||
exe, args,
|
||||
ProcessTestOptions{
|
||||
.timeout = std::chrono::milliseconds{5000},
|
||||
.max_output_bytes = 4096,
|
||||
.resources = ProcessResourceLimits{
|
||||
.address_space_bytes = 64ULL * 1024ULL * 1024ULL},
|
||||
});
|
||||
expect(capped.outcome == ProcessOutcome::crashed ||
|
||||
capped.outcome == ProcessOutcome::failed);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user