Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sys-kernel/dracut: enable testing #34052

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 7 additions & 5 deletions sys-kernel/dracut/dracut-060_pre20231030.ebuild
Expand Up @@ -62,13 +62,18 @@ BDEPEND="
>=app-text/docbook-xsl-stylesheets-1.75.2
>=dev-libs/libxslt-1.1.26
virtual/pkgconfig
test? (
app-shells/dash
app-emulation/qemu
)
"

QA_MULTILIB_PATHS="usr/lib/dracut/.*"

PATCHES=(
"${FILESDIR}"/gentoo-ldconfig-paths-r1.patch
"${FILESDIR}"/dracut-060-fix-resume-hostonly.patch
"${FILESDIR}"/dracut-tests.patch
)

src_configure() {
Expand All @@ -85,13 +90,10 @@ src_configure() {
}

src_test() {
if [[ ${EUID} != 0 ]]; then
# Tests need root privileges, bug #298014
ewarn "Skipping tests: Not running as root."
elif [[ ! -w /dev/kvm ]]; then
if [[ ! -w /dev/kvm ]]; then
ewarn "Skipping tests: Unable to access /dev/kvm."
else
emake -C test check
tools/test-github.sh gentoo "98"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about running the full test suite if mount is readable? Something like this:

Suggested change
tools/test-github.sh gentoo "98"
local mount=$(type -P mount)
if [[ -n ${mount} && -r ${mount} ]]; then
emake -C test check
else
tools/test-github.sh gentoo "98" || die
fi

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another potential challange is networked tests - e.g. nfs, iscsi, nbd. The test suite would create a server and client VM with qemu and boot both VMs. Would we want to/is it normally allowed to run this kind of test suites as part of packaging ?

Note that for example that just the NFS test (Test number 20) itself (if everything goes well), runs for about 45 min - see the upstream timeout on networking CI tests - https://github.com/dracutdevs/dracut/blob/master/.github/workflows/integration.yml#L58 . Most of the time this tests times out even with the 45 min timeout limit.

Also note that we do not run networked tests on Gentoo upstream - https://github.com/dracutdevs/dracut/blob/master/.github/workflows/integration.yml#L27

IMHO we want to run only a subset of the tests - at least initially.

There is an attempt to reorganize the test suite upstream so that it is easier to just pick a non-networked tests downstream - see dracutdevs/dracut#2263

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at the test-github.sh script, it looks like it runs configure and make to compile the code (again). We don't want to do that in the src_test function.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair point. I think this also came up during Debian/Ubuntu discussion. Let me drop some pointers here for now, and I hope to find some time to upload a new revision later.

https://salsa.debian.org/debian/dracut/-/merge_requests/24/

https://bugs.launchpad.net/ubuntu/+source/dracut/+bug/2031417

fi
}

Expand Down
78 changes: 78 additions & 0 deletions sys-kernel/dracut/files/dracut-tests.patch
@@ -0,0 +1,78 @@
From 71055058c0bdb6fec0dbebf2ec8bbfc968820b88 Mon Sep 17 00:00:00 2001
From: Laszlo Gombos <laszlo.gombos@gmail.com>
Date: Tue, 21 Feb 2023 00:20:29 +0000
Subject: [PATCH] fix(test): running tests no longer requires to be root

Remove sudo from test containers.
---
Makefile | 1 -
test/Makefile | 1 -
test/test-functions | 12 ------------
7 files changed, 6 insertions(+), 22 deletions(-)

diff --git a/Makefile b/Makefile
index 5fd9395648..15c0af245a 100644
--- a/Makefile
+++ b/Makefile
@@ -270,7 +270,6 @@ endif
endif

check: all syncheck
- @[ "$$EUID" == "0" ] || { echo "'check' must be run as root! Please use 'sudo'."; exit 1; }
@$(MAKE) -C test check

testimage: all
diff --git a/test/Makefile b/test/Makefile
index dfaa4509ea..518e7d616d 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -1,7 +1,6 @@
.PHONY: all check clean $(wildcard TEST-??-*)

$(wildcard TEST-??-*):
- @[ "$(shell id -u)" = 0 ] || { echo "'check' must be run as root! Please use 'sudo'."; exit 1; }
@{ \
[ -d $@ ] || exit 0; \
[ -f $@/Makefile ] || exit 0; \
diff --git a/test/test-functions b/test/test-functions
index abd20ec628..8a3765af0d 100644
--- a/test/test-functions
+++ b/test/test-functions
@@ -49,15 +49,6 @@ COLOR_FAILURE='\033[0;31m'
COLOR_WARNING='\033[0;33m'
COLOR_NORMAL='\033[0;39m'

-check_root() {
- if ((EUID != 0)); then
- SETCOLOR_FAILURE
- echo "Tests must be run as root! Please use 'sudo'."
- SETCOLOR_NORMAL
- exit 1
- fi
-}
-
# generate qemu arguments for named raw disks
#
# qemu_add_drive_args <index> <args> <filename> <id-name> [<bootindex>]
@@ -119,13 +110,11 @@ test_marker_check() {
while (($# > 0)); do
case $1 in
--run)
- check_root
echo "TEST RUN: $TEST_DESCRIPTION"
test_check && test_run
exit $?
;;
--setup)
- check_root
echo "TEST SETUP: $TEST_DESCRIPTION"
test_check && test_setup
exit $?
@@ -138,7 +127,6 @@ while (($# > 0)); do
exit $?
;;
--all)
- check_root
if ! test_check 2 &> test${TEST_RUN_ID:+-$TEST_RUN_ID}.log; then
echo -e "TEST: $TEST_DESCRIPTION " "$COLOR_WARNING" "[SKIPPED]" "$COLOR_NORMAL"
exit 0