From: Zhihang Wei <wzh@ilbers.de>
To: isar-users@googlegroups.com
Subject: [PATCH v2 1/2] testsuite: Support cleanup on rootless build files in test-container
Date: Thu, 16 Jul 2026 16:41:44 +0200 [thread overview]
Message-ID: <20260716144145.1495181-1-wzh@ilbers.de> (raw)
When running tests with rootless builds, some files created with the user
namespace inside the container cannot be removed by the calling user after
the test-container exits without sudo. Add the `--clean-rootless-files`
option to the test-container entrypoint to clean up such files before
leaving the container.
The cleanup is only performed for rootless builds and only removes files
that cannot be cleaned up without sudo outside the container. Other build
artifacts are left untouched so they remain available for CI artifact
collection and post-test inspection.
Signed-off-by: Zhihang Wei <wzh@ilbers.de>
---
.../dockerdata/test-container-entrypoint | 38 +++++++++++++++++--
1 file changed, 34 insertions(+), 4 deletions(-)
diff --git a/testsuite/dockerdata/test-container-entrypoint b/testsuite/dockerdata/test-container-entrypoint
index e4714942..745d181b 100755
--- a/testsuite/dockerdata/test-container-entrypoint
+++ b/testsuite/dockerdata/test-container-entrypoint
@@ -17,6 +17,8 @@ else
shift 1
fi
+clean_rootless_files=0
+
export args="--max-parallel-tasks=1 --disable-sysinfo"
for arg in $*; do
case "$arg" in
@@ -29,15 +31,19 @@ for arg in $*; do
--shell)
export start_shell=1
;;
+ --clean-rootless-files)
+ clean_rootless_files=1
+ ;;
--help)
cat <<EOF
Usage: run-tests.sh [params] ...
Supported parameters:
- --clean Purge results of previous test runs before starting.
- --debug Use '--show=app,test' log settings for avocado.
- --shell Drop into shell rather than starting tests.
- --help Show this help message.
+ --clean Purge results of previous test runs before starting.
+ --debug Use '--show=app,test' log settings for avocado.
+ --shell Drop into shell rather than starting tests.
+ --clean-rootless-files Clean up files created by rootless builds with unshare after the tests finish.
+ --help Show this help message.
Any other parameters are passed to "avocado run". Its usage is:
@@ -59,6 +65,15 @@ case "$args" in
;;
esac
+case "$args" in
+ *"-p rootless=1"*)
+ ;;
+ *)
+ clean_rootless_files=0
+ ;;
+esac
+export clean_rootless_files
+
mkdir /isar
busybox syslogd
@@ -72,6 +87,21 @@ echo exit | /container-entrypoint
gosu builder sh -c '
set -e
+cleanup_rootless_files()
+{
+ rc=$?
+
+ if [ "${clean_rootless_files}" = 1 ]; then
+ find build \
+ \( ! -user "$(whoami)" -type d -prune \) \
+ -exec ./scripts/isar-clean-builddir --rootless {} \;
+ fi
+
+ exit ${rc}
+}
+
+trap cleanup_rootless_files EXIT
+
base_dir=/work/build/testsuite
mkdir -p ${base_dir}/overlay/upper
--
2.39.5
--
You received this message because you are subscribed to the Google Groups "isar-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to isar-users+unsubscribe@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/isar-users/20260716144145.1495181-1-wzh%40ilbers.de.
next reply other threads:[~2026-07-16 14:41 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-16 14:41 Zhihang Wei [this message]
2026-07-16 14:41 ` [PATCH v2 2/2] ci: Add GitLab CI pipeline for rootless builds Zhihang Wei
2026-07-28 15:19 ` [PATCH v2 1/2] testsuite: Support cleanup on rootless build files in test-container Zhihang Wei
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=20260716144145.1495181-1-wzh@ilbers.de \
--to=wzh@ilbers.de \
--cc=isar-users@googlegroups.com \
/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