($INBOX_DIR/description missing)
 help / color / mirror / Atom feed
From: Finn Behrens <me@kloenk.dev>
To: ell@lists.linux.dev
Cc: dev@leona.is
Subject: [PATCH] unit: skip sysctl test if sysfs is not available
Date: Mon, 04 Sep 2023 09:57:22 +0200	[thread overview]
Message-ID: <526DA75D-01AB-4D85-BF5C-5F25E5C39480@kloenk.dev> (raw)

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)


             reply	other threads:[~2023-09-04  8:06 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-04  7:57 Finn Behrens [this message]
2023-09-05  3:28 ` [PATCH] unit: skip sysctl test if sysfs is not available Denis Kenzior

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=526DA75D-01AB-4D85-BF5C-5F25E5C39480@kloenk.dev \
    --to=me@kloenk.dev \
    --cc=dev@leona.is \
    --cc=ell@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).