diff mbox series

strace: Fix uio test and ignore pwritev|pwrite64 tests on musl

Message ID 20250819054447.4003831-1-raj.khem@gmail.com
State New
Headers show
Series strace: Fix uio test and ignore pwritev|pwrite64 tests on musl | expand

Commit Message

Khem Raj Aug. 19, 2025, 5:44 a.m. UTC
The pwritev and pwrite64 are wrappers over pwritev2 syscall in
musl but strace assumes glibc behavior, ignore them for now

Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 ...gnore-pwritev-pwrite64-tests-on-musl.patch | 53 +++++++++++++++++++
 ...01-tests-fix-uio.test-with-musl-libc.patch | 30 +++++++++++
 meta/recipes-devtools/strace/strace_6.16.bb   |  4 ++
 3 files changed, 87 insertions(+)
 create mode 100644 meta/recipes-devtools/strace/strace/0001-Ignore-pwritev-pwrite64-tests-on-musl.patch
 create mode 100644 meta/recipes-devtools/strace/strace/0001-tests-fix-uio.test-with-musl-libc.patch

Comments

Alexander Kanavin Aug. 19, 2025, 9:29 a.m. UTC | #1
On Tue, 19 Aug 2025 at 07:44, Khem Raj via lists.openembedded.org
<raj.khem=gmail.com@lists.openembedded.org> wrote:
> +musl uses wrappers for pwritev and pwrite64 using
> +pwritev2 syscall [1], however the test exepcts that the
> +program will call pwritev and pwrite64 ( glibc behavior )
> +
> +This can be fixed if the function calls are changed to
> +use syscall() API directly, but that needs change upstream [2]
> +
> +[1] https://git.musl-libc.org/cgit/musl/commit/src?id=5370070fded61b569196764673a4fc8440aac79e
> +[2] https://github.com/strace/strace/pull/347

This needs a separate ticket, rather than a passing comment in a
closed pull request.
Better yet, rework the patch to a form suitable for upstream submission.

Alex
diff mbox series

Patch

diff --git a/meta/recipes-devtools/strace/strace/0001-Ignore-pwritev-pwrite64-tests-on-musl.patch b/meta/recipes-devtools/strace/strace/0001-Ignore-pwritev-pwrite64-tests-on-musl.patch
new file mode 100644
index 00000000000..465a8339a9d
--- /dev/null
+++ b/meta/recipes-devtools/strace/strace/0001-Ignore-pwritev-pwrite64-tests-on-musl.patch
@@ -0,0 +1,53 @@ 
+From 13fd22ad0df5b80c428d3ecc0114fb340f3b3894 Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Mon, 18 Aug 2025 22:18:58 -0700
+Subject: [PATCH] Ignore pwritev/pwrite64 tests on musl
+
+musl uses wrappers for pwritev and pwrite64 using
+pwritev2 syscall [1], however the test exepcts that the
+program will call pwritev and pwrite64 ( glibc behavior )
+
+This can be fixed if the function calls are changed to
+use syscall() API directly, but that needs change upstream [2]
+
+[1] https://git.musl-libc.org/cgit/musl/commit/src?id=5370070fded61b569196764673a4fc8440aac79e
+[2] https://github.com/strace/strace/pull/347
+
+Upstream-Status: Inappropriate [Musl Specific]
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+---
+ tests/pread64-pwrite64.gen.test | 2 ++
+ tests/preadv-pwritev.gen.test   | 2 ++
+ tests/pwritev.gen.test          | 2 ++
+ 3 files changed, 6 insertions(+)
+
+--- a/tests/pread64-pwrite64.gen.test
++++ b/tests/pread64-pwrite64.gen.test
+@@ -1,4 +1,7 @@
+ #!/bin/sh -efu
+ # Generated by ./tests/gen_tests.sh from ./tests/gen_tests.in (pread64-pwrite64 -a21 -eread=0 -ewrite=1 -e trace=pread64,pwrite64 -P pread64-pwrite64-tmpfile -P /dev/zero -P /dev/null); do not edit.
+ . "${srcdir=.}/init.sh"
++
++skip_ "Test not ported to musl, musl generates pwritev2"
++
+ run_strace_match_diff -a21 -eread=0 -ewrite=1 -e trace=pread64,pwrite64 -P pread64-pwrite64-tmpfile -P /dev/zero -P /dev/null
+--- a/tests/preadv-pwritev.gen.test
++++ b/tests/preadv-pwritev.gen.test
+@@ -1,4 +1,7 @@
+ #!/bin/sh -efu
+ # Generated by ./tests/gen_tests.sh from ./tests/gen_tests.in (preadv-pwritev -a19 -eread=0 -ewrite=1 -e trace=preadv,pwritev); do not edit.
+ . "${srcdir=.}/init.sh"
++
++skip_ "Test not ported to musl, musl generates pwritev2"
++
+ run_strace_match_diff -a19 -eread=0 -ewrite=1 -e trace=preadv,pwritev
+--- a/tests/pwritev.gen.test
++++ b/tests/pwritev.gen.test
+@@ -1,4 +1,7 @@
+ #!/bin/sh -efu
+ # Generated by ./tests/gen_tests.sh from ./tests/gen_tests.in (pwritev -a22 -s7); do not edit.
+ . "${srcdir=.}/init.sh"
++
++skip_ "Test not ported to musl, musl generates pwritev2"
++
+ run_strace_match_diff -a22 -s7
diff --git a/meta/recipes-devtools/strace/strace/0001-tests-fix-uio.test-with-musl-libc.patch b/meta/recipes-devtools/strace/strace/0001-tests-fix-uio.test-with-musl-libc.patch
new file mode 100644
index 00000000000..a879ca50ca2
--- /dev/null
+++ b/meta/recipes-devtools/strace/strace/0001-tests-fix-uio.test-with-musl-libc.patch
@@ -0,0 +1,30 @@ 
+From 7fadf6947761cc5248aa4a376bb9517481dbaa52 Mon Sep 17 00:00:00 2001
+From: Gyorgy Sarvari <skandigraun@gmail.com>
+Date: Tue, 12 Aug 2025 20:02:31 +0200
+Subject: [PATCH] tests: fix uio.test with musl-libc
+
+musl-libc handles the pwrite calls differently than glibc, making
+the uio test fail.  Using glibc, there are separated pwrite and pwritev
+calls, however musl uses only pwritev2 for both pwrite and pwritev.
+
+To account to this difference, modify the expected matching regexp
+to also match the musl output (append it with an OR).
+
+Upstream-Status: Backport [https://github.com/strace/strace/pull/347]
+Signed-off-by: Gyorgy Sarvari <skandigraun@gmail.com>
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+---
+ tests/uio.expected | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/tests/uio.expected b/tests/uio.expected
+index 98d5c06..2a712a1 100644
+--- a/tests/uio.expected
++++ b/tests/uio.expected
+@@ -1,4 +1,4 @@
+ pread(64)?\(0, "\\0\\0\\0\\0", 4, 1004211379570065135\) += 4
+ preadv\(0, \[\{iov_base="\\0\\0\\0\\0", iov_len=4\}\], 1, 1004211379570065135\) += 4
+-pwrite(64)?\(0, "\\0\\0\\0\\0", 4, 1004211379570065135\) += 4
+-pwritev\(0, \[\{iov_base="\\0\\0\\0\\0", iov_len=4\}\], 1, 1004211379570065135\) += 4
++pwrite(64)?\(0, "\\0\\0\\0\\0", 4, 1004211379570065135\) += 4|pwritev2\(0, \[\{iov_base="\\0\\0\\0\\0", iov_len=4}], 1, 1004211379570065135, RWF_NOAPPEND\) += 4
++pwritev\(0, \[\{iov_base="\\0\\0\\0\\0", iov_len=4\}\], 1, 1004211379570065135\) += 4|pwritev2\(0, \[\{iov_base="\\0\\0\\0\\0", iov_len=4}], 1, 1004211379570065135, RWF_NOAPPEND\) += 4
diff --git a/meta/recipes-devtools/strace/strace_6.16.bb b/meta/recipes-devtools/strace/strace_6.16.bb
index 3e6b855df06..0552caa2b6d 100644
--- a/meta/recipes-devtools/strace/strace_6.16.bb
+++ b/meta/recipes-devtools/strace/strace_6.16.bb
@@ -14,6 +14,10 @@  SRC_URI = "${GITHUB_BASE_URI}/download/v${PV}/strace-${PV}.tar.xz \
            file://skip-load.patch \
            file://0001-configure-Use-autoconf-macro-to-detect-largefile-sup.patch \
            file://0002-tests-Replace-off64_t-with-off_t.patch \
+           file://0001-tests-fix-uio.test-with-musl-libc.patch \
+           "
+SRC_URI:append:libc-musl = "\
+           file://0001-Ignore-pwritev-pwrite64-tests-on-musl.patch \
            "
 SRC_URI[sha256sum] = "3d7aee7e4f044b2f67f3d51a8a76eda18076e9fb2774de54ac351d777d4ebffa"