]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: suppress logs generated by journal tests
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 28 May 2024 05:05:15 +0000 (14:05 +0900)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Tue, 28 May 2024 08:38:53 +0000 (10:38 +0200)
Note, journal_file_dump() is only used by tests.

Closes #33035.

src/libsystemd/sd-journal/journal-file.c
test/units/TEST-02-UNITTESTS.sh

index d0acbced61f3f7e46ebaf68a4dd413d76df16ef7..7e941edb1997136791e188dbb13c5c4e04675cde 100644 (file)
@@ -3801,35 +3801,35 @@ void journal_file_dump(JournalFile *f) {
                 case OBJECT_ENTRY:
                         assert(s);
 
-                        printf("Type: %s seqnum=%"PRIu64" monotonic=%"PRIu64" realtime=%"PRIu64"\n",
-                               s,
-                               le64toh(o->entry.seqnum),
-                               le64toh(o->entry.monotonic),
-                               le64toh(o->entry.realtime));
+                        log_info("Type: %s seqnum=%"PRIu64" monotonic=%"PRIu64" realtime=%"PRIu64"\n",
+                                 s,
+                                 le64toh(o->entry.seqnum),
+                                 le64toh(o->entry.monotonic),
+                                 le64toh(o->entry.realtime));
                         break;
 
                 case OBJECT_TAG:
                         assert(s);
 
-                        printf("Type: %s seqnum=%"PRIu64" epoch=%"PRIu64"\n",
-                               s,
-                               le64toh(o->tag.seqnum),
-                               le64toh(o->tag.epoch));
+                        log_info("Type: %s seqnum=%"PRIu64" epoch=%"PRIu64"\n",
+                                 s,
+                                 le64toh(o->tag.seqnum),
+                                 le64toh(o->tag.epoch));
                         break;
 
                 default:
                         if (s)
-                                printf("Type: %s \n", s);
+                                log_info("Type: %s \n", s);
                         else
-                                printf("Type: unknown (%i)", o->object.type);
+                                log_info("Type: unknown (%i)", o->object.type);
 
                         break;
                 }
 
                 c = COMPRESSION_FROM_OBJECT(o);
                 if (c > COMPRESSION_NONE)
-                        printf("Flags: %s\n",
-                               compression_to_string(c));
+                        log_info("Flags: %s\n",
+                                 compression_to_string(c));
 
                 if (p == le64toh(f->header->tail_object_offset))
                         p = 0;
index 7d44f974af4ee6b79d391a2f76aace160a56b7d5..0c8de536ef691a67a2304a4d4a2d5b94a29880f6 100755 (executable)
@@ -42,10 +42,20 @@ run_test() {
 
     local test="$1"
     local name="${test##*/}"
+    local environment=
 
     echo "Executing test $name as unit $name.service"
 
-    systemd-run --quiet --property Delegate=1 --unit="$name" --wait "$test" && ret=0 || ret=$?
+    case "$name" in
+        test-journal-flush)
+            environment="SYSTEMD_LOG_LEVEL=info"
+            ;;
+        test-journal-verify)
+            environment="SYSTEMD_LOG_LEVEL=crit"
+            ;;
+    esac
+
+    systemd-run --quiet --property Delegate=1 --property "Environment=$environment" --unit="$name" --wait "$test" && ret=0 || ret=$?
 
     exec {LOCK_FD}> /lock
     flock --exclusive ${LOCK_FD}