diff options
author | Lennart Poettering <lennart@poettering.net> | 2018-11-19 11:05:18 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-19 11:05:18 +0100 |
commit | a44088f10fe59ce89f9219d9f678c9300b1f0eee (patch) | |
tree | 69f6be64ced694e0db6905389af970aa410b504c /src/test | |
parent | 2b38a8ea80cdc64222bbd49ae374792f941aaf42 (diff) | |
parent | 64d9f7568bf8d3c500a9da5c93a2aa88084b901f (diff) | |
download | systemd-a44088f10fe59ce89f9219d9f678c9300b1f0eee.tar.gz systemd-a44088f10fe59ce89f9219d9f678c9300b1f0eee.tar.bz2 systemd-a44088f10fe59ce89f9219d9f678c9300b1f0eee.zip |
Merge pull request #10825 from keszybz/advertize-followup
udev link advertizing followup
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/test-util.c | 45 |
1 files changed, 43 insertions, 2 deletions
diff --git a/src/test/test-util.c b/src/test/test-util.c index 21d58dd86b..eeee09a7d2 100644 --- a/src/test/test-util.c +++ b/src/test/test-util.c @@ -13,11 +13,14 @@ #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); @@ -220,9 +237,25 @@ static void test_log2i(void) { assert_se(log2i(INT_MAX) == sizeof(int)*8-2); } +static void test_eqzero(void) { + const uint32_t zeros[] = {0, 0, 0}; + const uint32_t ones[] = {1, 1}; + const uint32_t mixed[] = {0, 1, 0, 0, 0}; + const uint8_t longer[] = {[55] = 255}; + + log_info("/* %s */", __func__); + + assert_se(eqzero(zeros)); + assert_se(!eqzero(ones)); + assert_se(!eqzero(mixed)); + assert_se(!eqzero(longer)); +} + 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 +286,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 +299,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 +335,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 +347,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 +374,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(); @@ -344,6 +384,7 @@ int main(int argc, char *argv[]) { test_protect_errno(); test_in_set(); test_log2i(); + test_eqzero(); test_raw_clone(); test_physical_memory(); test_physical_memory_scale(); |