test: split out finalization task
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 28 Nov 2023 21:08:11 +0000 (06:08 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 1 Dec 2023 01:08:46 +0000 (10:08 +0900)
src/libsystemd/sd-journal/test-journal-interleaving.c

index eff908b..af4f506 100644 (file)
@@ -58,6 +58,20 @@ static void test_close(JournalFile *f) {
         (void) journal_file_offline_close(f);
 }
 
+static void test_done(const char *t) {
+        log_info("Done...");
+
+        if (arg_keep)
+                log_info("Not removing %s", t);
+        else {
+                journal_directory_vacuum(".", 3000000, 0, 0, NULL, true);
+
+                assert_se(rm_rf(t, REMOVE_ROOT|REMOVE_PHYSICAL) >= 0);
+        }
+
+        log_info("------------------------------------------------------------");
+}
+
 static void append_number(JournalFile *f, int n, const sd_id128_t *boot_id, uint64_t *seqnum) {
         _cleanup_free_ char *p = NULL, *q = NULL;
         dual_timestamp ts;
@@ -376,17 +390,7 @@ static void test_skip_one(void (*setup)(void)) {
         test_check_numbers_up(j, 9);
         sd_journal_close(j);
 
-        log_info("Done...");
-
-        if (arg_keep)
-                log_info("Not removing %s", t);
-        else {
-                journal_directory_vacuum(".", 3000000, 0, 0, NULL, true);
-
-                assert_se(rm_rf(t, REMOVE_ROOT|REMOVE_PHYSICAL) >= 0);
-        }
-
-        puts("------------------------------------------------------------");
+        test_done(t);
 }
 
 TEST(skip) {
@@ -428,17 +432,7 @@ static void test_boot_id_one(void (*setup)(void), size_t n_boots_expected) {
                 sd_journal_close(j);
         }
 
-        log_info("Done...");
-
-        if (arg_keep)
-                log_info("Not removing %s", t);
-        else {
-                journal_directory_vacuum(".", 3000000, 0, 0, NULL, true);
-
-                assert_se(rm_rf(t, REMOVE_ROOT|REMOVE_PHYSICAL) >= 0);
-        }
-
-        puts("------------------------------------------------------------");
+        test_done(t);
 }
 
 TEST(boot_id) {
@@ -527,15 +521,7 @@ static void test_sequence_numbers_one(void) {
                 test_close(two);
         }
 
-        log_info("Done...");
-
-        if (arg_keep)
-                log_info("Not removing %s", t);
-        else {
-                journal_directory_vacuum(".", 3000000, 0, 0, NULL, true);
-
-                assert_se(rm_rf(t, REMOVE_ROOT|REMOVE_PHYSICAL) >= 0);
-        }
+        test_done(t);
 }
 
 TEST(sequence_numbers) {