summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Roos <throos@amazon.de>2023-05-17 14:13:53 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2023-05-22 10:53:49 +0100
commit6c8fe83bb5d1aaa11307253e8ab33c2d7f1a4a3f (patch)
tree1068ac4bf68dc2f7c3105c34c380780bc6fd7c4b
parenta0998bf22b5f13ef68c9282e41f18a35b79cc067 (diff)
downloadpoky-6c8fe83bb5d1aaa11307253e8ab33c2d7f1a4a3f.tar.gz
oeqa: adding selftest-hello and use it to speed up tests
Adding a selftest version of hello world to run it in tests where no download is necessary. Also using this in several tests to speed them up. Using the -native version wherever possible will also speed up tests a lot. [YOCTO #11142] (From OE-Core rev: c3f26b63934888df0e3cd563c1c2804eb78a368e) Signed-off-by: Thomas Roos <throos@amazon.de> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta-selftest/recipes-test/selftest-hello/files/helloworld.c8
-rw-r--r--meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb19
-rw-r--r--meta/lib/oeqa/selftest/cases/bbtests.py18
3 files changed, 36 insertions, 9 deletions
diff --git a/meta-selftest/recipes-test/selftest-hello/files/helloworld.c b/meta-selftest/recipes-test/selftest-hello/files/helloworld.c
new file mode 100644
index 0000000000..fc7169b7b8
--- /dev/null
+++ b/meta-selftest/recipes-test/selftest-hello/files/helloworld.c
@@ -0,0 +1,8 @@
1#include <stdio.h>
2
3int main(void)
4{
5 printf("Hello world!\n");
6
7 return 0;
8}
diff --git a/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb b/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb
new file mode 100644
index 0000000000..547587bef4
--- /dev/null
+++ b/meta-selftest/recipes-test/selftest-hello/selftest-hello_1.0.bb
@@ -0,0 +1,19 @@
1DESCRIPTION = "Simple helloworld application -- selftest variant"
2SECTION = "examples"
3LICENSE = "MIT"
4LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
5
6SRC_URI = "file://helloworld.c"
7
8S = "${WORKDIR}"
9
10do_compile() {
11 ${CC} ${CFLAGS} ${LDFLAGS} helloworld.c -o helloworld
12}
13
14do_install() {
15 install -d ${D}${bindir}
16 install -m 0755 helloworld ${D}${bindir}
17}
18
19BBCLASSEXTEND = "native nativesdk" \ No newline at end of file
diff --git a/meta/lib/oeqa/selftest/cases/bbtests.py b/meta/lib/oeqa/selftest/cases/bbtests.py
index d97bda13c2..1dd2839c8d 100644
--- a/meta/lib/oeqa/selftest/cases/bbtests.py
+++ b/meta/lib/oeqa/selftest/cases/bbtests.py
@@ -41,7 +41,7 @@ class BitbakeTests(OESelftestTestCase):
41 41
42 def test_event_handler(self): 42 def test_event_handler(self):
43 self.write_config("INHERIT += \"test_events\"") 43 self.write_config("INHERIT += \"test_events\"")
44 result = bitbake('m4-native') 44 result = bitbake('selftest-hello-native')
45 find_build_started = re.search(r"NOTE: Test for bb\.event\.BuildStarted(\n.*)*NOTE: Executing.*Tasks", result.output) 45 find_build_started = re.search(r"NOTE: Test for bb\.event\.BuildStarted(\n.*)*NOTE: Executing.*Tasks", result.output)
46 find_build_completed = re.search(r"Tasks Summary:.*(\n.*)*NOTE: Test for bb\.event\.BuildCompleted", result.output) 46 find_build_completed = re.search(r"Tasks Summary:.*(\n.*)*NOTE: Test for bb\.event\.BuildCompleted", result.output)
47 self.assertTrue(find_build_started, msg = "Match failed in:\n%s" % result.output) 47 self.assertTrue(find_build_started, msg = "Match failed in:\n%s" % result.output)
@@ -49,11 +49,11 @@ class BitbakeTests(OESelftestTestCase):
49 self.assertNotIn('Test for bb.event.InvalidEvent', result.output) 49 self.assertNotIn('Test for bb.event.InvalidEvent', result.output)
50 50
51 def test_local_sstate(self): 51 def test_local_sstate(self):
52 bitbake('m4-native') 52 bitbake('selftest-hello-native')
53 bitbake('m4-native -cclean') 53 bitbake('selftest-hello-native -cclean')
54 result = bitbake('m4-native') 54 result = bitbake('selftest-hello-native')
55 find_setscene = re.search("m4-native.*do_.*_setscene", result.output) 55 find_setscene = re.search("selftest-hello-native.*do_.*_setscene", result.output)
56 self.assertTrue(find_setscene, msg = "No \"m4-native.*do_.*_setscene\" message found during bitbake m4-native. bitbake output: %s" % result.output ) 56 self.assertTrue(find_setscene, msg = "No \"selftest-hello-native.*do_.*_setscene\" message found during bitbake selftest-hello-native. bitbake output: %s" % result.output )
57 57
58 def test_bitbake_invalid_recipe(self): 58 def test_bitbake_invalid_recipe(self):
59 result = bitbake('-b asdf', ignore_status=True) 59 result = bitbake('-b asdf', ignore_status=True)
@@ -175,7 +175,7 @@ SSTATE_DIR = \"${TOPDIR}/download-selftest\"
175 self.assertIn('localconf', result.output) 175 self.assertIn('localconf', result.output)
176 176
177 def test_dry_run(self): 177 def test_dry_run(self):
178 result = runCmd('bitbake -n m4-native') 178 result = runCmd('bitbake -n selftest-hello-native')
179 self.assertEqual(0, result.status, "bitbake dry run didn't run as expected. %s" % result.output) 179 self.assertEqual(0, result.status, "bitbake dry run didn't run as expected. %s" % result.output)
180 180
181 def test_just_parse(self): 181 def test_just_parse(self):
@@ -233,7 +233,7 @@ INHERIT:remove = \"report-error\"
233 233
234 def test_setscene_only(self): 234 def test_setscene_only(self):
235 """ Bitbake option to restore from sstate only within a build (i.e. execute no real tasks, only setscene)""" 235 """ Bitbake option to restore from sstate only within a build (i.e. execute no real tasks, only setscene)"""
236 test_recipe = 'ed' 236 test_recipe = 'selftest-hello-native'
237 237
238 bitbake(test_recipe) 238 bitbake(test_recipe)
239 bitbake('-c clean %s' % test_recipe) 239 bitbake('-c clean %s' % test_recipe)
@@ -246,7 +246,7 @@ INHERIT:remove = \"report-error\"
246 'Executed tasks were: %s' % (task, str(tasks))) 246 'Executed tasks were: %s' % (task, str(tasks)))
247 247
248 def test_skip_setscene(self): 248 def test_skip_setscene(self):
249 test_recipe = 'ed' 249 test_recipe = 'selftest-hello-native'
250 250
251 bitbake(test_recipe) 251 bitbake(test_recipe)
252 bitbake('-c clean %s' % test_recipe) 252 bitbake('-c clean %s' % test_recipe)