diff options
author | Michał Górny <mgorny@gentoo.org> | 2024-02-15 16:33:03 +0100 |
---|---|---|
committer | Sam James <sam@gentoo.org> | 2024-02-21 02:13:45 +0000 |
commit | 997058a825a340813532bef77a34425cf4a88eb2 (patch) | |
tree | 2385c4e0ef4f769ce75be0172af896f0837f3339 | |
parent | estrip: Support debug info deduplication with sys-devel/dwz (diff) | |
download | portage-997058a825a340813532bef77a34425cf4a88eb2.tar.gz portage-997058a825a340813532bef77a34425cf4a88eb2.tar.bz2 portage-997058a825a340813532bef77a34425cf4a88eb2.zip |
Support PROPERTIES=test_userpriv not to drop perms for tests
Support PROPERTIES=test_userpriv and a corresponding ALLOW_TEST=userpriv
to disable FEATURES=userpriv when running the test phase. This can be
used e.g. in dev-python/reflink that needs to be able to mount
filesystem on a loopback device for testing.
Bug: https://bugs.gentoo.org/924585
Signed-off-by: Michał Górny <mgorny@gentoo.org>
Closes: https://github.com/gentoo/portage/pull/1274
Signed-off-by: Sam James <sam@gentoo.org>
-rw-r--r-- | bin/phase-functions.sh | 3 | ||||
-rw-r--r-- | lib/portage/package/ebuild/config.py | 3 | ||||
-rw-r--r-- | lib/portage/package/ebuild/doebuild.py | 3 | ||||
-rw-r--r-- | man/ebuild.5 | 5 | ||||
-rw-r--r-- | man/make.conf.5 | 4 |
5 files changed, 17 insertions, 1 deletions
diff --git a/bin/phase-functions.sh b/bin/phase-functions.sh index cd672a878..ebcf5f242 100644 --- a/bin/phase-functions.sh +++ b/bin/phase-functions.sh @@ -503,7 +503,8 @@ __dyn_test() { fi if has test ${PORTAGE_RESTRICT} && ! has all ${ALLOW_TEST} && - ! { has test_network ${PORTAGE_PROPERTIES} && has network ${ALLOW_TEST}; } + ! { has test_network ${PORTAGE_PROPERTIES} && has network ${ALLOW_TEST}; } && + ! { has test_privileged ${PORTAGE_PROPERTIES} && has privileged ${ALLOW_TEST}; } then einfo "Skipping make test/check due to ebuild restriction." __vecho ">>> Test phase [disabled because of RESTRICT=test]: ${CATEGORY}/${PF}" diff --git a/lib/portage/package/ebuild/config.py b/lib/portage/package/ebuild/config.py index d7b0ca567..c89354cbf 100644 --- a/lib/portage/package/ebuild/config.py +++ b/lib/portage/package/ebuild/config.py @@ -2114,6 +2114,9 @@ class config: "test" in restrict and not "all" in allow_test and not ("test_network" in properties and "network" in allow_test) + and not ( + "test_privileged" in properties and "privileged" in allow_test + ) ) if restrict_test and "test" in self.features: diff --git a/lib/portage/package/ebuild/doebuild.py b/lib/portage/package/ebuild/doebuild.py index 4cf155e03..bc51fdff2 100644 --- a/lib/portage/package/ebuild/doebuild.py +++ b/lib/portage/package/ebuild/doebuild.py @@ -239,6 +239,9 @@ def _doebuild_spawn(phase, settings, actionmap=None, **kwargs): ebuild_sh_arg, ) + if phase == "test" and "test_privileged" in settings["PORTAGE_PROPERTIES"].split(): + kwargs["droppriv"] = False + settings["EBUILD_PHASE"] = phase try: return spawn(cmd, settings, **kwargs) diff --git a/man/ebuild.5 b/man/ebuild.5 index f849f20a2..a32ba4828 100644 --- a/man/ebuild.5 +++ b/man/ebuild.5 @@ -811,6 +811,11 @@ is installed. The package manager may run tests that require an internet connection, even if the ebuild has .IR RESTRICT=test . +.TP +.I test_privileged +The package manager may run tests that require superuser permissions, even if +the ebuild has +.IR RESTRICT=test . .RE .PD 1 .TP diff --git a/man/make.conf.5 b/man/make.conf.5 index 23d840854..e13f6eec4 100644 --- a/man/make.conf.5 +++ b/man/make.conf.5 @@ -1323,6 +1323,10 @@ Run tests in packages specifying \fBPROPERTIES\fR="\fBtest_network\fR". Note that this will most likely cause Internet access during the test suite which could cause additional costs, privacy concerns and intermittent test failures. .TP +.B privileged +Run tests in packages specifying \fBPROPERTIES\fR="\fBtest_privileged\fR". Note +that this will cause the test suite to be run with superuser permissions. +.TP .RE .TP .B RESUMECOMMAND |