summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>2022-03-02 15:33:29 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2022-03-04 17:14:15 +0000
commit6d715aafecc1196b9549b6acaca9e8c7d4e034e8 (patch)
tree332eac313bfaf71cfc07f95650ebc2d832d92a6a
parent2126584d61c1d94c88cceb4f5bff14d8ec60cb91 (diff)
downloadpoky-6d715aafecc1196b9549b6acaca9e8c7d4e034e8.tar.gz
oeqa: selftest: overlayfs: add test for image with fstab entry
(From OE-Core rev: 67f1959a46beec5edf133f2f8b02635feea7e599) Signed-off-by: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta-selftest/recipes-test/base-files/base-files_%.bbappend2
-rw-r--r--meta/lib/oeqa/selftest/cases/overlayfs.py82
2 files changed, 57 insertions, 27 deletions
diff --git a/meta-selftest/recipes-test/base-files/base-files_%.bbappend b/meta-selftest/recipes-test/base-files/base-files_%.bbappend
new file mode 100644
index 0000000000..205720982c
--- /dev/null
+++ b/meta-selftest/recipes-test/base-files/base-files_%.bbappend
@@ -0,0 +1,2 @@
1# This bbappend is used to alter the recipe using the test_recipe.inc file created by tests.
2include test_recipe.inc
diff --git a/meta/lib/oeqa/selftest/cases/overlayfs.py b/meta/lib/oeqa/selftest/cases/overlayfs.py
index 79d36fa93c..56ae48ce64 100644
--- a/meta/lib/oeqa/selftest/cases/overlayfs.py
+++ b/meta/lib/oeqa/selftest/cases/overlayfs.py
@@ -107,7 +107,7 @@ OVERLAYFS_MOUNT_POINT[usr-share-overlay] = "/usr/share/overlay"
107 line = getline(res, "Missing required mount point for OVERLAYFS_MOUNT_POINT[mnt-overlay] in your MACHINE configuration") 107 line = getline(res, "Missing required mount point for OVERLAYFS_MOUNT_POINT[mnt-overlay] in your MACHINE configuration")
108 self.assertTrue(line and line.startswith("Parsing recipes...ERROR:"), msg=res.output) 108 self.assertTrue(line and line.startswith("Parsing recipes...ERROR:"), msg=res.output)
109 109
110 def test_correct_image(self): 110 def _test_correct_image(self, recipe, data):
111 """ 111 """
112 Summary: Check that we can create an image when all parameters are 112 Summary: Check that we can create an image when all parameters are
113 set correctly 113 set correctly
@@ -126,31 +126,6 @@ VIRTUAL-RUNTIME_init_manager = "systemd"
126KERNEL_EXTRA_FEATURES:append = " features/overlayfs/overlayfs.scc" 126KERNEL_EXTRA_FEATURES:append = " features/overlayfs/overlayfs.scc"
127""" 127"""
128 128
129 systemd_machine_unit_append = """
130SYSTEMD_SERVICE:${PN} += " \
131 mnt-overlay.mount \
132"
133
134do_install:append() {
135 install -d ${D}${systemd_system_unitdir}
136 cat <<EOT > ${D}${systemd_system_unitdir}/mnt-overlay.mount
137[Unit]
138Description=Tmpfs directory
139DefaultDependencies=no
140
141[Mount]
142What=tmpfs
143Where=/mnt/overlay
144Type=tmpfs
145Options=mode=1777,strictatime,nosuid,nodev
146
147[Install]
148WantedBy=multi-user.target
149EOT
150}
151
152"""
153
154 overlayfs_recipe_append = """ 129 overlayfs_recipe_append = """
155OVERLAYFS_WRITABLE_PATHS[mnt-overlay] += "/usr/share/another-overlay-mount" 130OVERLAYFS_WRITABLE_PATHS[mnt-overlay] += "/usr/share/another-overlay-mount"
156 131
@@ -179,7 +154,7 @@ EOT
179 154
180 self.write_config(config) 155 self.write_config(config)
181 self.add_overlay_conf_to_machine() 156 self.add_overlay_conf_to_machine()
182 self.write_recipeinc('systemd-machine-units', systemd_machine_unit_append) 157 self.write_recipeinc(recipe, data)
183 self.write_recipeinc('overlayfs-user', overlayfs_recipe_append) 158 self.write_recipeinc('overlayfs-user', overlayfs_recipe_append)
184 159
185 bitbake('core-image-minimal') 160 bitbake('core-image-minimal')
@@ -210,6 +185,59 @@ EOT
210 line = getline_qemu(output, "upperdir=/mnt/overlay/upper/usr/share/another-overlay-mount") 185 line = getline_qemu(output, "upperdir=/mnt/overlay/upper/usr/share/another-overlay-mount")
211 self.assertTrue(line and line.startswith("overlay"), msg=output) 186 self.assertTrue(line and line.startswith("overlay"), msg=output)
212 187
188 def test_correct_image_fstab(self):
189 """
190 Summary: Check that we can create an image when all parameters are
191 set correctly via fstab
192 Expected: Image is created successfully
193 Author: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>
194 """
195
196 base_files_append = """
197do_install:append() {
198 cat <<EOT >> ${D}${sysconfdir}/fstab
199tmpfs /mnt/overlay tmpfs mode=1777,strictatime,nosuid,nodev 0 0
200EOT
201}
202"""
203
204 self._test_correct_image('base-files', base_files_append)
205
206 def test_correct_image_unit(self):
207 """
208 Summary: Check that we can create an image when all parameters are
209 set correctly via mount unit
210 Expected: Image is created successfully
211 Author: Vyacheslav Yurkov <uvv.mail@gmail.com>
212 """
213
214 systemd_machine_unit_append = """
215SYSTEMD_SERVICE:${PN} += " \
216 mnt-overlay.mount \
217"
218
219do_install:append() {
220 install -d ${D}${systemd_system_unitdir}
221 cat <<EOT > ${D}${systemd_system_unitdir}/mnt-overlay.mount
222[Unit]
223Description=Tmpfs directory
224DefaultDependencies=no
225
226[Mount]
227What=tmpfs
228Where=/mnt/overlay
229Type=tmpfs
230Options=mode=1777,strictatime,nosuid,nodev
231
232[Install]
233WantedBy=multi-user.target
234EOT
235}
236
237"""
238
239 self._test_correct_image('systemd-machine-units', systemd_machine_unit_append)
240
213class OverlayFSEtcRunTimeTests(OESelftestTestCase): 241class OverlayFSEtcRunTimeTests(OESelftestTestCase):
214 """overlayfs-etc class tests""" 242 """overlayfs-etc class tests"""
215 243