]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: always call test_setup_logging()
authorYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 17 Nov 2023 16:54:01 +0000 (01:54 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 17 Nov 2023 18:04:27 +0000 (03:04 +0900)
34 files changed:
src/coredump/test-coredump-vacuum.c
src/import/test-qcow2.c
src/journal/test-journald-tables.c
src/libsystemd-network/test-dhcp-option.c
src/libsystemd/sd-bus/test-bus-benchmark.c
src/libsystemd/sd-bus/test-bus-objects.c
src/libsystemd/sd-bus/test-bus-server.c
src/libsystemd/sd-bus/test-bus-signature.c
src/libsystemd/sd-journal/test-mmap-cache.c
src/libsystemd/sd-resolve/test-resolve.c
src/login/test-inhibit.c
src/login/test-login-tables.c
src/machine/test-machine-tables.c
src/network/generator/test-network-generator.c
src/network/test-network-tables.c
src/nspawn/test-nspawn-tables.c
src/resolve/test-dns-packet.c
src/resolve/test-dnssec-complex.c
src/resolve/test-resolve-tables.c
src/test/test-bitmap.c
src/test/test-btrfs-physical-offset.c
src/test/test-btrfs.c
src/test/test-chase-manual.c
src/test/test-daemon.c
src/test/test-dev-setup.c
src/test/test-hashmap-plain.c
src/test/test-job-type.c
src/test/test-list.c
src/test/test-log.c
src/test/test-procfs-util.c
src/test/test-tables.c
src/test/test-varlink.c
src/test/test-xml.c
src/udev/net/test-link-config-tables.c

index 840884d961220a631f5c142e8f663221802eb2cc..27f833095097e13b0c3b79acc339390b0fb389ae 100644 (file)
@@ -3,8 +3,10 @@
 #include <stdlib.h>
 
 #include "coredump-vacuum.h"
+#include "tests.h"
 
 int main(int argc, char *argv[]) {
+        test_setup_logging(LOG_DEBUG);
 
         if (coredump_vacuum(-1, UINT64_MAX, 70 * 1024) < 0)
                 return EXIT_FAILURE;
index ca31fd678d31a8aff3c0741340c1bb60289d834e..88932071bc4eeb7551fe0c186709271d90affbf9 100644 (file)
@@ -7,11 +7,14 @@
 #include "fd-util.h"
 #include "log.h"
 #include "qcow2-util.h"
+#include "tests.h"
 
 int main(int argc, char *argv[]) {
         _cleanup_close_ int sfd = -EBADF, dfd = -EBADF;
         int r;
 
+        test_setup_logging(LOG_DEBUG);
+
         if (argc != 3) {
                 log_error("Needs two arguments.");
                 return EXIT_FAILURE;
index 958beb84173e74e815ae065e8d40afc1e91d06a7..d726c3f3e3c1d8cd71f499e710a314b89cd1ce98 100644 (file)
@@ -2,8 +2,11 @@
 
 #include "journald-server.h"
 #include "test-tables.h"
+#include "tests.h"
 
 int main(int argc, char **argv) {
+        test_setup_logging(LOG_DEBUG);
+
         test_table(split_mode, SPLIT);
         test_table(storage, STORAGE);
 
index 47d799348f9a73e1fc309bec2275e8f7092091fa..bcd46e4720f01da976ece80a16f46915269b0343 100644 (file)
@@ -12,6 +12,7 @@
 #include "ether-addr-util.h"
 #include "macro.h"
 #include "memory-util.h"
+#include "tests.h"
 
 struct option_desc {
         uint8_t sname[64];
@@ -362,6 +363,8 @@ static void test_option_set(void) {
 }
 
 int main(int argc, char *argv[]) {
+        test_setup_logging(LOG_DEBUG);
+
         test_invalid_buffer_length();
         test_message_init();
 
index 74fa0ed746c36c290a1119c859eed9ec7bc75722..d988588de049a8395fc8e16b9128e3cbb1470786 100644 (file)
@@ -12,6 +12,7 @@
 #include "fd-util.h"
 #include "missing_resource.h"
 #include "string-util.h"
+#include "tests.h"
 #include "time-util.h"
 
 #define MAX_SIZE (2*1024*1024)
@@ -221,6 +222,8 @@ int main(int argc, char *argv[]) {
         pid_t pid;
         int r;
 
+        test_setup_logging(LOG_DEBUG);
+
         for (i = 1; i < argc; i++) {
                 if (streq(argv[i], "chart")) {
                         mode = MODE_CHART;
index 0d4a6db1e3bc308f5342e1c88e0bb4e54e974587..ccdd0d50b7c03f3742c26c540a84190c613dfc83 100644 (file)
@@ -12,6 +12,7 @@
 #include "log.h"
 #include "macro.h"
 #include "strv.h"
+#include "tests.h"
 
 struct context {
         int fds[2];
@@ -646,6 +647,8 @@ int main(int argc, char *argv[]) {
         void *p;
         int r, q;
 
+        test_setup_logging(LOG_DEBUG);
+
         c.automatic_integer_property = 4711;
         assert_se(c.automatic_string_property = strdup("dudeldu"));
 
index e3cb8f705bb16acae61f5c3b5329f8875ae75251..8049e33294928ffdc2fba6aab10a680561af0ff8 100644 (file)
@@ -10,6 +10,7 @@
 #include "macro.h"
 #include "memory-util.h"
 #include "string-util.h"
+#include "tests.h"
 
 struct context {
         int fds[2];
@@ -157,6 +158,8 @@ static int test_one(bool client_negotiate_unix_fds, bool server_negotiate_unix_f
 int main(int argc, char *argv[]) {
         int r;
 
+        test_setup_logging(LOG_DEBUG);
+
         r = test_one(true, true, false, false);
         assert_se(r >= 0);
 
index ba94804869ce71a22951806ec17b1dd17a8516bf..5a4c8118643bfa96167e0a35dabd17bf9be1f019 100644 (file)
@@ -4,11 +4,14 @@
 #include "bus-signature.h"
 #include "log.h"
 #include "string-util.h"
+#include "tests.h"
 
 int main(int argc, char *argv[]) {
         char prefix[256];
         int r;
 
+        test_setup_logging(LOG_DEBUG);
+
         assert_se(signature_is_single("y", false));
         assert_se(signature_is_single("u", false));
         assert_se(signature_is_single("v", false));
index 73c0b99978c22e2aa2269baa7008f3af4444a15a..ce5ea123c689d9e7c1d271824c137388315ba608 100644 (file)
@@ -8,6 +8,7 @@
 #include "fd-util.h"
 #include "macro.h"
 #include "mmap-cache.h"
+#include "tests.h"
 #include "tmpfile-util.h"
 
 int main(int argc, char *argv[]) {
@@ -17,6 +18,8 @@ int main(int argc, char *argv[]) {
         MMapCache *m;
         void *p, *q;
 
+        test_setup_logging(LOG_DEBUG);
+
         assert_se(m = mmap_cache_new());
 
         x = mkostemp_safe(px);
index 9c17a36610f774e747410aeefdd0935c69498522..829e13ea69df0b0d6fee88498fd3c8a36d2c0158 100644 (file)
@@ -13,6 +13,7 @@
 #include "macro.h"
 #include "socket-util.h"
 #include "string-util.h"
+#include "tests.h"
 #include "time-util.h"
 
 #define TEST_TIMEOUT_USEC (20*USEC_PER_SEC)
@@ -67,6 +68,8 @@ int main(int argc, char *argv[]) {
                 .in.sin_port = htobe16(80),
         };
 
+        test_setup_logging(LOG_DEBUG);
+
         assert_se(sd_resolve_default(&resolve) >= 0);
 
         /* Test a floating resolver query */
index f59cca8fed7b45bd3bdf42b0fd6595faeaa2356c..abb80d953e497c9513478584df39b5fc3d37d798 100644 (file)
@@ -9,6 +9,7 @@
 #include "bus-util.h"
 #include "fd-util.h"
 #include "macro.h"
+#include "tests.h"
 
 static int inhibit(sd_bus *bus, const char *what) {
         _cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
@@ -57,6 +58,8 @@ int main(int argc, char *argv[]) {
         int fd1, fd2;
         int r;
 
+        test_setup_logging(LOG_DEBUG);
+
         r = sd_bus_open_system(&bus);
         assert_se(r >= 0);
 
index 9d16685082c3a4c352e4263de52d20fb4fa25fda..3c5ec04271f562bce0dbb1b09875efc1c396f64a 100644 (file)
@@ -3,8 +3,11 @@
 #include "logind-action.h"
 #include "logind-session.h"
 #include "test-tables.h"
+#include "tests.h"
 
 int main(int argc, char **argv) {
+        test_setup_logging(LOG_DEBUG);
+
         test_table(handle_action, HANDLE_ACTION);
         test_table(inhibit_mode, INHIBIT_MODE);
         test_table(kill_who, KILL_WHO);
index 0e51755087b7752a4b70525d1a6ca9cdbbdd4dba..32c5e0e80d0acef62d86cc11e9950727e49fa10e 100644 (file)
@@ -2,8 +2,11 @@
 
 #include "machine.h"
 #include "test-tables.h"
+#include "tests.h"
 
 int main(int argc, char **argv) {
+        test_setup_logging(LOG_DEBUG);
+
         test_table(kill_who, KILL_WHO);
         test_table(machine_class, MACHINE_CLASS);
         test_table(machine_state, MACHINE_STATE);
index 318b9e98c3754bb140e66895ae06928b4100dd31..7850da990451303653bb85a2d63cc5bcd41bd8fd 100644 (file)
@@ -3,6 +3,7 @@
 #include "macro.h"
 #include "network-generator.h"
 #include "string-util.h"
+#include "tests.h"
 
 static void test_network_one(const char *ifname, const char *key, const char *value, const char *expected) {
         _cleanup_(context_clear) Context context = {};
@@ -63,6 +64,8 @@ static void test_link_one(const char *filename, const char *key, const char *val
 }
 
 int main(int argc, char *argv[]) {
+        test_setup_logging(LOG_DEBUG);
+
         test_network_one("", "ip", "dhcp6",
                          "[Match]\n"
                          "Kind=!*\n"
index e3e260754d66752cd4ccaaa2d38bde4229c9f96d..564ca096099ada89acfa95ac4f2f17555e88b929 100644 (file)
 #include "networkd-network.h"
 #include "networkd-util.h"
 #include "test-tables.h"
+#include "tests.h"
 #include "tunnel.h"
 
 int main(int argc, char **argv) {
+        test_setup_logging(LOG_DEBUG);
+
         test_table(bond_ad_select, NETDEV_BOND_AD_SELECT);
         test_table(bond_arp_all_targets, NETDEV_BOND_ARP_ALL_TARGETS);
         test_table(bond_arp_validate, NETDEV_BOND_ARP_VALIDATE);
index 3baf5d301fabb892364df926eafe3f2ff6a3c063..daea4695e3c5409b8b76ae99641e4e77ef1fe330 100644 (file)
@@ -2,8 +2,11 @@
 
 #include "nspawn-settings.h"
 #include "test-tables.h"
+#include "tests.h"
 
 int main(int argc, char **argv) {
+        test_setup_logging(LOG_DEBUG);
+
         test_table(resolv_conf_mode, RESOLV_CONF_MODE);
         test_table(timezone_mode, TIMEZONE_MODE);
 
index 01f15ca88a2bc1407baf0127822ce8177370f49f..ca09b0840c59b0b631953f8201b564983b0b007f 100644 (file)
@@ -128,7 +128,7 @@ int main(int argc, char **argv) {
         _cleanup_globfree_ glob_t g = {};
         char **fnames;
 
-        log_parse_environment();
+        test_setup_logging(LOG_DEBUG);
 
         if (argc >= 2) {
                 N = argc - 1;
index 976d197bb49b97b46c8d87cabfb45c66e9a5c5ad..05a5f07aadc0ee99e016337cd332b49740664792 100644 (file)
@@ -12,6 +12,7 @@
 #include "random-util.h"
 #include "resolved-def.h"
 #include "string-util.h"
+#include "tests.h"
 #include "time-util.h"
 
 static void prefix_random(const char *name, char **ret) {
@@ -105,6 +106,8 @@ int main(int argc, char* argv[]) {
          *    That zones contacted are still set up as they were when I wrote this.
          */
 
+        test_setup_logging(LOG_DEBUG);
+
         assert_se(sd_bus_open_system(&bus) >= 0);
 
         /* Normally signed */
index e4f4e14cc308c3f445daf4d6ec52326ea134baa8..6b8618103f970b307b60440fe9ce4abbc3a32619 100644 (file)
@@ -4,10 +4,13 @@
 #include "resolved-dns-dnssec.h"
 #include "resolved-dns-packet.h"
 #include "test-tables.h"
+#include "tests.h"
 
 int main(int argc, char **argv) {
         uint16_t i;
 
+        test_setup_logging(LOG_DEBUG);
+
         test_table(dns_protocol, DNS_PROTOCOL);
         test_table(dnssec_result, DNSSEC_RESULT);
         test_table(dnssec_verdict, DNSSEC_VERDICT);
index 6a84508b12da34a5d3bfefe857eeb7d7db782902..8acf83312911fd041ec5b8cb509e128eb3019d8d 100644 (file)
@@ -1,11 +1,14 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
 #include "bitmap.h"
+#include "tests.h"
 
 int main(int argc, const char *argv[]) {
         _cleanup_bitmap_free_ Bitmap *b = NULL, *b2 = NULL;
         unsigned n = UINT_MAX, i = 0;
 
+        test_setup_logging(LOG_DEBUG);
+
         b = bitmap_new();
         assert_se(b);
 
index 379ab311003f766614f3198b4e2b9fa3362e559c..221c08e57e3353dee84fa32d09cfbe7b6f4d20e4 100644 (file)
@@ -8,6 +8,7 @@
 #include "format-util.h"
 #include "log.h"
 #include "memory-util.h"
+#include "tests.h"
 
 int main(int argc, char *argv[]) {
         _cleanup_close_ int fd = -EBADF;
@@ -17,6 +18,8 @@ int main(int argc, char *argv[]) {
         assert(argc == 2);
         assert(!isempty(argv[1]));
 
+        test_setup_logging(LOG_DEBUG);
+
         fd = open(argv[1], O_RDONLY|O_CLOEXEC|O_NOCTTY);
         if (fd < 0) {
                 log_error_errno(errno, "Failed to open '%s': %m", argv[1]);
index 5980727c857529fa8912640e8626da42b5c3d639..205142e9820dd5a19cc4a2be212b5daf1f8f9ab4 100644 (file)
 #include "format-util.h"
 #include "log.h"
 #include "string-util.h"
+#include "tests.h"
 
 int main(int argc, char *argv[]) {
         BtrfsQuotaInfo quota;
         int r, fd;
 
+        test_setup_logging(LOG_DEBUG);
+
         fd = open("/", O_RDONLY|O_CLOEXEC|O_DIRECTORY);
         if (fd < 0)
                 log_error_errno(errno, "Failed to open root directory: %m");
index d65fbe1d744597da30bb221d9a0e413bbe84761b..475f089fa847ae2accf0b1f90a97e706ae625788 100644 (file)
@@ -5,6 +5,7 @@
 #include "fd-util.h"
 #include "log.h"
 #include "main-func.h"
+#include "tests.h"
 
 static char *arg_root = NULL;
 static int arg_flags = 0;
@@ -84,7 +85,7 @@ static int parse_argv(int argc, char *argv[]) {
 static int run(int argc, char **argv) {
         int r;
 
-        log_setup();
+        test_setup_logging(LOG_DEBUG);
 
         r = parse_argv(argc, argv);
         if (r <= 0)
index e5bc6c457b70f6c3e10f9d70c21ad607d21d48f0..b880521025e7b543a149ad1beed29d8a440be398 100644 (file)
@@ -7,12 +7,15 @@
 #include "parse-util.h"
 #include "strv.h"
 #include "time-util.h"
+#include "tests.h"
 
 int main(int argc, char *argv[]) {
         _cleanup_strv_free_ char **l = NULL;
         int n, i;
         usec_t duration = USEC_PER_SEC / 10;
 
+        test_setup_logging(LOG_DEBUG);
+
         if (argc >= 2) {
                 unsigned x;
 
index c9022ab97353228559b13126c005f9ce615ecdf1..b75576ab4c508495cbe0508ca44d70a04d642178 100644 (file)
@@ -14,6 +14,8 @@ int main(int argc, char *argv[]) {
         const char *f;
         struct stat st;
 
+        test_setup_logging(LOG_DEBUG);
+
         if (have_effective_cap(CAP_DAC_OVERRIDE) <= 0)
                 return log_tests_skipped("missing capability (CAP_DAC_OVERRIDE)");
 
index a821d412b7eb08e16adbeb97afd7c9ba7b6f057d..152b1c03e6def40b1ca3a13dd66094b778bd1ee8 100644 (file)
@@ -7,8 +7,8 @@
 #include "stdio-util.h"
 #include "string-util.h"
 #include "strv.h"
-#include "time-util.h"
 #include "tests.h"
+#include "time-util.h"
 
 TEST(hashmap_replace) {
         _cleanup_hashmap_free_ Hashmap *m = NULL;
index 0a9b6dc24988f7215b3768fec342cf64c83cf128..519fff71d57bd95441b5f4d81a3970770aa3c2d3 100644 (file)
@@ -3,11 +3,14 @@
 #include <stdio.h>
 
 #include "service.h"
+#include "tests.h"
 #include "unit.h"
 
 int main(int argc, char *argv[]) {
         const ServiceState test_states[] = { SERVICE_DEAD, SERVICE_RUNNING };
 
+        test_setup_logging(LOG_DEBUG);
+
         for (size_t i = 0; i < ELEMENTSOF(test_states); i++) {
                 /* fake a unit */
                 Service s = {
index 4b20a9f956d677e1a0455276ce2421877bb921df..87f7c7b3d466fe4d8afed107bab640502695da38 100644 (file)
@@ -2,8 +2,11 @@
 
 #include "alloc-util.h"
 #include "list.h"
+#include "tests.h"
 
 int main(int argc, const char *argv[]) {
+        test_setup_logging(LOG_DEBUG);
+
         size_t i;
         typedef struct list_item {
                 LIST_FIELDS(struct list_item, item_list);
index b0363c612ae90b91bd34aa049981138cfdf7ff41..b5ba67b74b64d201c7e168173d3635307e299db2 100644 (file)
@@ -11,6 +11,7 @@
 #include "process-util.h"
 #include "string-util.h"
 #include "strv.h"
+#include "tests.h"
 
 assert_cc(IS_SYNTHETIC_ERRNO(SYNTHETIC_ERRNO(EINVAL)));
 assert_cc(!IS_SYNTHETIC_ERRNO(EINVAL));
@@ -204,6 +205,8 @@ static void test_log_prefix(void) {
 }
 
 int main(int argc, char* argv[]) {
+        test_setup_logging(LOG_DEBUG);
+
         test_file();
 
         assert_se(log_info_errno(SYNTHETIC_ERRNO(EUCLEAN), "foo") == -EUCLEAN);
index 644de5831c1e8b3b073a3aed0b24bf2892439619..2b19a9888b10eb807bcd3e66a801b52934790b1e 100644 (file)
@@ -14,8 +14,7 @@ int main(int argc, char *argv[]) {
         uint64_t v, pid_max, threads_max, limit;
         int r;
 
-        log_parse_environment();
-        log_open();
+        test_setup_logging(LOG_DEBUG);
 
         assert_se(procfs_cpu_get_usage(&nsec) >= 0);
         log_info("Current system CPU time: %s", FORMAT_TIMESPAN(nsec/NSEC_PER_USEC, 1));
index 975f952a1f6cf3d4fd29b47783e6af79a97068e6..8abfba550cc18184769c0bdeef7bf4a0c522668c 100644 (file)
 #include "swap.h"
 #include "target.h"
 #include "test-tables.h"
+#include "tests.h"
 #include "timer.h"
 #include "unit-name.h"
 #include "unit.h"
 #include "virt.h"
 
 int main(int argc, char **argv) {
+        test_setup_logging(LOG_DEBUG);
+
         test_table(architecture, ARCHITECTURE);
         test_table(assert_type, CONDITION_TYPE);
         test_table(automount_result, AUTOMOUNT_RESULT);
index 05bdf9c3fab28abbe56ff5be73b83f55f8ea194b..2617ed0e1aa2292304a60aa5900acd2713910c7f 100644 (file)
@@ -11,6 +11,7 @@
 #include "json.h"
 #include "rm-rf.h"
 #include "strv.h"
+#include "tests.h"
 #include "tmpfile-util.h"
 #include "user-util.h"
 #include "varlink.h"
@@ -330,8 +331,7 @@ int main(int argc, char *argv[]) {
         pthread_t t;
         const char *sp;
 
-        log_set_max_level(LOG_DEBUG);
-        log_open();
+        test_setup_logging(LOG_DEBUG);
 
         assert_se(mkdtemp_malloc("/tmp/varlink-test-XXXXXX", &tmpdir) >= 0);
         sp = strjoina(tmpdir, "/socket");
index 5dee5c1beda043801df3af121561eb187a44d906..a8cb635aa31d6db4d550b4468e12782b32970e7a 100644 (file)
@@ -4,6 +4,7 @@
 
 #include "alloc-util.h"
 #include "string-util.h"
+#include "tests.h"
 #include "xml.h"
 
 static void test_one(const char *data, ...) {
@@ -36,6 +37,8 @@ static void test_one(const char *data, ...) {
 
 int main(int argc, char *argv[]) {
 
+        test_setup_logging(LOG_DEBUG);
+
         test_one("", XML_END);
 
         test_one("<foo></foo>",
index 4fd004607f2e9cc96728a3f2ecbb40868028d878..a4332320f6890b4e8b01275f783f93c9c4b951be 100644 (file)
@@ -2,8 +2,11 @@
 
 #include "link-config.h"
 #include "test-tables.h"
+#include "tests.h"
 
 int main(int argc, char **argv) {
+        test_setup_logging(LOG_DEBUG);
+
         test_table(mac_address_policy, MAC_ADDRESS_POLICY);
 
         return EXIT_SUCCESS;