[PATCH] unit: skip sysctl test if sysfs is not available
Finn Behrens <[email protected]> Mon, 04 Sep 2023 09:57:22 +0200
| Newsgroups | dev.linux.lists.ell |
|---|---|
| Message-ID | <[email protected]> |
Some build environments that build in a mount namespace do not mount
sysfs which makes sysctl and l_sysctl_* fail. Skip the test, if
the file does not exists.
---
unit/test-sysctl.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/unit/test-sysctl.c b/unit/test-sysctl.c
index 820c707..3985e41 100644
--- a/unit/test-sysctl.c
+++ b/unit/test-sysctl.c
@@ -28,6 +28,7 @@
#include <assert.h>
#include <errno.h>
#include <stdio.h>
+#include <unistd.h>
#include <ell/ell.h>
@@ -70,9 +71,18 @@ static void test_sysctl_get_set(const void *data)
int main(int argc, char *argv[])
{
+ int ret;
l_test_init(&argc, &argv);
- l_test_add("sysctl/get_set", test_sysctl_get_set, NULL);
+ /*
+ * test is failing if /proc/sys/net/core/somaxconn does not exists
+ * this can happen when either net is not compiled, or running in a namespace
+ * where sysfs is not mounted
+ */
+ ret = access("/proc/sys/net/core/somaxconn", F_OK);
+ if (!ret)
+ l_test_add("sysctl/get_set", test_sysctl_get_set, NULL);
+
return l_test_run();
}
--
2.37.0 (Apple Git-136)