diff options
author | Finn Behrens <me@kloenk.dev> | 2023-09-04 09:57:22 +0200 |
---|---|---|
committer | Denis Kenzior <denkenz@gmail.com> | 2023-09-04 22:26:40 -0500 |
commit | dd457d8642b721c36204d52829be46f005cec341 (patch) | |
tree | 0a263f255f8aec67e7a0b0dabe04fbac5974a4e9 | |
parent | 73e85097f2bc3e95275a905bfca00bb3c8166ce1 (diff) |
unit: skip sysctl test if sysfs is not available
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.
-rw-r--r-- | unit/test-sysctl.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/unit/test-sysctl.c b/unit/test-sysctl.c index 820c7079..d48b7144 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 exist + * 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(); } |