]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/test/test-set.c
test: Use TEST macro
[thirdparty/systemd.git] / src / test / test-set.c
index e63137192cbc82b4d5aa27f04b4f8de43bf3b2f6..4dd98ef4f8d629a605cb47825e87e7d38d3001a1 100644 (file)
@@ -3,10 +3,11 @@
 #include "random-util.h"
 #include "set.h"
 #include "strv.h"
+#include "tests.h"
 
 const bool mempool_use_allowed = VALGRIND;
 
-static void test_set_steal_first(void) {
+TEST(set_steal_first) {
         _cleanup_set_free_ Set *m = NULL;
         int seen[3] = {};
         char *val;
@@ -33,7 +34,7 @@ static void item_seen(Item *item) {
         item->seen++;
 }
 
-static void test_set_free_with_destructor(void) {
+TEST(set_free_with_destructor) {
         Set *m;
         struct Item items[4] = {};
         unsigned i;
@@ -51,7 +52,7 @@ static void test_set_free_with_destructor(void) {
 
 DEFINE_PRIVATE_HASH_OPS_WITH_VALUE_DESTRUCTOR(item_hash_ops, void, trivial_hash_func, trivial_compare_func, Item, item_seen);
 
-static void test_set_free_with_hash_ops(void) {
+TEST(set_free_with_hash_ops) {
         Set *m;
         struct Item items[4] = {};
         unsigned i;
@@ -67,7 +68,7 @@ static void test_set_free_with_hash_ops(void) {
         assert_se(items[3].seen == 0);
 }
 
-static void test_set_put(void) {
+TEST(set_put) {
         _cleanup_set_free_ Set *m = NULL;
 
         m = set_new(&string_hash_ops);
@@ -89,7 +90,7 @@ static void test_set_put(void) {
         assert_se(strv_length(t) == 3);
 }
 
-static void test_set_put_strdup(void) {
+TEST(set_put_strdup) {
         _cleanup_set_free_ Set *m = NULL;
 
         assert_se(set_put_strdup(&m, "aaa") == 1);
@@ -100,7 +101,7 @@ static void test_set_put_strdup(void) {
         assert_se(set_size(m) == 2);
 }
 
-static void test_set_put_strdupv(void) {
+TEST(set_put_strdupv) {
         _cleanup_set_free_ Set *m = NULL;
 
         assert_se(set_put_strdupv(&m, STRV_MAKE("aaa", "aaa", "bbb", "bbb", "aaa")) == 2);
@@ -108,7 +109,7 @@ static void test_set_put_strdupv(void) {
         assert_se(set_size(m) == 3);
 }
 
-static void test_set_ensure_allocated(void) {
+TEST(set_ensure_allocated) {
         _cleanup_set_free_ Set *m = NULL;
 
         assert_se(set_ensure_allocated(&m, &string_hash_ops) == 1);
@@ -117,12 +118,10 @@ static void test_set_ensure_allocated(void) {
         assert_se(set_size(m) == 0);
 }
 
-static void test_set_copy(void) {
+TEST(set_copy) {
         Set *s, *copy;
         char *key1, *key2, *key3, *key4;
 
-        log_info("/* %s */", __func__);
-
         key1 = strdup("key1");
         assert_se(key1);
         key2 = strdup("key2");
@@ -149,7 +148,7 @@ static void test_set_copy(void) {
         set_free_free(copy);
 }
 
-static void test_set_ensure_put(void) {
+TEST(set_ensure_put) {
         _cleanup_set_free_ Set *m = NULL;
 
         assert_se(set_ensure_put(&m, &string_hash_ops, "a") == 1);
@@ -161,7 +160,7 @@ static void test_set_ensure_put(void) {
         assert_se(set_size(m) == 2);
 }
 
-static void test_set_ensure_consume(void) {
+TEST(set_ensure_consume) {
         _cleanup_set_free_ Set *m = NULL;
         char *s, *t;
 
@@ -183,7 +182,7 @@ static void test_set_ensure_consume(void) {
         assert_se(set_size(m) == 2);
 }
 
-static void test_set_strjoin(void) {
+TEST(set_strjoin) {
         _cleanup_set_free_ Set *m = NULL;
         _cleanup_free_ char *joined = NULL;
 
@@ -260,7 +259,7 @@ static void test_set_strjoin(void) {
         assert_se(STR_IN_SET(joined, "xxxaaaxxxbbbxxx", "xxxbbbxxxaaaxxx"));
 }
 
-static void test_set_equal(void) {
+TEST(set_equal) {
         _cleanup_set_free_ Set *a = NULL, *b = NULL;
         void *p;
         int r;
@@ -331,19 +330,4 @@ static void test_set_equal(void) {
         assert_se(set_equal(b, a));
 }
 
-int main(int argc, const char *argv[]) {
-        test_set_steal_first();
-        test_set_free_with_destructor();
-        test_set_free_with_hash_ops();
-        test_set_put();
-        test_set_put_strdup();
-        test_set_put_strdupv();
-        test_set_ensure_allocated();
-        test_set_ensure_put();
-        test_set_ensure_consume();
-        test_set_strjoin();
-        test_set_equal();
-        test_set_copy();
-
-        return 0;
-}
+DEFINE_TEST_MAIN(LOG_INFO);