]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test-copy: Stop using rm_rf_physical_and_close
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Fri, 11 Nov 2022 09:04:37 +0000 (10:04 +0100)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Fri, 11 Nov 2022 09:19:18 +0000 (10:19 +0100)
This cleanup function depends on resolving fd's to paths via /proc
which is unreliable so we shouldn't depend on it for destructive
operations. Use regular path based cleanup instead.

src/test/test-copy.c

index 00a38b18f6a690d53fe012e1f09541f90f3bb428..6ad157ef1c5a83d78f9c31563ff3e5a5c5b93c40 100644 (file)
@@ -77,11 +77,12 @@ TEST(copy_tree_replace_file) {
 }
 
 TEST(copy_tree_replace_dirs) {
-        _cleanup_(rm_rf_physical_and_closep) int src = -1, dst = -1;
+        _cleanup_(rm_rf_physical_and_freep) char *srcp = NULL, *dstp = NULL;
+        _cleanup_close_ int src = -1, dst = -1;
 
         /* Create the random source/destination directories */
-        assert_se((src = mkdtemp_open(NULL, 0, NULL)) >= 0);
-        assert_se((dst = mkdtemp_open(NULL, 0, NULL)) >= 0);
+        assert_se((src = mkdtemp_open(NULL, 0, &srcp)) >= 0);
+        assert_se((dst = mkdtemp_open(NULL, 0, &dstp)) >= 0);
 
         /* Populate some data to differentiate the files. */
         assert_se(write_string_file_at(src, "foo", "src file 1", WRITE_STRING_FILE_CREATE) >= 0);