2022-05-02 17:50:57 +00:00
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
use Setup;
|
|
|
|
use Test2::V0;
|
|
|
|
use Hydra::Helper::Exec;
|
|
|
|
|
2022-05-02 19:13:59 +00:00
|
|
|
my $sd_res;
|
2022-05-02 18:40:13 +00:00
|
|
|
eval {
|
2022-05-02 19:13:59 +00:00
|
|
|
($sd_res) = captureStdoutStderr(3, (
|
2022-05-02 18:40:13 +00:00
|
|
|
"systemd-run",
|
|
|
|
"--user",
|
|
|
|
"--collect",
|
|
|
|
"--scope",
|
|
|
|
"--property",
|
|
|
|
"MemoryMax=25M",
|
|
|
|
"--",
|
|
|
|
"true"
|
|
|
|
));
|
|
|
|
} or do {
|
2022-05-02 19:13:59 +00:00
|
|
|
skip_all("`systemd-run` failed when invoked in this environment");
|
2022-05-02 18:40:13 +00:00
|
|
|
};
|
2022-05-02 19:13:59 +00:00
|
|
|
if ($sd_res != 0) { skip_all("`systemd-run` returned non-zero when executing `true` (expected 0)"); }
|
2022-05-02 18:08:50 +00:00
|
|
|
|
2022-05-02 19:14:46 +00:00
|
|
|
my $ctx = test_context();
|
|
|
|
|
2022-05-02 18:40:13 +00:00
|
|
|
my ($res, $stdout, $stderr) = captureStdoutStderr(60, (
|
|
|
|
"systemd-run",
|
|
|
|
"--user",
|
|
|
|
"--collect",
|
|
|
|
"--scope",
|
|
|
|
"--property",
|
|
|
|
"MemoryMax=25M",
|
|
|
|
"--",
|
|
|
|
"hydra-eval-jobs",
|
|
|
|
"-I", "/dev/zero",
|
2022-05-02 19:14:46 +00:00
|
|
|
"-I", $ctx->jobsdir,
|
|
|
|
($ctx->jobsdir . "/oom.nix")
|
2022-05-02 18:40:13 +00:00
|
|
|
));
|
2022-05-02 17:50:57 +00:00
|
|
|
|
2022-05-02 19:14:46 +00:00
|
|
|
isnt($res, 0, "`hydra-eval-jobs` exits non-zero");
|
2022-05-02 17:50:57 +00:00
|
|
|
ok(utf8::decode($stderr), "Stderr output is UTF8-clean");
|
|
|
|
like(
|
2022-05-02 18:40:13 +00:00
|
|
|
$stderr,
|
|
|
|
qr/^child process \(\d+?\) killed by signal=9$/m,
|
|
|
|
"The stderr record includes a relevant error message"
|
2022-05-02 17:50:57 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
done_testing;
|