summaryrefslogtreecommitdiff
path: root/src/oom
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2022-02-23 06:51:06 +0900
committerGitHub <noreply@github.com>2022-02-23 06:51:06 +0900
commit05d8ad0f855a9d32e3509cb68cd54c6bf0003073 (patch)
tree4c61fa99e57b83fa6ae760e190e7a5cb5ee431e7 /src/oom
parentcab4ed0f4a5cb1f2e2d236082370e0a7982b9fbf (diff)
parentbe99883e131ef422f8278ec1d099520996a78bb0 (diff)
downloadsystemd-05d8ad0f855a9d32e3509cb68cd54c6bf0003073.tar.gz
Merge pull request #22596 from yuwata/test-fix-fd-leaks
test: fix fd leaks
Diffstat (limited to 'src/oom')
-rw-r--r--src/oom/test-oomd-util.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/oom/test-oomd-util.c b/src/oom/test-oomd-util.c
index f0283677f7..13d9e60f16 100644
--- a/src/oom/test-oomd-util.c
+++ b/src/oom/test-oomd-util.c
@@ -5,6 +5,7 @@
#include "alloc-util.h"
#include "cgroup-setup.h"
#include "cgroup-util.h"
+#include "fd-util.h"
#include "fileio.h"
#include "fs-util.h"
#include "oomd-util.h"
@@ -13,6 +14,7 @@
#include "string-util.h"
#include "strv.h"
#include "tests.h"
+#include "tmpfile-util.h"
static int fork_and_sleep(unsigned sleep_min) {
usec_t n, timeout, ts;
@@ -244,12 +246,13 @@ static void test_oomd_update_cgroup_contexts_between_hashmaps(void) {
static void test_oomd_system_context_acquire(void) {
_cleanup_(unlink_tempfilep) char path[] = "/oomdgetsysctxtestXXXXXX";
+ _cleanup_close_ int fd = -1;
OomdSystemContext ctx;
if (geteuid() != 0)
return (void) log_tests_skipped("not root");
- assert_se(mkstemp(path));
+ assert_se((fd = mkostemp_safe(path)) >= 0);
assert_se(oomd_system_context_acquire("/verylikelynonexistentpath", &ctx) == -ENOENT);