summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/selftest/cases/package.py
diff options
context:
space:
mode:
Diffstat (limited to 'meta/lib/oeqa/selftest/cases/package.py')
-rw-r--r--meta/lib/oeqa/selftest/cases/package.py46
1 files changed, 28 insertions, 18 deletions
diff --git a/meta/lib/oeqa/selftest/cases/package.py b/meta/lib/oeqa/selftest/cases/package.py
index 7166c3991f..1aa6c03f8a 100644
--- a/meta/lib/oeqa/selftest/cases/package.py
+++ b/meta/lib/oeqa/selftest/cases/package.py
@@ -1,10 +1,11 @@
1# 1#
2# Copyright OpenEmbedded Contributors
3#
2# SPDX-License-Identifier: MIT 4# SPDX-License-Identifier: MIT
3# 5#
4 6
5from oeqa.selftest.case import OESelftestTestCase 7from oeqa.selftest.case import OESelftestTestCase
6from oeqa.utils.commands import bitbake, get_bb_vars, get_bb_var, runqemu 8from oeqa.utils.commands import bitbake, get_bb_vars, get_bb_var, runqemu
7import stat
8import subprocess, os 9import subprocess, os
9import oe.path 10import oe.path
10import re 11import re
@@ -88,6 +89,13 @@ class VersionOrdering(OESelftestTestCase):
88 self.assertEqual(status - 100, sort, "%s %s (%d) failed" % (ver1, ver2, sort)) 89 self.assertEqual(status - 100, sort, "%s %s (%d) failed" % (ver1, ver2, sort))
89 90
90class PackageTests(OESelftestTestCase): 91class PackageTests(OESelftestTestCase):
92 # Verify that a recipe cannot rename a package into an existing one
93 def test_package_name_conflict(self):
94 res = bitbake("packagenameconflict", ignore_status=True)
95 self.assertNotEqual(res.status, 0)
96 err = "package name already exists"
97 self.assertTrue(err in res.output)
98
91 # Verify that a recipe which sets up hardlink files has those preserved into split packages 99 # Verify that a recipe which sets up hardlink files has those preserved into split packages
92 # Also test file sparseness is preserved 100 # Also test file sparseness is preserved
93 def test_preserve_sparse_hardlinks(self): 101 def test_preserve_sparse_hardlinks(self):
@@ -116,9 +124,9 @@ class PackageTests(OESelftestTestCase):
116 124
117 # Verify gdb to read symbols from separated debug hardlink file correctly 125 # Verify gdb to read symbols from separated debug hardlink file correctly
118 def test_gdb_hardlink_debug(self): 126 def test_gdb_hardlink_debug(self):
119 features = 'IMAGE_INSTALL_append = " selftest-hardlink"\n' 127 features = 'IMAGE_INSTALL:append = " selftest-hardlink"\n'
120 features += 'IMAGE_INSTALL_append = " selftest-hardlink-dbg"\n' 128 features += 'IMAGE_INSTALL:append = " selftest-hardlink-dbg"\n'
121 features += 'IMAGE_INSTALL_append = " selftest-hardlink-gdb"\n' 129 features += 'IMAGE_INSTALL:append = " selftest-hardlink-gdb"\n'
122 self.write_config(features) 130 self.write_config(features)
123 bitbake("core-image-minimal") 131 bitbake("core-image-minimal")
124 132
@@ -134,8 +142,10 @@ class PackageTests(OESelftestTestCase):
134 self.logger.error("No debugging symbols found. GDB result:\n%s" % output) 142 self.logger.error("No debugging symbols found. GDB result:\n%s" % output)
135 return False 143 return False
136 144
137 # Check debugging symbols works correctly 145 # Check debugging symbols works correctly. Don't look for a
138 elif re.match(r"Breakpoint 1.*hello\.c.*4", l): 146 # source file as optimisation can put the breakpoint inside
147 # stdio.h.
148 elif "Breakpoint 1 at" in l:
139 return True 149 return True
140 150
141 self.logger.error("GDB result:\n%d: %s", status, output) 151 self.logger.error("GDB result:\n%d: %s", status, output)
@@ -150,25 +160,25 @@ class PackageTests(OESelftestTestCase):
150 self.fail('GDB %s failed' % binary) 160 self.fail('GDB %s failed' % binary)
151 161
152 def test_preserve_ownership(self): 162 def test_preserve_ownership(self):
153 import os, stat, oe.cachedpath 163 features = 'IMAGE_INSTALL:append = " selftest-chown"\n'
154 features = 'IMAGE_INSTALL_append = " selftest-chown"\n'
155 self.write_config(features) 164 self.write_config(features)
156 bitbake("core-image-minimal") 165 bitbake("core-image-minimal")
157 166
158 sysconfdir = get_bb_var('sysconfdir', 'selftest-chown') 167 def check_ownership(qemu, expected_gid, expected_uid, path):
159 def check_ownership(qemu, gid, uid, path):
160 self.logger.info("Check ownership of %s", path) 168 self.logger.info("Check ownership of %s", path)
161 status, output = qemu.run_serial(r'/bin/stat -c "%U %G" ' + path, timeout=60) 169 status, output = qemu.run_serial('stat -c "%U %G" ' + path)
162 output = output.split(" ") 170 self.assertEqual(status, 1, "stat failed: " + output)
163 if output[0] != uid or output[1] != gid : 171 try:
164 self.logger.error("Incrrect ownership %s [%s:%s]", path, output[0], output[1]) 172 uid, gid = output.split()
165 return False 173 self.assertEqual(uid, expected_uid)
166 return True 174 self.assertEqual(gid, expected_gid)
175 except ValueError:
176 self.fail("Cannot parse output: " + output)
167 177
178 sysconfdir = get_bb_var('sysconfdir', 'selftest-chown')
168 with runqemu('core-image-minimal') as qemu: 179 with runqemu('core-image-minimal') as qemu:
169 for path in [ sysconfdir + "/selftest-chown/file", 180 for path in [ sysconfdir + "/selftest-chown/file",
170 sysconfdir + "/selftest-chown/dir", 181 sysconfdir + "/selftest-chown/dir",
171 sysconfdir + "/selftest-chown/symlink", 182 sysconfdir + "/selftest-chown/symlink",
172 sysconfdir + "/selftest-chown/fifotest/fifo"]: 183 sysconfdir + "/selftest-chown/fifotest/fifo"]:
173 if not check_ownership(qemu, "test", "test", path): 184 check_ownership(qemu, "test", "test", path)
174 self.fail('Test ownership %s failed' % path)