From: Mark Hatle <mark.hatle@kernel.crashing.org>
To: yocto-patches@lists.yoctoproject.org
Subject: [pseudo][pseudo-1.9]PATCH 01/10] test: Skip open_tree tests when the function or syscall is unavailable
Date: Wed, 11 Nov 2026 10:15:03 -0600 [thread overview]
Message-ID: <1794413712-18072-2-git-send-email-mark.hatle@kernel.crashing.org> (raw)
In-Reply-To: <1794413712-18072-1-git-send-email-mark.hatle@kernel.crashing.org>
From: Mark Hatle <mark.hatle@amd.com>
test-open_tree failed to build on systems where glibc does not provide
open_tree() (added in glibc 2.36), e.g. Ubuntu 22.04, breaking 'make test'.
Declare open_tree() weak so the test links, and skip the test if the
symbol is not resolved or the call returns ENOSYS. Under pseudo the
symbol always resolves to libpseudo's wrapper, which returns ENOSYS
when libc lacks open_tree().
test-open_tree_attr-syscall failed on kernels older than 6.15 which do
not implement the open_tree_attr syscall. Probe the syscall first and
skip the test if it returns ENOSYS.
Both tests return 77 to indicate a skip, which the shell wrappers convert
to 255 so run_tests.sh reports them as skipped, matching the existing
openat2 tests.
AI-Generated: Uses GitHub Copilot
Signed-off-by: Mark Hatle <mark.hatle@amd.com>
(cherry picked from commit ef3fadb80ea4822fd6ddbdd6fd21dd6a358f010f)
Signed-off-by: Mark Hatle <mark.hatle@amd.com>
---
test/test-open_tree.c | 25 +++++++++++++++++++++++++
test/test-open_tree.sh | 15 +++++++++++++--
test/test-open_tree_attr-syscall.c | 11 +++++++++++
test/test-open_tree_attr-syscall.sh | 15 +++++++++++++--
4 files changed, 62 insertions(+), 4 deletions(-)
diff --git a/test/test-open_tree.c b/test/test-open_tree.c
index 9570f11..3b1b7ea 100644
--- a/test/test-open_tree.c
+++ b/test/test-open_tree.c
@@ -10,6 +10,14 @@
#define TEST_DIR "test-open-tree-dir"
#define TEST_FILE "test-open-tree-file"
+/*
+ * Older glibc versions (< 2.36) do not provide open_tree(). Declare it
+ * weak so the test still links; at runtime it resolves to glibc's or
+ * libpseudo's open_tree if either provides it, otherwise it is NULL and
+ * the test is skipped.
+ */
+extern int open_tree(int dirfd, const char *path, unsigned int flags) __attribute__((weak));
+
static int test_no_flags(void) {
int treefd = -1;
int fd = -1;
@@ -124,6 +132,23 @@ static void cleanup(void) {
}
int main(void) {
+ int probefd;
+
+ if (!open_tree) {
+ fprintf(stderr, "open_tree() not available, skipping.\n");
+ return 77;
+ }
+
+ /* pseudo exports open_tree() but returns ENOSYS if libc lacks it */
+ probefd = open_tree(AT_FDCWD, ".", 0);
+ if (probefd == -1 && errno == ENOSYS) {
+ fprintf(stderr, "open_tree() returned ENOSYS, skipping.\n");
+ return 77;
+ }
+ if (probefd != -1) {
+ close(probefd);
+ }
+
cleanup();
if (mkdir(TEST_DIR, 0777) == -1) {
diff --git a/test/test-open_tree.sh b/test/test-open_tree.sh
index 427d550..274c654 100755
--- a/test/test-open_tree.sh
+++ b/test/test-open_tree.sh
@@ -1,9 +1,20 @@
#!/bin/sh
-./test/test-open_tree
+# rc 77 indicates open_tree() is not available, so report skipped (255).
+# This usually indicates that glibc does not have the open_tree function.
+run_test() {
+ "$@"
+ rc=$?
+ if [ "$rc" -eq 77 ]; then
+ exit 255
+ fi
+ return "$rc"
+}
+
+run_test ./test/test-open_tree
rc1=$?
-PSEUDO_IGNORE_PATHS=/ ./test/test-open_tree
+run_test env PSEUDO_IGNORE_PATHS=/ ./test/test-open_tree
rc2=$?
exit $((rc1 | rc2))
diff --git a/test/test-open_tree_attr-syscall.c b/test/test-open_tree_attr-syscall.c
index cc38c5f..e4e652e 100644
--- a/test/test-open_tree_attr-syscall.c
+++ b/test/test-open_tree_attr-syscall.c
@@ -150,6 +150,17 @@ static void cleanup(void) {
}
int main(void) {
+ int probefd;
+
+ probefd = do_open_tree_attr_syscall(AT_FDCWD, ".", 0);
+ if (probefd == -1 && errno == ENOSYS) {
+ fprintf(stderr, "open_tree_attr syscall not supported, skipping.\n");
+ return 77;
+ }
+ if (probefd != -1) {
+ close(probefd);
+ }
+
cleanup();
if (mkdir(TEST_DIR, 0777) == -1) {
diff --git a/test/test-open_tree_attr-syscall.sh b/test/test-open_tree_attr-syscall.sh
index f6e51f4..d87043e 100755
--- a/test/test-open_tree_attr-syscall.sh
+++ b/test/test-open_tree_attr-syscall.sh
@@ -1,9 +1,20 @@
#!/bin/sh
-./test/test-open_tree_attr-syscall
+# rc 77 indicates the open_tree_attr syscall is not supported (ENOSYS),
+# so report skipped (255). This usually indicates an older kernel.
+run_test() {
+ "$@"
+ rc=$?
+ if [ "$rc" -eq 77 ]; then
+ exit 255
+ fi
+ return "$rc"
+}
+
+run_test ./test/test-open_tree_attr-syscall
rc1=$?
-PSEUDO_IGNORE_PATHS=/ ./test/test-open_tree_attr-syscall
+run_test env PSEUDO_IGNORE_PATHS=/ ./test/test-open_tree_attr-syscall
rc2=$?
exit $((rc1 | rc2))
--
1.8.3.1
next prev parent reply other threads:[~2026-11-11 16:15 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-11 16:15 [pseudo][pseudo-1.9]PATCH 00/10] Backports from master to 1.9 branch Mark Hatle
2026-11-11 16:15 ` Mark Hatle [this message]
2026-11-11 16:15 ` [pseudo][pseudo-1.9]PATCH 02/10] makewrappers: Don't generate unused _int paths with noignore_path Mark Hatle
2026-11-11 16:15 ` [pseudo][pseudo-1.9]PATCH 03/10] ports/linux: Don't require <linux/mount.h> Mark Hatle
2026-11-11 16:15 ` [pseudo][pseudo-1.9]PATCH 04/10] configure: Require GCC 5 or later Mark Hatle
2026-11-11 16:15 ` [pseudo][pseudo-1.9]PATCH 05/10] pseudo_client: serialize path changes across clients Mark Hatle
2026-11-11 16:15 ` [pseudo][pseudo-1.9]PATCH 06/10] ports: hold the path lock in create and metadata wrappers Mark Hatle
2026-11-11 16:15 ` [pseudo][pseudo-1.9]PATCH 07/10] ports: check created files under the path lock before recording them Mark Hatle
2026-11-11 16:15 ` [pseudo][pseudo-1.9]PATCH 08/10] test-parallel-ops: Add a parallel create/rename/link/chmod test Mark Hatle
2026-11-11 16:15 ` [pseudo][pseudo-1.9]PATCH 09/10] README.security: Add information specific to file/process security Mark Hatle
2026-11-11 16:15 ` [pseudo][pseudo-1.9]PATCH 10/10] AGENTS.md: Add to assist future developers Mark Hatle
2026-11-12 11:46 ` [yocto-patches] [pseudo][pseudo-1.9]PATCH 00/10] Backports from master to 1.9 branch Yoann Congal
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=1794413712-18072-2-git-send-email-mark.hatle@kernel.crashing.org \
--to=mark.hatle@kernel.crashing.org \
--cc=yocto-patches@lists.yoctoproject.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.