blob: 040c6db089d225957981d8ac13aed2f844967320 [file] [log] [blame]
Andrew Geissler5199d832021-09-24 16:47:35 -05001#
Patrick Williams92b42cb2022-09-03 06:53:57 -05002# Copyright OpenEmbedded Contributors
3#
Andrew Geissler5199d832021-09-24 16:47:35 -05004# SPDX-License-Identifier: MIT
5#
6
7
8from oeqa.selftest.case import OESelftestTestCase
9from oeqa.utils.commands import bitbake
10
11class BitBakeLogging(OESelftestTestCase):
12
13 def assertCount(self, item, entry, count):
14 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))
15
Andrew Geissler7e0e3c02022-02-25 20:34:39 +000016 def test_shell_loggingA(self):
Andrew Geissler5199d832021-09-24 16:47:35 -050017 # no logs, no verbose
18 self.write_config('BBINCLUDELOGS = ""')
19 result = bitbake("logging-test -c shelltest -f", ignore_status = True)
20 self.assertIn("ERROR: Logfile of failure stored in:", result.output)
21 self.assertNotIn("This is shell stdout", result.output)
22 self.assertNotIn("This is shell stderr", result.output)
23
Andrew Geissler7e0e3c02022-02-25 20:34:39 +000024 def test_shell_loggingB(self):
Andrew Geissler5199d832021-09-24 16:47:35 -050025 # logs, no verbose
26 self.write_config('BBINCLUDELOGS = "yes"')
27 result = bitbake("logging-test -c shelltest -f", ignore_status = True)
28 self.assertIn("ERROR: Logfile of failure stored in:", result.output)
29 self.assertCount(result.output, "This is shell stdout", 1)
30 self.assertCount(result.output, "This is shell stderr", 1)
31
Andrew Geissler7e0e3c02022-02-25 20:34:39 +000032 def test_shell_loggingC(self):
Andrew Geissler5199d832021-09-24 16:47:35 -050033 # no logs, verbose
34 self.write_config('BBINCLUDELOGS = ""')
35 result = bitbake("logging-test -c shelltest -f -v", ignore_status = True)
36 self.assertIn("ERROR: Logfile of failure stored in:", result.output)
Andrew Geissler7e0e3c02022-02-25 20:34:39 +000037 # two copies due to set +x
Andrew Geissler5199d832021-09-24 16:47:35 -050038 self.assertCount(result.output, "This is shell stdout", 2)
39 self.assertCount(result.output, "This is shell stderr", 2)
40
Andrew Geissler7e0e3c02022-02-25 20:34:39 +000041 def test_shell_loggingD(self):
Andrew Geissler5199d832021-09-24 16:47:35 -050042 # logs, verbose
43 self.write_config('BBINCLUDELOGS = "yes"')
44 result = bitbake("logging-test -c shelltest -f -v", ignore_status = True)
45 self.assertIn("ERROR: Logfile of failure stored in:", result.output)
46 # two copies due to set +x
47 self.assertCount(result.output, "This is shell stdout", 2)
48 self.assertCount(result.output, "This is shell stderr", 2)
49
Andrew Geissler7e0e3c02022-02-25 20:34:39 +000050 def test_python_exec_func_shell_loggingA(self):
51 # no logs, no verbose
52 self.write_config('BBINCLUDELOGS = ""')
53 result = bitbake("logging-test -c pythontest_exec_func_shell -f",
54 ignore_status = True)
55 self.assertIn("ERROR: Logfile of failure stored in:", result.output)
56 self.assertNotIn("This is shell stdout", result.output)
57 self.assertNotIn("This is shell stderr", result.output)
58
59 def test_python_exec_func_shell_loggingB(self):
60 # logs, no verbose
61 self.write_config('BBINCLUDELOGS = "yes"')
62 result = bitbake("logging-test -c pythontest_exec_func_shell -f",
63 ignore_status = True)
64 self.assertIn("ERROR: Logfile of failure stored in:", result.output)
65 self.assertCount(result.output, "This is shell stdout", 1)
66 self.assertCount(result.output, "This is shell stderr", 1)
67
68 def test_python_exec_func_shell_loggingC(self):
69 # no logs, verbose
70 self.write_config('BBINCLUDELOGS = ""')
71 result = bitbake("logging-test -c pythontest_exec_func_shell -f -v",
72 ignore_status = True)
73 self.assertIn("ERROR: Logfile of failure stored in:", result.output)
74 # two copies due to set +x
75 self.assertCount(result.output, "This is shell stdout", 2)
76 self.assertCount(result.output, "This is shell stderr", 2)
77
78 def test_python_exec_func_shell_loggingD(self):
79 # logs, verbose
80 self.write_config('BBINCLUDELOGS = "yes"')
81 result = bitbake("logging-test -c pythontest_exec_func_shell -f -v",
82 ignore_status = True)
83 self.assertIn("ERROR: Logfile of failure stored in:", result.output)
84 # two copies due to set +x
85 self.assertCount(result.output, "This is shell stdout", 2)
86 self.assertCount(result.output, "This is shell stderr", 2)
87
88 def test_python_exit_loggingA(self):
Andrew Geissler5199d832021-09-24 16:47:35 -050089 # no logs, no verbose
90 self.write_config('BBINCLUDELOGS = ""')
91 result = bitbake("logging-test -c pythontest_exit -f", ignore_status = True)
92 self.assertIn("ERROR: Logfile of failure stored in:", result.output)
93 self.assertNotIn("This is python stdout", result.output)
94
Andrew Geissler7e0e3c02022-02-25 20:34:39 +000095 def test_python_exit_loggingB(self):
Andrew Geissler5199d832021-09-24 16:47:35 -050096 # logs, no verbose
97 self.write_config('BBINCLUDELOGS = "yes"')
98 result = bitbake("logging-test -c pythontest_exit -f", ignore_status = True)
99 self.assertIn("ERROR: Logfile of failure stored in:", result.output)
100 # A sys.exit() should include the output
101 self.assertCount(result.output, "This is python stdout", 1)
102
Andrew Geissler7e0e3c02022-02-25 20:34:39 +0000103 def test_python_exit_loggingC(self):
Andrew Geissler5199d832021-09-24 16:47:35 -0500104 # no logs, verbose
105 self.write_config('BBINCLUDELOGS = ""')
106 result = bitbake("logging-test -c pythontest_exit -f -v", ignore_status = True)
107 self.assertIn("ERROR: Logfile of failure stored in:", result.output)
Patrick Williams8e7b46e2023-05-01 14:19:06 -0500108 self.assertCount(result.output, "This is python stdout", 1)
Andrew Geissler5199d832021-09-24 16:47:35 -0500109
Andrew Geissler7e0e3c02022-02-25 20:34:39 +0000110 def test_python_exit_loggingD(self):
Andrew Geissler5199d832021-09-24 16:47:35 -0500111 # logs, verbose
112 self.write_config('BBINCLUDELOGS = "yes"')
113 result = bitbake("logging-test -c pythontest_exit -f -v", ignore_status = True)
114 self.assertIn("ERROR: Logfile of failure stored in:", result.output)
Patrick Williams8e7b46e2023-05-01 14:19:06 -0500115 self.assertCount(result.output, "This is python stdout", 1)
Andrew Geissler5199d832021-09-24 16:47:35 -0500116
Andrew Geissler7e0e3c02022-02-25 20:34:39 +0000117 def test_python_exec_func_python_loggingA(self):
118 # no logs, no verbose
119 self.write_config('BBINCLUDELOGS = ""')
120 result = bitbake("logging-test -c pythontest_exec_func_python -f",
121 ignore_status = True)
122 self.assertIn("ERROR: Logfile of failure stored in:", result.output)
123 self.assertNotIn("This is python stdout", result.output)
124
125 def test_python_exec_func_python_loggingB(self):
126 # logs, no verbose
127 self.write_config('BBINCLUDELOGS = "yes"')
128 result = bitbake("logging-test -c pythontest_exec_func_python -f",
129 ignore_status = True)
130 self.assertIn("ERROR: Logfile of failure stored in:", result.output)
131 # A sys.exit() should include the output
132 self.assertCount(result.output, "This is python stdout", 1)
133
134 def test_python_exec_func_python_loggingC(self):
135 # no logs, verbose
136 self.write_config('BBINCLUDELOGS = ""')
137 result = bitbake("logging-test -c pythontest_exec_func_python -f -v",
138 ignore_status = True)
139 self.assertIn("ERROR: Logfile of failure stored in:", result.output)
Patrick Williams8e7b46e2023-05-01 14:19:06 -0500140 self.assertCount(result.output, "This is python stdout", 1)
Andrew Geissler7e0e3c02022-02-25 20:34:39 +0000141
142 def test_python_exec_func_python_loggingD(self):
143 # logs, verbose
144 self.write_config('BBINCLUDELOGS = "yes"')
145 result = bitbake("logging-test -c pythontest_exec_func_python -f -v",
146 ignore_status = True)
147 self.assertIn("ERROR: Logfile of failure stored in:", result.output)
Patrick Williams8e7b46e2023-05-01 14:19:06 -0500148 self.assertCount(result.output, "This is python stdout", 1)
Andrew Geissler7e0e3c02022-02-25 20:34:39 +0000149
150 def test_python_fatal_loggingA(self):
Andrew Geissler5199d832021-09-24 16:47:35 -0500151 # no logs, no verbose
152 self.write_config('BBINCLUDELOGS = ""')
153 result = bitbake("logging-test -c pythontest_fatal -f", ignore_status = True)
154 self.assertIn("ERROR: Logfile of failure stored in:", result.output)
155 self.assertNotIn("This is python fatal test stdout", result.output)
156 self.assertCount(result.output, "This is a fatal error", 1)
157
Andrew Geissler7e0e3c02022-02-25 20:34:39 +0000158 def test_python_fatal_loggingB(self):
Andrew Geissler5199d832021-09-24 16:47:35 -0500159 # logs, no verbose
160 self.write_config('BBINCLUDELOGS = "yes"')
161 result = bitbake("logging-test -c pythontest_fatal -f", ignore_status = True)
162 self.assertIn("ERROR: Logfile of failure stored in:", result.output)
163 # A bb.fatal() should not include the output
164 self.assertNotIn("This is python fatal test stdout", result.output)
165 self.assertCount(result.output, "This is a fatal error", 1)
166
Andrew Geissler7e0e3c02022-02-25 20:34:39 +0000167 def test_python_fatal_loggingC(self):
Andrew Geissler5199d832021-09-24 16:47:35 -0500168 # no logs, verbose
169 self.write_config('BBINCLUDELOGS = ""')
170 result = bitbake("logging-test -c pythontest_fatal -f -v", ignore_status = True)
171 self.assertIn("ERROR: Logfile of failure stored in:", result.output)
Patrick Williams8e7b46e2023-05-01 14:19:06 -0500172 self.assertCount(result.output, "This is python fatal test stdout", 1)
Andrew Geissler5199d832021-09-24 16:47:35 -0500173 self.assertCount(result.output, "This is a fatal error", 1)
174
Andrew Geissler7e0e3c02022-02-25 20:34:39 +0000175 def test_python_fatal_loggingD(self):
Andrew Geissler5199d832021-09-24 16:47:35 -0500176 # logs, verbose
177 self.write_config('BBINCLUDELOGS = "yes"')
178 result = bitbake("logging-test -c pythontest_fatal -f -v", ignore_status = True)
179 self.assertIn("ERROR: Logfile of failure stored in:", result.output)
Patrick Williams8e7b46e2023-05-01 14:19:06 -0500180 self.assertCount(result.output, "This is python fatal test stdout", 1)
Andrew Geissler5199d832021-09-24 16:47:35 -0500181 self.assertCount(result.output, "This is a fatal error", 1)
182