From 4dd73b883f1825fb3d20870e71f8a4daafd369d2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Mon, 1 Oct 2018 15:22:55 +0200 Subject: [PATCH] test-sd-hwdb: skip tests if hwdb cannot be opened --- src/test/test-sd-hwdb.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/test/test-sd-hwdb.c b/src/test/test-sd-hwdb.c index dc6191c..b67a853 100644 --- a/src/test/test-sd-hwdb.c +++ b/src/test/test-sd-hwdb.c @@ -4,19 +4,25 @@ #include "errno.h" #include "tests.h" -static void test_failed_enumerate(void) { +static int test_failed_enumerate(void) { _cleanup_(sd_hwdb_unrefp) sd_hwdb *hwdb; const char *key, *value; + int r; log_info("/* %s */", __func__); - assert_se(sd_hwdb_new(&hwdb) == 0); + r = sd_hwdb_new(&hwdb); + if (r == -ENOENT) + return r; + assert_se(r == 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 \ @@ -54,9 +60,14 @@ static void test_basic_enumerate(void) { } int main(int argc, char *argv[]) { + int r; + test_setup_logging(LOG_DEBUG); - test_failed_enumerate(); + r = test_failed_enumerate(); + if (r < 0) + return log_tests_skipped_errno(r, "cannot open hwdb"); + test_basic_enumerate(); return 0; -- 2.7.4