diff options
author | Jan Janssen <medhefgo@web.de> | 2021-11-24 12:11:17 +0100 |
---|---|---|
committer | Jan Janssen <medhefgo@web.de> | 2021-11-25 15:03:10 +0100 |
commit | c462e63eea7c781e00a3ce83055967dbbd67bf96 (patch) | |
tree | 60176ff67195f375edf28d8f1215e16ed649bfc0 /src/test/test-format-table.c | |
parent | test: Use TEST macro (diff) | |
download | systemd-c462e63eea7c781e00a3ce83055967dbbd67bf96.tar.xz systemd-c462e63eea7c781e00a3ce83055967dbbd67bf96.zip |
test: Use TEST macro in more cases
This converts to TEST macro in less trivial cases. This is mostly
due to having an intro or outro before/after the actual tests.
Some notable changes:
- add a "test" to make sure the hashmap and ordered_hashmap tests
from different compilation units are actually run in test-hashmap.c
- make root arg a global var in test-install-root.c
- slightly rework an EFI specific test in test-proc-cmdline.c
- usage of saved_argv/saved_argc in test-process-util.c
- splitting test-rlimit-util.c into several tests
- moving the hwdb open check into intro in test-sd-hwdb.c
- condense several "tests" into one in test-udev-util.c
Diffstat (limited to 'src/test/test-format-table.c')
-rw-r--r-- | src/test/test-format-table.c | 42 |
1 files changed, 15 insertions, 27 deletions
diff --git a/src/test/test-format-table.c b/src/test/test-format-table.c index 7a4c98eba6..a3b29ca337 100644 --- a/src/test/test-format-table.c +++ b/src/test/test-format-table.c @@ -6,14 +6,13 @@ #include "format-table.h" #include "string-util.h" #include "strv.h" +#include "tests.h" #include "time-util.h" -static void test_issue_9549(void) { +TEST(issue_9549) { _cleanup_(table_unrefp) Table *table = NULL; _cleanup_free_ char *formatted = NULL; - log_info("/* %s */", __func__); - assert_se(table = table_new("name", "type", "ro", "usage", "created", "modified")); assert_se(table_set_align_percent(table, TABLE_HEADER_CELL(3), 100) >= 0); assert_se(table_add_many(table, @@ -34,12 +33,10 @@ static void test_issue_9549(void) { )); } -static void test_multiline(void) { +TEST(multiline) { _cleanup_(table_unrefp) Table *table = NULL; _cleanup_free_ char *formatted = NULL; - log_info("/* %s */", __func__); - assert_se(table = table_new("foo", "bar")); assert_se(table_set_align_percent(table, TABLE_HEADER_CELL(1), 100) >= 0); @@ -148,12 +145,10 @@ static void test_multiline(void) { formatted = mfree(formatted); } -static void test_strv(void) { +TEST(strv) { _cleanup_(table_unrefp) Table *table = NULL; _cleanup_free_ char *formatted = NULL; - log_info("/* %s */", __func__); - assert_se(table = table_new("foo", "bar")); assert_se(table_set_align_percent(table, TABLE_HEADER_CELL(1), 100) >= 0); @@ -262,12 +257,10 @@ static void test_strv(void) { formatted = mfree(formatted); } -static void test_strv_wrapped(void) { +TEST(strv_wrapped) { _cleanup_(table_unrefp) Table *table = NULL; _cleanup_free_ char *formatted = NULL; - log_info("/* %s */", __func__); - assert_se(table = table_new("foo", "bar")); assert_se(table_set_align_percent(table, TABLE_HEADER_CELL(1), 100) >= 0); @@ -366,12 +359,10 @@ static void test_strv_wrapped(void) { formatted = mfree(formatted); } -static void test_json(void) { +TEST(json) { _cleanup_(json_variant_unrefp) JsonVariant *v = NULL, *w = NULL; _cleanup_(table_unrefp) Table *t = NULL; - log_info("/* %s */", __func__); - assert_se(t = table_new("foo bar", "quux", "piep miau")); assert_se(table_set_json_field_name(t, 2, "zzz") >= 0); @@ -401,13 +392,10 @@ static void test_json(void) { assert_se(json_variant_equal(v, w)); } -int main(int argc, char *argv[]) { +TEST(table) { _cleanup_(table_unrefp) Table *t = NULL; _cleanup_free_ char *formatted = NULL; - assert_se(setenv("SYSTEMD_COLORS", "0", 1) >= 0); - assert_se(setenv("COLUMNS", "40", 1) >= 0); - assert_se(t = table_new("one", "two", "three")); assert_se(table_set_align_percent(t, TABLE_HEADER_CELL(2), 100) >= 0); @@ -539,12 +527,12 @@ int main(int argc, char *argv[]) { " yes fäää yes fäää fäää\n" " yes xxx yes xxx xxx\n" "5min 5min \n")); - - test_issue_9549(); - test_multiline(); - test_strv(); - test_strv_wrapped(); - test_json(); - - return 0; } + +DEFINE_CUSTOM_TEST_MAIN( + LOG_INFO, + ({ + assert_se(setenv("SYSTEMD_COLORS", "0", 1) >= 0); + assert_se(setenv("COLUMNS", "40", 1) >= 0); + }), + /* no outro */); |