summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2021-09-10 12:39:44 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2021-09-23 22:13:53 +0100
commitd08c9290e82fb26d958991592ef801d07393f69d (patch)
tree4caf4522e5c4247188c8513b8c8b2c379110671b
parent7d0437c4e8063362d9ca127dbd439208fe6ebda4 (diff)
downloadpoky-d08c9290e82fb26d958991592ef801d07393f69d.tar.gz
oeqa/selftest: Add tests for bitbake shell/python task output
We've seen issues where shell/python tasks lose their log file entries or output and also where output is duplicated. Add some tests to attempt to spot regressions in this area in future. (From OE-Core rev: 414020a9bd656ee61efe2f47db1b31d86b15c1c8) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta-selftest/recipes-test/logging-test/logging-test.bb24
-rw-r--r--meta/lib/oeqa/selftest/cases/bblogging.py104
2 files changed, 128 insertions, 0 deletions
diff --git a/meta-selftest/recipes-test/logging-test/logging-test.bb b/meta-selftest/recipes-test/logging-test/logging-test.bb
new file mode 100644
index 0000000000..a6100123f9
--- /dev/null
+++ b/meta-selftest/recipes-test/logging-test/logging-test.bb
@@ -0,0 +1,24 @@
1SUMMARY = "Destined to fail"
2LICENSE = "CLOSED"
3
4deltask do_patch
5INHIBIT_DEFAULT_DEPS = "1"
6
7do_shelltest() {
8 echo "This is shell stdout"
9 echo "This is shell stderr" >&2
10 exit 1
11}
12addtask do_shelltest
13
14python do_pythontest_exit () {
15 print("This is python stdout")
16 sys.exit(1)
17}
18addtask do_pythontest_exit
19
20python do_pythontest_fatal () {
21 print("This is python fatal test stdout")
22 bb.fatal("This is a fatal error")
23}
24addtask do_pythontest_fatal
diff --git a/meta/lib/oeqa/selftest/cases/bblogging.py b/meta/lib/oeqa/selftest/cases/bblogging.py
new file mode 100644
index 0000000000..ea6c3c8c77
--- /dev/null
+++ b/meta/lib/oeqa/selftest/cases/bblogging.py
@@ -0,0 +1,104 @@
1#
2# SPDX-License-Identifier: MIT
3#
4
5
6from oeqa.selftest.case import OESelftestTestCase
7from oeqa.utils.commands import bitbake
8
9class BitBakeLogging(OESelftestTestCase):
10
11 def assertCount(self, item, entry, count):
12 self.assertEqual(item.count(entry), count, msg="Output:\n'''\n%s\n'''\ndoesn't contain %d copies of:\n'''\n%s\n'''\n" % (item, count, entry))
13
14 def test_shell_logging(self):
15 # no logs, no verbose
16 self.write_config('BBINCLUDELOGS = ""')
17 result = bitbake("logging-test -c shelltest -f", ignore_status = True)
18 self.assertIn("ERROR: Logfile of failure stored in:", result.output)
19 self.assertNotIn("This is shell stdout", result.output)
20 self.assertNotIn("This is shell stderr", result.output)
21
22 # logs, no verbose
23 self.write_config('BBINCLUDELOGS = "yes"')
24 result = bitbake("logging-test -c shelltest -f", ignore_status = True)
25 self.assertIn("ERROR: Logfile of failure stored in:", result.output)
26 self.assertCount(result.output, "This is shell stdout", 1)
27 self.assertCount(result.output, "This is shell stderr", 1)
28
29 # no logs, verbose
30 self.write_config('BBINCLUDELOGS = ""')
31 result = bitbake("logging-test -c shelltest -f -v", ignore_status = True)
32 self.assertIn("ERROR: Logfile of failure stored in:", result.output)
33 # two copies due to set +x
34 self.assertCount(result.output, "This is shell stdout", 2)
35 self.assertCount(result.output, "This is shell stderr", 2)
36
37 # logs, verbose
38 self.write_config('BBINCLUDELOGS = "yes"')
39 result = bitbake("logging-test -c shelltest -f -v", ignore_status = True)
40 self.assertIn("ERROR: Logfile of failure stored in:", result.output)
41 # two copies due to set +x
42 self.assertCount(result.output, "This is shell stdout", 2)
43 self.assertCount(result.output, "This is shell stderr", 2)
44
45 def test_python_exit_logging(self):
46 # no logs, no verbose
47 self.write_config('BBINCLUDELOGS = ""')
48 result = bitbake("logging-test -c pythontest_exit -f", ignore_status = True)
49 self.assertIn("ERROR: Logfile of failure stored in:", result.output)
50 self.assertNotIn("This is python stdout", result.output)
51
52 # logs, no verbose
53 self.write_config('BBINCLUDELOGS = "yes"')
54 result = bitbake("logging-test -c pythontest_exit -f", ignore_status = True)
55 self.assertIn("ERROR: Logfile of failure stored in:", result.output)
56 # A sys.exit() should include the output
57 self.assertCount(result.output, "This is python stdout", 1)
58
59 # no logs, verbose
60 self.write_config('BBINCLUDELOGS = ""')
61 result = bitbake("logging-test -c pythontest_exit -f -v", ignore_status = True)
62 self.assertIn("ERROR: Logfile of failure stored in:", result.output)
63 # python tasks don't log output with -v currently
64 #self.assertCount(result.output, "This is python stdout", 1)
65
66 # logs, verbose
67 self.write_config('BBINCLUDELOGS = "yes"')
68 result = bitbake("logging-test -c pythontest_exit -f -v", ignore_status = True)
69 self.assertIn("ERROR: Logfile of failure stored in:", result.output)
70 # python tasks don't log output with -v currently
71 #self.assertCount(result.output, "This is python stdout", 1)
72
73 def test_python_fatal_logging(self):
74 # no logs, no verbose
75 self.write_config('BBINCLUDELOGS = ""')
76 result = bitbake("logging-test -c pythontest_fatal -f", ignore_status = True)
77 self.assertIn("ERROR: Logfile of failure stored in:", result.output)
78 self.assertNotIn("This is python fatal test stdout", result.output)
79 self.assertCount(result.output, "This is a fatal error", 1)
80
81 # logs, no verbose
82 self.write_config('BBINCLUDELOGS = "yes"')
83 result = bitbake("logging-test -c pythontest_fatal -f", ignore_status = True)
84 self.assertIn("ERROR: Logfile of failure stored in:", result.output)
85 # A bb.fatal() should not include the output
86 self.assertNotIn("This is python fatal test stdout", result.output)
87 self.assertCount(result.output, "This is a fatal error", 1)
88
89 # no logs, verbose
90 self.write_config('BBINCLUDELOGS = ""')
91 result = bitbake("logging-test -c pythontest_fatal -f -v", ignore_status = True)
92 self.assertIn("ERROR: Logfile of failure stored in:", result.output)
93 # python tasks don't log output with -v currently
94 #self.assertCount(result.output, "This is python fatal test stdout", 1)
95 self.assertCount(result.output, "This is a fatal error", 1)
96
97 # logs, verbose
98 self.write_config('BBINCLUDELOGS = "yes"')
99 result = bitbake("logging-test -c pythontest_fatal -f -v", ignore_status = True)
100 self.assertIn("ERROR: Logfile of failure stored in:", result.output)
101 # python tasks don't log output with -v currently
102 #self.assertCount(result.output, "This is python fatal test stdout", 1)
103 self.assertCount(result.output, "This is a fatal error", 1)
104