Hi! On Wed, 2026-08-19 at 11:44:14 +0200, Guillem Jover wrote: > On Fri, 2026-07-17 at 04:59:34 +0200, Guillem Jover wrote: > > On Wed, 2026-07-15 at 17:13:29 +0700, Arnaud Rebillout wrote: > > > Option 2 > > > > > > Do not conflate "needs-root" with "I can create device", which is not > > > necessarily true. The test suite could be adjusted to check whether it's > > > possible to create a device, and if it's not possible, skip those few > > > tests that need this capability. > > > > > > I can provide a patch for Option 2 if you're interested. > > > > I think this would be better, and more resilient in general from an > > upstream PoV regardless of the location the tests are executed by > > downstreams (random CI systems etc). So a patch would be very welcome. > > > > (I assume that doing this in make will be a pain, but the functional > > test suite should eventually get rewritten in autotest, which will make > > it nicer to deal with.) > > I'm assuming that you did not have the time to look into this further, > so I'll start preparing one, but otherwise let me know if you were > still working on this!
In the end I went with a trivial solution, requiring explicitly enabling these tests. Once the test suite gets rewritten it can be switched to be autodetected, but for now this should be good enough. I'm attaching what I ended up with. Tested on a sid chroot, with /usr/bin/mknod removed, to simulate "no mknod allowed". :) Thanks, Guillem
From 054617211a2facbcd35c72aa72a95f030aa82e89 Mon Sep 17 00:00:00 2001 From: Guillem Jover <[email protected]> Date: Wed, 19 Aug 2026 12:52:38 +0200 Subject: [PATCH] test: Make mknod(1) tests conditional and disabled by default On some containers mknod(1) is not permitted, otherwise it would defeat the purpose of the containment. Make all tests that require mknod(1) conditional on a new has-mknod DPKG_TESTSUITE_OPTIONS option, so that we can control when to enable them. And disable them by default. Analysis-by: Arnaud Rebillout <[email protected]> Closes: #1142100, #1144781 --- tests/Feature.mk | 12 +++++++++++- tests/Makefile | 2 +- tests/README | 6 ++++++ tests/t-multiarch/Makefile | 8 +++++--- tests/t-unpack-device/Makefile | 10 +++++++++- tests/t-unpack-hardlink/Makefile | 2 +- 6 files changed, 33 insertions(+), 7 deletions(-) diff --git a/tests/Feature.mk b/tests/Feature.mk index da4e8d659..b3763b2c3 100644 --- a/tests/Feature.mk +++ b/tests/Feature.mk @@ -1,7 +1,7 @@ # # Dpkg functional testsuite (kind of) # -# Copyright © 2015 Guillem Jover <[email protected]> +# Copyright © 2015-2026 Guillem Jover <[email protected]> # ## Feature checks setup ## @@ -16,4 +16,14 @@ ifneq (,$(filter as-root,$(DPKG_TESTSUITE_OPTIONS))) export DPKG_AS_ROOT = 1 endif +# Some containers, such as lxc, do not permit creating devices, as that would +# defeat the containment. +# TODO: Switch this into a dynamic feature check, once we have rewritten the +# test suite in autotest. +ifneq (,$(filter has-mknod,$(DPKG_TESTSUITE_OPTIONS))) +ifdef DPKG_AS_ROOT +export DPKG_SYS_HAS_MKNOD = 1 +endif +endif + endif diff --git a/tests/Makefile b/tests/Makefile index bdd9dd318..445d4613e 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -36,7 +36,7 @@ TESTS_PASS += t-unpack-divert-hardlink TESTS_PASS += t-unpack-divert-nowarn TESTS_PASS += t-unpack-divert-overwrite TESTS_PASS += t-unpack-fifo -ifdef DPKG_AS_ROOT +ifdef DPKG_SYS_HAS_MKNOD # No permissions for devices TESTS_PASS += t-unpack-device endif diff --git a/tests/README b/tests/README index a6592a47a..d288d235e 100644 --- a/tests/README +++ b/tests/README @@ -25,6 +25,12 @@ supported: current root filesystem. If you are uncertain of the consequences, run it at least on a chroot, or isolated in a virtual machine. +* has-mknod + + This enables the tests that rely on mknod(1). These tests will not run + on some containers, where permitting to execute mknod(1) would defeat the + containment. + * test-all This runs all tests, including manual and failing ones. diff --git a/tests/t-multiarch/Makefile b/tests/t-multiarch/Makefile index dd6aa4e25..4e8427a0a 100644 --- a/tests/t-multiarch/Makefile +++ b/tests/t-multiarch/Makefile @@ -63,7 +63,7 @@ $(foreach ma,same foreign foreign-any allowed allowed-any allowed-fake no,\ $(eval $(call build_pkg,dep-on-$(ma)_1.0_all,dep-on-$(ma),1.0,all,no,pkg-ma-$(subst -,:,$(ma)) (>= 1.0)))) shared_file_types := file symlink fifo -ifdef DPKG_AS_ROOT +ifdef DPKG_SYS_HAS_MKNOD shared_file_types += chardev blockdev endif $(foreach arch,$(NATIVE_ARCH) $(FOREIGN_ARCH),\ @@ -488,6 +488,7 @@ pkg-ma-shared-files_$(1)_$(2)-fifo_$(3):: pkg-template test -e pkg-ma-shared-files_$(1)_$(2)-fifo_$(3)$(common_file) || \ $(BEROOT) mkfifo pkg-ma-shared-files_$(1)_$(2)-fifo_$(3)$(common_file) +ifdef DPKG_SYS_HAS_MKNOD pkg-ma-shared-files_$(1)_$(2)-chardev_$(3):: pkg-template [ "$(2)" = "orig" ] && major=1 || major=2; \ [ "$(1)" = "1.0" ] && minor=3 || minor=4; \ @@ -499,6 +500,7 @@ pkg-ma-shared-files_$(1)_$(2)-blockdev_$(3):: pkg-template [ "$(1)" = "1.0" ] && minor=3 || minor=4; \ test -e pkg-ma-shared-files_$(1)_$(2)-blockdev_$(3)$(common_file) || \ $(BEROOT) mknod pkg-ma-shared-files_$(1)_$(2)-blockdev_$(3)$(common_file) b $$$$major $$$$minor +endif endef $(foreach version,1.0 2.0,$(foreach variant,orig alt,\ @@ -513,7 +515,7 @@ test-coinstall-shared-files: ma-setup test -f "$(DPKG_INSTDIR)$(common_file)" ! $(DPKG_INSTALL) pkg-ma-shared-files_1.0_alt-fifo_$(FOREIGN_ARCH).deb test -f "$(DPKG_INSTDIR)$(common_file)" -ifdef DPKG_AS_ROOT +ifdef DPKG_SYS_HAS_MKNOD ! $(DPKG_INSTALL) pkg-ma-shared-files_1.0_alt-chardev_$(FOREIGN_ARCH).deb test -f "$(DPKG_INSTDIR)$(common_file)" ! $(DPKG_INSTALL) pkg-ma-shared-files_1.0_alt-blockdev_$(FOREIGN_ARCH).deb @@ -560,7 +562,7 @@ endif $(DPKG_INSTALL) pkg-ma-shared-files_1.0_orig-symlink_$(FOREIGN_ARCH).deb $(call stdout_is,readlink "$(DPKG_INSTDIR)$(common_file)",orig-1.0) $(DPKG_PURGE) pkg-ma-shared-files:$(NATIVE_ARCH) pkg-ma-shared-files:$(FOREIGN_ARCH) -ifdef DPKG_AS_ROOT +ifdef DPKG_SYS_HAS_MKNOD $(DPKG_INSTALL) pkg-ma-shared-files_1.0_orig-chardev_$(NATIVE_ARCH).deb ! $(DPKG_INSTALL) pkg-ma-shared-files_1.0_alt-chardev_$(FOREIGN_ARCH).deb $(DPKG_INSTALL) pkg-ma-shared-files_1.0_orig-chardev_$(FOREIGN_ARCH).deb diff --git a/tests/t-unpack-device/Makefile b/tests/t-unpack-device/Makefile index 0dcb3ca6d..f061cad94 100644 --- a/tests/t-unpack-device/Makefile +++ b/tests/t-unpack-device/Makefile @@ -10,7 +10,15 @@ $(PKG)/test-null: $(PKG)/test-ram0: $(BEROOT) mknod $@ b 1 0 -build-hook: $(PKG)/test-null $(PKG)/test-ram0 +TEST_DEVICES = +ifdef DPKG_SYS_HAS_MKNOD +TEST_DEVICES += \ + $(PKG)/test-null \ + $(PKG)/test-ram0 \ + # EOL +endif + +build-hook: $(TEST_DEVICES) clean-hook: rm -f $(PKG)/test-null diff --git a/tests/t-unpack-hardlink/Makefile b/tests/t-unpack-hardlink/Makefile index 3412ca5ce..18459149b 100644 --- a/tests/t-unpack-hardlink/Makefile +++ b/tests/t-unpack-hardlink/Makefile @@ -30,7 +30,7 @@ TEST_LINKS := \ $(PKG)/test-fifo-link0 \ # EOL -ifdef DPKG_AS_ROOT +ifdef DPKG_SYS_HAS_MKNOD TEST_LINKS += \ $(PKG)/test-null-link0 \ $(PKG)/test-ram0-link0 \ -- 2.55.0

