blob: 1534a36a85b080036583d192bd6f8f11cad73858 [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)
108 # python tasks don't log output with -v currently
109 #self.assertCount(result.output, "This is python stdout", 1)
110
Andrew Geissler7e0e3c02022-02-25 20:34:39 +0000111 def test_python_exit_loggingD(self):
Andrew Geissler5199d832021-09-24 16:47:35 -0500112 # logs, verbose
113 self.write_config('BBINCLUDELOGS = "yes"')
114 result = bitbake("logging-test -c pythontest_exit -f -v", ignore_status = True)
115 self.assertIn("ERROR: Logfile of failure stored in:", result.output)
116 # python tasks don't log output with -v currently
117 #self.assertCount(result.output, "This is python stdout", 1)
118
Andrew Geissler7e0e3c02022-02-25 20:34:39 +0000119 def test_python_exec_func_python_loggingA(self):
120 # no logs, no verbose
121 self.write_config('BBINCLUDELOGS = ""')
122 result = bitbake("logging-test -c pythontest_exec_func_python -f",
123 ignore_status = True)
124 self.assertIn("ERROR: Logfile of failure stored in:", result.output)
125 self.assertNotIn("This is python stdout", result.output)
126
127 def test_python_exec_func_python_loggingB(self):
128 # logs, no verbose
129 self.write_config('BBINCLUDELOGS = "yes"')
130 result = bitbake("logging-test -c pythontest_exec_func_python -f",
131 ignore_status = True)
132 self.assertIn("ERROR: Logfile of failure stored in:", result.output)
133 # A sys.exit() should include the output
134 self.assertCount(result.output, "This is python stdout", 1)
135
136 def test_python_exec_func_python_loggingC(self):
137 # no logs, verbose
138 self.write_config('BBINCLUDELOGS = ""')
139 result = bitbake("logging-test -c pythontest_exec_func_python -f -v",
140 ignore_status = True)
141 self.assertIn("ERROR: Logfile of failure stored in:", result.output)
142 # python tasks don't log output with -v currently
143 #self.assertCount(result.output, "This is python stdout", 1)
144
145 def test_python_exec_func_python_loggingD(self):
146 # logs, verbose
147 self.write_config('BBINCLUDELOGS = "yes"')
148 result = bitbake("logging-test -c pythontest_exec_func_python -f -v",
149 ignore_status = True)
150 self.assertIn("ERROR: Logfile of failure stored in:", result.output)
151 # python tasks don't log output with -v currently
152 #self.assertCount(result.output, "This is python stdout", 1)
153
154 def test_python_fatal_loggingA(self):
Andrew Geissler5199d832021-09-24 16:47:35 -0500155 # no logs, no verbose
156 self.write_config('BBINCLUDELOGS = ""')
157 result = bitbake("logging-test -c pythontest_fatal -f", ignore_status = True)
158 self.assertIn("ERROR: Logfile of failure stored in:", result.output)
159 self.assertNotIn("This is python fatal test stdout", result.output)
160 self.assertCount(result.output, "This is a fatal error", 1)
161
Andrew Geissler7e0e3c02022-02-25 20:34:39 +0000162 def test_python_fatal_loggingB(self):
Andrew Geissler5199d832021-09-24 16:47:35 -0500163 # logs, no verbose
164 self.write_config('BBINCLUDELOGS = "yes"')
165 result = bitbake("logging-test -c pythontest_fatal -f", ignore_status = True)
166 self.assertIn("ERROR: Logfile of failure stored in:", result.output)
167 # A bb.fatal() should not include the output
168 self.assertNotIn("This is python fatal test stdout", result.output)
169 self.assertCount(result.output, "This is a fatal error", 1)
170
Andrew Geissler7e0e3c02022-02-25 20:34:39 +0000171 def test_python_fatal_loggingC(self):
Andrew Geissler5199d832021-09-24 16:47:35 -0500172 # no logs, verbose
173 self.write_config('BBINCLUDELOGS = ""')
174 result = bitbake("logging-test -c pythontest_fatal -f -v", ignore_status = True)
175 self.assertIn("ERROR: Logfile of failure stored in:", result.output)
176 # python tasks don't log output with -v currently
177 #self.assertCount(result.output, "This is python fatal test stdout", 1)
178 self.assertCount(result.output, "This is a fatal error", 1)
179
Andrew Geissler7e0e3c02022-02-25 20:34:39 +0000180 def test_python_fatal_loggingD(self):
Andrew Geissler5199d832021-09-24 16:47:35 -0500181 # logs, verbose
182 self.write_config('BBINCLUDELOGS = "yes"')
183 result = bitbake("logging-test -c pythontest_fatal -f -v", ignore_status = True)
184 self.assertIn("ERROR: Logfile of failure stored in:", result.output)
185 # python tasks don't log output with -v currently
186 #self.assertCount(result.output, "This is python fatal test stdout", 1)
187 self.assertCount(result.output, "This is a fatal error", 1)
188