summaryrefslogtreecommitdiff
path: root/src/test/test-sd-hwdb.c
diff options
context:
space:
mode:
authorJan Janssen <medhefgo@web.de>2021-11-24 12:11:17 +0100
committerJan Janssen <medhefgo@web.de>2021-11-25 15:03:10 +0100
commitc462e63eea7c781e00a3ce83055967dbbd67bf96 (patch)
tree60176ff67195f375edf28d8f1215e16ed649bfc0 /src/test/test-sd-hwdb.c
parent4f7452a8eb7a946efea927fae017d4d661097833 (diff)
downloadsystemd-c462e63eea7c781e00a3ce83055967dbbd67bf96.tar.gz
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-sd-hwdb.c')
-rw-r--r--src/test/test-sd-hwdb.c38
1 files changed, 12 insertions, 26 deletions
diff --git a/src/test/test-sd-hwdb.c b/src/test/test-sd-hwdb.c
index 7ed6907cbd..7961c17c4a 100644
--- a/src/test/test-sd-hwdb.c
+++ b/src/test/test-sd-hwdb.c
@@ -7,38 +7,28 @@
#include "errno.h"
#include "tests.h"
-static int test_failed_enumerate(void) {
+TEST(failed_enumerate) {
_cleanup_(sd_hwdb_unrefp) sd_hwdb *hwdb = NULL;
const char *key, *value;
- int r;
-
- log_info("/* %s */", __func__);
- r = sd_hwdb_new(&hwdb);
- if (r == -ENOENT || ERRNO_IS_PRIVILEGE(r))
- return r;
- assert_se(r == 0);
+ assert_se(sd_hwdb_new(&hwdb) == 0);
assert_se(sd_hwdb_seek(hwdb, "no-such-modalias-should-exist") == 0);
assert_se(sd_hwdb_enumerate(hwdb, &key, &value) == 0);
assert_se(sd_hwdb_enumerate(hwdb, &key, NULL) == -EINVAL);
assert_se(sd_hwdb_enumerate(hwdb, NULL, &value) == -EINVAL);
-
- return 0;
}
#define DELL_MODALIAS \
"evdev:atkbd:dmi:bvnXXX:bvrYYY:bdZZZ:svnDellXXX:pnYYY"
-static void test_basic_enumerate(void) {
+TEST(basic_enumerate) {
_cleanup_(sd_hwdb_unrefp) sd_hwdb *hwdb = NULL;
const char *key, *value;
size_t len1 = 0, len2 = 0;
int r;
- log_info("/* %s */", __func__);
-
assert_se(sd_hwdb_new(&hwdb) == 0);
assert_se(sd_hwdb_seek(hwdb, DELL_MODALIAS) == 0);
@@ -62,16 +52,12 @@ static void test_basic_enumerate(void) {
assert_se(len1 == len2);
}
-int main(int argc, char *argv[]) {
- int r;
-
- test_setup_logging(LOG_DEBUG);
-
- r = test_failed_enumerate();
- if (r < 0)
- return log_tests_skipped_errno(r, "cannot open hwdb");
-
- test_basic_enumerate();
-
- return 0;
-}
+DEFINE_CUSTOM_TEST_MAIN(
+ LOG_DEBUG,
+ ({
+ _cleanup_(sd_hwdb_unrefp) sd_hwdb *hwdb = NULL;
+ int r = sd_hwdb_new(&hwdb);
+ if (r == -ENOENT || ERRNO_IS_PRIVILEGE(r))
+ return log_tests_skipped_errno(r, "cannot open hwdb");
+ }),
+ /* no outro */);