Message ID | 526DA75D-01AB-4D85-BF5C-5F25E5C39480@kloenk.dev (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | unit: skip sysctl test if sysfs is not available | expand |
Context | Check | Description |
---|---|---|
tedd_an/pre-ci_am | fail | error: unit/test-sysctl.c: does not exist in index hint: Use 'git am --show-current-patch' to see the failed patch |
Hi Finn, On 9/4/23 02:57, Finn Behrens wrote: > 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(-) > Applied, thanks. Regards, -Denis
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(); }