]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test-util: modernize
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sun, 18 Nov 2018 09:46:30 +0000 (10:46 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sun, 18 Nov 2018 09:47:16 +0000 (10:47 +0100)
src/test/test-util.c

index 21d58dd86b0cc8c62dec416e09553ffcc00cc18d..80856e638886bcf454c63695277a4badf4253976 100644 (file)
 #include "raw-clone.h"
 #include "rm-rf.h"
 #include "string-util.h"
+#include "tests.h"
 #include "util.h"
 
 static void test_align_power2(void) {
         unsigned long i, p2;
 
+        log_info("/* %s */", __func__);
+
         assert_se(ALIGN_POWER2(0) == 0);
         assert_se(ALIGN_POWER2(1) == 1);
         assert_se(ALIGN_POWER2(2) == 2);
@@ -60,6 +63,8 @@ static void test_max(void) {
         void *p = (void *)str;
         void *q = (void *)&str[16];
 
+        log_info("/* %s */", __func__);
+
         assert_cc(sizeof(val1.b) == sizeof(int) * 100);
 
         /* CONST_MAX returns (void) instead of a value if the passed arguments
@@ -135,6 +140,8 @@ static void test_container_of(void) {
                 uint32_t v2;
         } _packed_ myval = { };
 
+        log_info("/* %s */", __func__);
+
         assert_cc(sizeof(myval) == 17);
         assert_se(container_of(&myval.v1, struct mytype, v1) == &myval);
         assert_se(container_of(&myval.v2, struct mytype, v2) == &myval);
@@ -150,6 +157,8 @@ static void test_container_of(void) {
 static void test_div_round_up(void) {
         int div;
 
+        log_info("/* %s */", __func__);
+
         /* basic tests */
         assert_se(DIV_ROUND_UP(0, 8) == 0);
         assert_se(DIV_ROUND_UP(1, 8) == 1);
@@ -181,6 +190,8 @@ static void test_div_round_up(void) {
 }
 
 static void test_u64log2(void) {
+        log_info("/* %s */", __func__);
+
         assert_se(u64log2(0) == 0);
         assert_se(u64log2(8) == 3);
         assert_se(u64log2(9) == 3);
@@ -191,6 +202,8 @@ static void test_u64log2(void) {
 }
 
 static void test_protect_errno(void) {
+        log_info("/* %s */", __func__);
+
         errno = 12;
         {
                 PROTECT_ERRNO;
@@ -200,6 +213,8 @@ static void test_protect_errno(void) {
 }
 
 static void test_in_set(void) {
+        log_info("/* %s */", __func__);
+
         assert_se(IN_SET(1, 1));
         assert_se(IN_SET(1, 1, 2, 3, 4));
         assert_se(IN_SET(2, 1, 2, 3, 4));
@@ -210,6 +225,8 @@ static void test_in_set(void) {
 }
 
 static void test_log2i(void) {
+        log_info("/* %s */", __func__);
+
         assert_se(log2i(1) == 0);
         assert_se(log2i(2) == 1);
         assert_se(log2i(3) == 1);
@@ -223,6 +240,8 @@ static void test_log2i(void) {
 static void test_raw_clone(void) {
         pid_t parent, pid, pid2;
 
+        log_info("/* %s */", __func__);
+
         parent = getpid();
         log_info("before clone: getpid()→"PID_FMT, parent);
         assert_se(raw_getpid() == parent);
@@ -253,6 +272,8 @@ static void test_physical_memory(void) {
         uint64_t p;
         char buf[FORMAT_BYTES_MAX];
 
+        log_info("/* %s */", __func__);
+
         p = physical_memory();
         assert_se(p > 0);
         assert_se(p < UINT64_MAX);
@@ -264,6 +285,8 @@ static void test_physical_memory(void) {
 static void test_physical_memory_scale(void) {
         uint64_t p;
 
+        log_info("/* %s */", __func__);
+
         p = physical_memory();
 
         assert_se(physical_memory_scale(0, 100) == 0);
@@ -298,6 +321,8 @@ static void test_physical_memory_scale(void) {
 static void test_system_tasks_max(void) {
         uint64_t t;
 
+        log_info("/* %s */", __func__);
+
         t = system_tasks_max();
         assert_se(t > 0);
         assert_se(t < UINT64_MAX);
@@ -308,6 +333,8 @@ static void test_system_tasks_max(void) {
 static void test_system_tasks_max_scale(void) {
         uint64_t t;
 
+        log_info("/* %s */", __func__);
+
         t = system_tasks_max();
 
         assert_se(system_tasks_max_scale(0, 100) == 0);
@@ -333,8 +360,7 @@ static void test_system_tasks_max_scale(void) {
 }
 
 int main(int argc, char *argv[]) {
-        log_parse_environment();
-        log_open();
+        test_setup_logging(LOG_INFO);
 
         test_align_power2();
         test_max();