acl: improve ptest packaging
PATCH v2 1/1 acl: improve ptest packaging
As there's a small number of test binaries in acl, instead of installing large chunks of the build tree we can install just those and use a boilerplate test runner.
Drop 0001-tests-do-not-hardcode-the-build-path-into-a-helper-l.patch and replace with an explicit -DBASEDIR= flag passed at build time.
Drop 0001-test-patch-out-failing-bits.patch and delete the tests that fail entirely as they won't work without a specific user/group setup.
Backport a patch from upstream so that some tests don't use excessive amounts of memory.
Backport a patch from upstream to cater for both glibc and musl's behaviour with interleaved stdout/stderr, fixing the tests on musl.
Clean up dependencies now that we're not shipping the build system.
--- ...t_uid-fix-memory-wasting-loop-if-use.patch | 49 +++++++++++++++ ...isc.test-Don-t-mix-stdout-and-stderr.patch | 35 +++++++++++ .../0001-test-patch-out-failing-bits.patch | 60 ------------------ ...dcode-the-build-path-into-a-helper-l.patch | 24 ------- meta/recipes-support/attr/acl/run-ptest | 37 +++++++---- meta/recipes-support/attr/acl_2.3.2.bb | 63 +++++++------------ 6 files changed, 133 insertions(+), 135 deletions(-) create mode 100644 meta/recipes-support/attr/acl/0001-libmisc-__acl_get_uid-fix-memory-wasting-loop-if-use.patch create mode 100644 meta/recipes-support/attr/acl/0001-test-misc.test-Don-t-mix-stdout-and-stderr.patch delete mode 100644 meta/recipes-support/attr/acl/0001-test-patch-out-failing-bits.patch delete mode 100644 meta/recipes-support/attr/acl/0001-tests-do-not-hardcode-the-build-path-into-a-helper-l.patch
meta/recipes-support/attr/acl/0001-libmisc-__acl_get_uid-fix-memory-wasting-loop-if-use.patch new file +49 -0
@@ -0,0 +1,49 @@ +From 56abe432b65801f31277fb9a3bca0f9e31502315 Mon Sep 17 00:00:00 2001 +From: Matthias Gerstner <[email protected]> +Date: Thu, 25 Apr 2024 12:43:49 +0200 +Subject: [PATCH] libmisc: __acl_get_uid(): fix memory wasting loop if user + does not exist + +I noticed that `acl_from_text()` unexpectedly returns ENOMEM for invalid +user names. The reason for this is a missing break statement in the for +loop in `__acl_get_uid()`, which causes the loop to act as if ERANGE was +returned from `getpwnam_r()`, thereby exponentially increasing the +buffer size to (in my case) multiple gigabytes, until `grow_buffer()` +reports ENOMEM, which terminates the `__acl_get_uid()` function. + +This is a pretty costly "no such user" lookup that can disturb a +process's heap memory management, but can also cause a process to fail +e.g. if it is multithreaded and other threads encounter an ENOMEM, +before `__acl_get_uid()` frees the gigantic heap buffer and returns. +The allocated memory isn't actually used. Therefore on Linux it should +not affect other processes by default, due to its overcommit memory +and lazy memory allocation strategy. + +Fix this by properly terminating the for loop on any conditions except +an ERANGE error being reported. The same break statement correctly +exists in `__acl_get_gid()` already. + +Fixes: 3737f00 ("use thread-safe getpwnam_r and getgrnam_r") +Signed-off-by: Andreas Gruenbacher <[email protected]> + +Upstream-Status: Backport +Signed-off-by: Ross Burton <[email protected]> +--- + libmisc/uid_gid_lookup.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/libmisc/uid_gid_lookup.c b/libmisc/uid_gid_lookup.c +index a4f21f6..74baab4 100644 +--- a/libmisc/uid_gid_lookup.c ++++ b/libmisc/uid_gid_lookup.c +@@ -91,6 +91,7 @@ __acl_get_uid(const char *token, uid_t *uid_p) + if (err == ERANGE) + continue; + errno = err ? err : EINVAL; ++ break; + } + free(buffer); + return result ? 0 : -1; +-- +2.43.0 +
meta/recipes-support/attr/acl/0001-test-misc.test-Don-t-mix-stdout-and-stderr.patch new file +35 -0
@@ -0,0 +1,35 @@ +From 47f8039ec9bd08b629775c8e788d11e41fa95f14 Mon Sep 17 00:00:00 2001 +From: Andreas Gruenbacher <[email protected]> +Date: Mon, 24 Mar 2025 21:14:09 +0100 +Subject: [PATCH] test/misc.test: Don't mix stdout and stderr + +In different environments, we may not get the stdout and stderr output +in the order the run script expects, so check both separately. + +Fixes: https://savannah.nongnu.org/bugs/?66944 +Signed-off-by: Andreas Gruenbacher <[email protected]> + +Upstream-Status: Backport +Signed-off-by: Ross Burton <[email protected]> +--- + test/misc.test | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/test/misc.test b/test/misc.test +index 06b3136..57c02e5 100644 +--- a/test/misc.test ++++ b/test/misc.test +@@ -440,8 +440,9 @@ Dangling symlink test https://savannah.nongnu.org/bugs/?28131 + > other::r-x + > + $ setfacl -R -m u:bin:rw d +- $ getfacl -RL d ++ $ getfacl -RL d > /dev/null + > getfacl: d/b: No such file or directory ++ $ getfacl -RL d 2> /dev/null + > # file: d + > # owner: %TUSER + > # group: %TGROUP +-- +2.43.0 +
meta/recipes-support/attr/acl/0001-test-patch-out-failing-bits.patch deleted +0 -60
60 lines not on this page · raw message
meta/recipes-support/attr/acl/0001-tests-do-not-hardcode-the-build-path-into-a-helper-l.patch deleted +0 -24
@@ -1,24 +0,0 @@ -From 42ae3f8a5e32ba0681ccd1552a203ddad8748a6e Mon Sep 17 00:00:00 2001 -From: Alexander Kanavin <[email protected]> -Date: Thu, 12 Dec 2019 13:45:52 +0100 -Subject: [PATCH] tests: do not hardcode the build path into a helper library - -Upstream-Status: Inappropriate [oe-core specific] -Signed-off-by: Alexander Kanavin <[email protected]> ---- - test/Makemodule.am | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/test/Makemodule.am b/test/Makemodule.am -index e1d715d..cffe732 100644 ---- a/test/Makemodule.am -+++ b/test/Makemodule.am -@@ -30,7 +30,7 @@ EXTRA_DIST += \ - check_LTLIBRARIES = libtestlookup.la - - libtestlookup_la_SOURCES = test/test_passwd.c test/test_group.c --libtestlookup_la_CFLAGS = -DBASEDIR=\"$(abs_srcdir)\" -+libtestlookup_la_CFLAGS = -DBASEDIR=\"/tmp/acl-ptest\" - libtestlookup_la_LDFLAGS = -rpath $(abs_builddir) - - # Make sure translations don't break tests when matching output.
meta/recipes-support/attr/acl/run-ptest +26 -11
@@ -1,16 +1,31 @@ #!/bin/sh -# -#This script is used to run acl test suites -#umask 077 +failed=0 +all=0 -mkdir -p /tmp/acl-ptest/test -cp test/test.* /tmp/acl-ptest/test -set +e -make test-suite.log -exitcode=$? -if [ $exitcode -ne 0 -a -e test-suite.log ]; then - cat test-suite.log +for f in *.test; do + LD_PRELOAD=$(pwd)/libtestlookup.so ./run $f + case "$?" in + 0) + echo "PASS: $f" + all=$((all + 1)) + ;; + 77) + echo "SKIP: $f" + ;; + *) + echo "FAIL: $f" + failed=$((failed + 1)) + all=$((all + 1)) + ;; + esac +done + +if [ "$failed" -eq 0 ] ; then + echo "All $all tests passed" + exit 0 +else + echo "$failed of $all tests failed" + exit 1 fi -exit $exitcode
meta/recipes-support/attr/acl_2.3.2.bb +23 -40
91 lines not on this page · raw message
Signature · 1 line
2.43.0