[PATCH 4/4] unit: Skip hwdb test when hwdb isn't available
Bastien Nocera <[email protected]> Tue, 17 Mar 2026 15:28:57 +0100
| Newsgroups | dev.linux.lists.ell |
|---|---|
| Message-ID | <[email protected]> |
Alpine includes a compatible libudev without implementing hwdb, so skip
the test on that platform.
---
unit/test-hwdb.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/unit/test-hwdb.c b/unit/test-hwdb.c
index 1c4928f3f993..f45f3973d2b9 100644
--- a/unit/test-hwdb.c
+++ b/unit/test-hwdb.c
@@ -14,6 +14,8 @@
#include <ell/ell.h>
+static struct l_hwdb *hwdb = NULL;
+
struct hwdb_stats {
int aliases;
int entries;
@@ -56,11 +58,9 @@ static void check_entry(const char *modalias, struct l_hwdb_entry *entries,
static void test_hwdb(const void *data)
{
- struct l_hwdb *hwdb;
struct hwdb_stats stats = { 0 };
bool result;
- hwdb = l_hwdb_new_default();
assert(hwdb);
result = l_hwdb_foreach(hwdb, check_entry, &stats);
@@ -84,11 +84,18 @@ static void test_hwdb(const void *data)
l_hwdb_unref(hwdb);
}
+static bool test_hwdb_precheck (const void *data)
+{
+ hwdb = l_hwdb_new_default();
+ return hwdb != NULL;
+}
+
int main(int argc, char *argv[])
{
l_test_init(&argc, &argv);
- l_test_add("hwdb", test_hwdb, NULL);
+ l_test_add_func_precheck("hwdb",
+ test_hwdb, test_hwdb_precheck, 0);
return l_test_run();
}
--
2.53.0