|
|
8d419f |
From 936e8cd5aff044832c98e5a6a97c9f057f44b476 Mon Sep 17 00:00:00 2001
|
|
|
8d419f |
From: Yu Watanabe <watanabe.yu+github@gmail.com>
|
|
|
8d419f |
Date: Tue, 22 Feb 2022 21:44:58 +0900
|
|
|
8d419f |
Subject: [PATCH] test: fix file descriptor leak in test-tmpfiles.c
|
|
|
8d419f |
|
|
|
8d419f |
Also fixes a typo in assertion.
|
|
|
8d419f |
|
|
|
8d419f |
Fixes an issure reported in #22576.
|
|
|
8d419f |
|
|
|
8d419f |
(cherry picked from commit 1da5325d19dee654326e5fa2f61262e5e0a40fff)
|
|
|
8d419f |
Related: #2087652
|
|
|
8d419f |
---
|
|
|
8d419f |
src/test/test-tmpfiles.c | 3 ++-
|
|
|
8d419f |
1 file changed, 2 insertions(+), 1 deletion(-)
|
|
|
8d419f |
|
|
|
8d419f |
diff --git a/src/test/test-tmpfiles.c b/src/test/test-tmpfiles.c
|
|
|
8d419f |
index 99243eb77a..f26701767f 100644
|
|
|
8d419f |
--- a/src/test/test-tmpfiles.c
|
|
|
8d419f |
+++ b/src/test/test-tmpfiles.c
|
|
|
8d419f |
@@ -35,7 +35,7 @@ TEST(tmpfiles) {
|
|
|
8d419f |
assert_se(endswith(ans, " (deleted)"));
|
|
|
8d419f |
|
|
|
8d419f |
fd2 = mkostemp_safe(pattern);
|
|
|
8d419f |
- assert_se(fd >= 0);
|
|
|
8d419f |
+ assert_se(fd2 >= 0);
|
|
|
8d419f |
assert_se(unlink(pattern) == 0);
|
|
|
8d419f |
|
|
|
8d419f |
assert_se(asprintf(&cmd2, "ls -l /proc/"PID_FMT"/fd/%d", getpid_cached(), fd2) > 0);
|
|
|
8d419f |
@@ -47,6 +47,7 @@ TEST(tmpfiles) {
|
|
|
8d419f |
pattern = strjoina(p, "/tmpfiles-test");
|
|
|
8d419f |
assert_se(tempfn_random(pattern, NULL, &d) >= 0);
|
|
|
8d419f |
|
|
|
8d419f |
+ fd = safe_close(fd);
|
|
|
8d419f |
fd = open_tmpfile_linkable(d, O_RDWR|O_CLOEXEC, &tmp);
|
|
|
8d419f |
assert_se(fd >= 0);
|
|
|
8d419f |
assert_se(write(fd, "foobar\n", 7) == 7);
|