[2/2] testsuite: add test for rootfs sstate

Message ID 20261023133338.32200-2-akarpovich@ilbers.de
State New
Headers show
Series [1/2] rootfs: clean rootfs dir before unpack from sstate | expand

Commit Message

Aliaksei Karpovich Oct. 23, 2026, 1:33 p.m. UTC
This test should catch the bug when user builds the same image
multiple times, adds and removes some package in image, but this
package is stayed on rootfs after removing.
The root cause is in sstate for rootfs.

Test conatins 3 build steps:
 1. Build the target
 2. Add some package in image and build the same target
 3. Remove package from image (return back to state in step 1) and
build the target again.

After each step, the test checks for the presence or absence of
the package on the rootfs.
---
 testsuite/citest.py | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

Patch

diff --git a/testsuite/citest.py b/testsuite/citest.py
index 0cedcc2c..b701ed13 100644
--- a/testsuite/citest.py
+++ b/testsuite/citest.py
@@ -1563,6 +1563,42 @@  class SstateTest(CIBaseTest):
         self.perform_sstate_test(image_target, package_target)
 
 
+class RootfsSstateTest(CIBaseTest):
+    """
+    Test for correct behavior of sstate for rootfs.
+    Contains 3 steps:
+     - Step 1: build isar-image-base without any package.
+     - Step 2: build isar-image-base with hello-isar package only.
+     - Step 3: build again isar-image-base without any package.
+
+    :avocado: tags=sstate,fast
+    """
+
+    def test_rootfs_sstate(self):
+        import glob
+
+        image = 'isar-image-base'
+        arch = 'amd64'
+        distro = 'trixie'
+
+        self.init()
+
+        image_target = f'mc:qemu{arch}-{distro}:{image}'
+        hello_bin_file = f'{self.build_dir}/tmp/work/*-{distro}-{arch}/{image}-qemu{arch}/*/rootfs/usr/bin/hello-isar'
+
+        self.perform_build_test(image_target, image_install='', sstate=True)
+        if glob.glob(hello_bin_file):
+            self.fail("Step 1: hello-isar shouldn't be on rootfs")
+
+        self.perform_build_test(image_target, image_install='hello-isar', sstate=True)
+        if not glob.glob(hello_bin_file):
+            self.fail("Step 2: hello-isar should be on rootfs")
+
+        self.perform_build_test(image_target, image_install='', sstate=True)
+        if glob.glob(hello_bin_file):
+            self.fail("Step 3: hello-isar shouldn't be on rootfs")
+
+
 class SingleTest(CIBaseTest):
 
     """