summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/selftest/cases/bblogging.py
blob: 1534a36a85b080036583d192bd6f8f11cad73858 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
#
# Copyright OpenEmbedded Contributors
#
# SPDX-License-Identifier: MIT
#


from oeqa.selftest.case import OESelftestTestCase
from oeqa.utils.commands import bitbake

class BitBakeLogging(OESelftestTestCase):

    def assertCount(self, item, entry, count):
        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))

    def test_shell_loggingA(self):
        # no logs, no verbose
        self.write_config('BBINCLUDELOGS = ""')
        result = bitbake("logging-test -c shelltest -f", ignore_status = True)
        self.assertIn("ERROR: Logfile of failure stored in:", result.output)
        self.assertNotIn("This is shell stdout", result.output)
        self.assertNotIn("This is shell stderr", result.output)

    def test_shell_loggingB(self):
        # logs, no verbose
        self.write_config('BBINCLUDELOGS = "yes"')
        result = bitbake("logging-test -c shelltest -f", ignore_status = True)
        self.assertIn("ERROR: Logfile of failure stored in:", result.output)
        self.assertCount(result.output, "This is shell stdout", 1)
        self.assertCount(result.output, "This is shell stderr", 1)

    def test_shell_loggingC(self):
        # no logs, verbose
        self.write_config('BBINCLUDELOGS = ""')
        result = bitbake("logging-test -c shelltest -f -v", ignore_status = True)
        self.assertIn("ERROR: Logfile of failure stored in:", result.output)
        # two copies due to set +x
        self.assertCount(result.output, "This is shell stdout", 2)
        self.assertCount(result.output, "This is shell stderr", 2)

    def test_shell_loggingD(self):
        # logs, verbose
        self.write_config('BBINCLUDELOGS = "yes"')
        result = bitbake("logging-test -c shelltest -f -v", ignore_status = True)
        self.assertIn("ERROR: Logfile of failure stored in:", result.output)
        # two copies due to set +x
        self.assertCount(result.output, "This is shell stdout", 2)
        self.assertCount(result.output, "This is shell stderr", 2)

    def test_python_exec_func_shell_loggingA(self):
        # no logs, no verbose
        self.write_config('BBINCLUDELOGS = ""')
        result = bitbake("logging-test -c pythontest_exec_func_shell -f",
                         ignore_status = True)
        self.assertIn("ERROR: Logfile of failure stored in:", result.output)
        self.assertNotIn("This is shell stdout", result.output)
        self.assertNotIn("This is shell stderr", result.output)

    def test_python_exec_func_shell_loggingB(self):
        # logs, no verbose
        self.write_config('BBINCLUDELOGS = "yes"')
        result = bitbake("logging-test -c pythontest_exec_func_shell -f",
                         ignore_status = True)
        self.assertIn("ERROR: Logfile of failure stored in:", result.output)
        self.assertCount(result.output, "This is shell stdout", 1)
        self.assertCount(result.output, "This is shell stderr", 1)

    def test_python_exec_func_shell_loggingC(self):
        # no logs, verbose
        self.write_config('BBINCLUDELOGS = ""')
        result = bitbake("logging-test -c pythontest_exec_func_shell -f -v",
                         ignore_status = True)
        self.assertIn("ERROR: Logfile of failure stored in:", result.output)
        # two copies due to set +x
        self.assertCount(result.output, "This is shell stdout", 2)
        self.assertCount(result.output, "This is shell stderr", 2)

    def test_python_exec_func_shell_loggingD(self):
        # logs, verbose
        self.write_config('BBINCLUDELOGS = "yes"')
        result = bitbake("logging-test -c pythontest_exec_func_shell -f -v",
                         ignore_status = True)
        self.assertIn("ERROR: Logfile of failure stored in:", result.output)
        # two copies due to set +x
        self.assertCount(result.output, "This is shell stdout", 2)
        self.assertCount(result.output, "This is shell stderr", 2)

    def test_python_exit_loggingA(self):
        # no logs, no verbose
        self.write_config('BBINCLUDELOGS = ""')
        result = bitbake("logging-test -c pythontest_exit -f", ignore_status = True)
        self.assertIn("ERROR: Logfile of failure stored in:", result.output)
        self.assertNotIn("This is python stdout", result.output)

    def test_python_exit_loggingB(self):
        # logs, no verbose
        self.write_config('BBINCLUDELOGS = "yes"')
        result = bitbake("logging-test -c pythontest_exit -f", ignore_status = True)
        self.assertIn("ERROR: Logfile of failure stored in:", result.output)
        # A sys.exit() should include the output
        self.assertCount(result.output, "This is python stdout", 1)

    def test_python_exit_loggingC(self):
        # no logs, verbose
        self.write_config('BBINCLUDELOGS = ""')
        result = bitbake("logging-test -c pythontest_exit -f -v", ignore_status = True)
        self.assertIn("ERROR: Logfile of failure stored in:", result.output)
        # python tasks don't log output with -v currently
        #self.assertCount(result.output, "This is python stdout", 1)

    def test_python_exit_loggingD(self):
        # logs, verbose
        self.write_config('BBINCLUDELOGS = "yes"')
        result = bitbake("logging-test -c pythontest_exit -f -v", ignore_status = True)
        self.assertIn("ERROR: Logfile of failure stored in:", result.output)
        # python tasks don't log output with -v currently
        #self.assertCount(result.output, "This is python stdout", 1)

    def test_python_exec_func_python_loggingA(self):
        # no logs, no verbose
        self.write_config('BBINCLUDELOGS = ""')
        result = bitbake("logging-test -c pythontest_exec_func_python -f",
                         ignore_status = True)
        self.assertIn("ERROR: Logfile of failure stored in:", result.output)
        self.assertNotIn("This is python stdout", result.output)

    def test_python_exec_func_python_loggingB(self):
        # logs, no verbose
        self.write_config('BBINCLUDELOGS = "yes"')
        result = bitbake("logging-test -c pythontest_exec_func_python -f",
                         ignore_status = True)
        self.assertIn("ERROR: Logfile of failure stored in:", result.output)
        # A sys.exit() should include the output
        self.assertCount(result.output, "This is python stdout", 1)

    def test_python_exec_func_python_loggingC(self):
        # no logs, verbose
        self.write_config('BBINCLUDELOGS = ""')
        result = bitbake("logging-test -c pythontest_exec_func_python -f -v",
                         ignore_status = True)
        self.assertIn("ERROR: Logfile of failure stored in:", result.output)
        # python tasks don't log output with -v currently
        #self.assertCount(result.output, "This is python stdout", 1)

    def test_python_exec_func_python_loggingD(self):
        # logs, verbose
        self.write_config('BBINCLUDELOGS = "yes"')
        result = bitbake("logging-test -c pythontest_exec_func_python -f -v",
                         ignore_status = True)
        self.assertIn("ERROR: Logfile of failure stored in:", result.output)
        # python tasks don't log output with -v currently
        #self.assertCount(result.output, "This is python stdout", 1)

    def test_python_fatal_loggingA(self):
        # no logs, no verbose
        self.write_config('BBINCLUDELOGS = ""')
        result = bitbake("logging-test -c pythontest_fatal -f", ignore_status = True)
        self.assertIn("ERROR: Logfile of failure stored in:", result.output)
        self.assertNotIn("This is python fatal test stdout", result.output)
        self.assertCount(result.output, "This is a fatal error", 1)

    def test_python_fatal_loggingB(self):
        # logs, no verbose
        self.write_config('BBINCLUDELOGS = "yes"')
        result = bitbake("logging-test -c pythontest_fatal -f", ignore_status = True)
        self.assertIn("ERROR: Logfile of failure stored in:", result.output)
        # A bb.fatal() should not include the output
        self.assertNotIn("This is python fatal test stdout", result.output)
        self.assertCount(result.output, "This is a fatal error", 1)

    def test_python_fatal_loggingC(self):
        # no logs, verbose
        self.write_config('BBINCLUDELOGS = ""')
        result = bitbake("logging-test -c pythontest_fatal -f -v", ignore_status = True)
        self.assertIn("ERROR: Logfile of failure stored in:", result.output)
        # python tasks don't log output with -v currently
        #self.assertCount(result.output, "This is python fatal test stdout", 1)
        self.assertCount(result.output, "This is a fatal error", 1)

    def test_python_fatal_loggingD(self):
        # logs, verbose
        self.write_config('BBINCLUDELOGS = "yes"')
        result = bitbake("logging-test -c pythontest_fatal -f -v", ignore_status = True)
        self.assertIn("ERROR: Logfile of failure stored in:", result.output)
        # python tasks don't log output with -v currently
        #self.assertCount(result.output, "This is python fatal test stdout", 1)
        self.assertCount(result.output, "This is a fatal error", 1)