]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
tests: add privileged useradd test for BTRFS subvolume homes
authorHadi Chokr <hadichokr@icloud.com>
Thu, 12 Feb 2026 11:17:52 +0000 (12:17 +0100)
committerIker Pedrosa <ikerpedrosam@gmail.com>
Mon, 2 Mar 2026 11:55:25 +0000 (12:55 +0100)
Add a privileged system test that verifies useradd can create home
directories as BTRFS subvolumes.

This test requires elevated privileges to use:
The BTRFS filesystem Framework class to create a /home directory on
BTRFS and check if the Users Home directory is a BTRFS Subvolume.

The test is intentionally isolated and excluded from default test runs
to prevent accidental execution on host systems.

Signed-off-by: Hadi Chokr <hadichokr@icloud.com>
tests/system/tests/privileged/test_privileged_useradd.py [new file with mode: 0644]

diff --git a/tests/system/tests/privileged/test_privileged_useradd.py b/tests/system/tests/privileged/test_privileged_useradd.py
new file mode 100644 (file)
index 0000000..fbee3a8
--- /dev/null
@@ -0,0 +1,35 @@
+"""
+Privileged useradd tests.
+"""
+
+from __future__ import annotations
+
+import pytest
+
+from framework.roles.shadow import Shadow
+from framework.topology import KnownTopology
+
+pytestmark = [
+    pytest.mark.privileged,
+    pytest.mark.topology(KnownTopology.ShadowPrivileged),
+]
+
+
+def test_useradd__btrfs_subvolume_home(shadow: Shadow) -> None:
+    """
+    :title: Btrfs subvolume home
+    :steps:
+        1. Create a user with --btrfs-subvolume-home
+        2. Verify the home directory exists
+        3. Verify the home directory is a Btrfs subvolume
+    :expectedresults:
+        1. The user home directory exists at /home/tuser
+        2. /home/tuser is listed as a Btrfs subvolume
+    :customerscenario: False
+    """
+    with shadow.host.btrfs.loopback_mount("/home"):
+        shadow.useradd("tuser --btrfs-subvolume-home")
+
+        assert shadow.fs.exists("/home/tuser"), "Home directory should exist"
+
+        assert shadow.host.btrfs.subvolume_exists("/home", "tuser")