blob: cddb846bdfce687e06cef67ae54b07a3b8bbc739 [file] [log] [blame]
Brad Bishopc342db32019-05-15 21:57:59 -04001#
Patrick Williams92b42cb2022-09-03 06:53:57 -05002# Copyright OpenEmbedded Contributors
3#
Brad Bishopc342db32019-05-15 21:57:59 -04004# SPDX-License-Identifier: MIT
5#
6
Andrew Geissler220dafd2023-10-04 10:18:08 -05007import collections
Brad Bishop6e60e8b2018-02-01 10:27:11 -05008import os
9
Brad Bishop6e60e8b2018-02-01 10:27:11 -050010from shutil import rmtree
11from oeqa.runtime.case import OERuntimeTestCase
12from oeqa.core.decorator.depends import OETestDepends
Brad Bishop6e60e8b2018-02-01 10:27:11 -050013
14common_errors = [
15 "(WW) warning, (EE) error, (NI) not implemented, (??) unknown.",
16 "dma timeout",
17 "can\'t add hid device:",
18 "usbhid: probe of ",
19 "_OSC failed (AE_ERROR)",
20 "_OSC failed (AE_SUPPORT)",
21 "AE_ALREADY_EXISTS",
22 "ACPI _OSC request failed (AE_SUPPORT)",
23 "can\'t disable ASPM",
24 "Failed to load module \"vesa\"",
25 "Failed to load module vesa",
26 "Failed to load module \"modesetting\"",
27 "Failed to load module modesetting",
28 "Failed to load module \"glx\"",
29 "Failed to load module \"fbdev\"",
30 "Failed to load module fbdev",
31 "Failed to load module glx",
Andrew Geisslereff27472021-10-29 15:35:00 -050032 "[drm] Cannot find any crtc or sizes",
Brad Bishop6e60e8b2018-02-01 10:27:11 -050033 "_OSC failed (AE_NOT_FOUND); disabling ASPM",
34 "Open ACPI failed (/var/run/acpid.socket) (No such file or directory)",
35 "NX (Execute Disable) protection cannot be enabled: non-PAE kernel!",
36 "hd.: possibly failed opcode",
37 'NETLINK INITIALIZATION FAILED',
38 'kernel: Cannot find map file',
39 'omap_hwmod: debugss: _wait_target_disable failed',
40 'VGA arbiter: cannot open kernel arbiter, no multi-card support',
41 'Failed to find URL:http://ipv4.connman.net/online/status.html',
42 'Online check failed for',
43 'netlink init failed',
44 'Fast TSC calibration',
45 "BAR 0-9",
46 "Failed to load module \"ati\"",
47 "controller can't do DEVSLP, turning off",
48 "stmmac_dvr_probe: warning: cannot get CSR clock",
49 "error: couldn\'t mount because of unsupported optional features",
50 "GPT: Use GNU Parted to correct GPT errors",
51 "Cannot set xattr user.Librepo.DownloadInProgress",
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080052 "Failed to read /var/lib/nfs/statd/state: Success",
53 "error retry time-out =",
54 "logind: cannot setup systemd-logind helper (-61), using legacy fallback",
Andrew Geissler82c905d2020-04-13 13:39:40 -050055 "Failed to rename network interface",
56 "Failed to process device, ignoring: Device or resource busy",
57 "Cannot find a map file",
58 "[rdrand]: Initialization Failed",
Andrew Geissler5f350902021-07-23 13:09:54 -040059 "[rndr ]: Initialization Failed",
Andrew Geissler82c905d2020-04-13 13:39:40 -050060 "[pulseaudio] authkey.c: Failed to open cookie file",
61 "[pulseaudio] authkey.c: Failed to load authentication key",
Andrew Geissler595f6302022-01-24 19:11:47 +000062 "was skipped because of a failed condition check",
63 "was skipped because all trigger condition checks failed",
Patrick Williams92b42cb2022-09-03 06:53:57 -050064 "xf86OpenConsole: Switching VT failed",
Andrew Geissler87f5cff2022-09-30 13:13:31 -050065 "Failed to read LoaderConfigTimeoutOneShot variable, ignoring: Operation not supported",
66 "Failed to read LoaderEntryOneShot variable, ignoring: Operation not supported",
Andrew Geissler220dafd2023-10-04 10:18:08 -050067 "invalid BAR (can't size)",
Brad Bishop6e60e8b2018-02-01 10:27:11 -050068 ]
69
Brad Bishop6e60e8b2018-02-01 10:27:11 -050070x86_common = [
71 '[drm:psb_do_init] *ERROR* Debug is',
72 'wrong ELF class',
73 'Could not enable PowerButton event',
74 'probe of LNXPWRBN:00 failed with error -22',
75 'pmd_set_huge: Cannot satisfy',
76 'failed to setup card detect gpio',
77 'amd_nb: Cannot enumerate AMD northbridges',
78 'failed to retrieve link info, disabling eDP',
79 'Direct firmware load for iwlwifi',
Brad Bishop19323692019-04-05 15:28:33 -040080 'Direct firmware load for regulatory.db',
81 'failed to load regulatory.db',
Brad Bishop6e60e8b2018-02-01 10:27:11 -050082] + common_errors
83
84qemux86_common = [
85 'wrong ELF class',
86 "fail to add MMCONFIG information, can't access extended PCI configuration space under this bridge.",
87 "can't claim BAR ",
88 'amd_nb: Cannot enumerate AMD northbridges',
Brad Bishop6e60e8b2018-02-01 10:27:11 -050089 'tsc: HPET/PMTIMER calibration failed',
Brad Bishop79641f22019-09-10 07:20:22 -040090 "modeset(0): Failed to initialize the DRI2 extension",
Brad Bishop79641f22019-09-10 07:20:22 -040091 "glamor initialization failed",
Andrew Geisslerc926e172021-05-07 16:11:35 -050092 "blk_update_request: I/O error, dev fd0, sector 0 op 0x0:(READ)",
93 "floppy: error",
Andrew Geissler5199d832021-09-24 16:47:35 -050094 'failed to IDENTIFY (I/O error, err_mask=0x4)',
Brad Bishop6e60e8b2018-02-01 10:27:11 -050095] + common_errors
96
97ignore_errors = {
98 'default' : common_errors,
99 'qemux86' : [
100 'Failed to access perfctr msr (MSR',
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500101 ] + qemux86_common,
102 'qemux86-64' : qemux86_common,
103 'qemumips' : [
104 'Failed to load module "glx"',
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500105 'cacheinfo: Failed to find cpu0 device node',
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500106 ] + common_errors,
107 'qemumips64' : [
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500108 'cacheinfo: Failed to find cpu0 device node',
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500109 ] + common_errors,
110 'qemuppc' : [
111 'PCI 0000:00 Cannot reserve Legacy IO [io 0x0000-0x0fff]',
112 'host side 80-wire cable detection failed, limiting max speed',
113 'mode "640x480" test failed',
114 'Failed to load module "glx"',
115 'can\'t handle BAR above 4GB',
116 'Cannot reserve Legacy IO',
117 ] + common_errors,
Andrew Geissler95ac1b82021-03-31 14:34:31 -0500118 'qemuppc64' : [
119 'vio vio: uevent: failed to send synthetic uevent',
120 'synth uevent: /devices/vio: failed to send uevent',
121 'PCI 0000:00 Cannot reserve Legacy IO [io 0x10000-0x10fff]',
122 ] + common_errors,
Patrick Williams213cb262021-08-07 19:21:33 -0500123 'qemuarmv5' : [
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500124 'mmci-pl18x: probe of fpga:05 failed with error -22',
125 'mmci-pl18x: probe of fpga:0b failed with error -22',
126 'Failed to load module "glx"',
127 'OF: amba_device_add() failed (-19) for /amba/smc@10100000',
128 'OF: amba_device_add() failed (-19) for /amba/mpmc@10110000',
129 'OF: amba_device_add() failed (-19) for /amba/sctl@101e0000',
130 'OF: amba_device_add() failed (-19) for /amba/watchdog@101e1000',
131 'OF: amba_device_add() failed (-19) for /amba/sci@101f0000',
Brad Bishop19323692019-04-05 15:28:33 -0400132 'OF: amba_device_add() failed (-19) for /amba/spi@101f4000',
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500133 'OF: amba_device_add() failed (-19) for /amba/ssp@101f4000',
134 'OF: amba_device_add() failed (-19) for /amba/fpga/sci@a000',
135 'Failed to initialize \'/amba/timer@101e3000\': -22',
136 'jitterentropy: Initialization failed with host not compliant with requirements: 2',
Patrick Williams213cb262021-08-07 19:21:33 -0500137 'clcd-pl11x: probe of 10120000.display failed with error -2',
Patrick Williams92b42cb2022-09-03 06:53:57 -0500138 'arm-charlcd 10008000.lcd: error -ENXIO: IRQ index 0 not found'
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500139 ] + common_errors,
140 'qemuarm64' : [
141 'Fatal server error:',
142 '(EE) Server terminated with error (1). Closing log file.',
143 'dmi: Firmware registration failed.',
144 'irq: type mismatch, failed to map hwirq-27 for /intc',
Andrew Geissler82c905d2020-04-13 13:39:40 -0500145 'logind: failed to get session seat',
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500146 ] + common_errors,
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500147 'intel-core2-32' : [
148 'ACPI: No _BQC method, cannot determine initial brightness',
149 '[Firmware Bug]: ACPI: No _BQC method, cannot determine initial brightness',
150 '(EE) Failed to load module "psb"',
151 '(EE) Failed to load module psb',
152 '(EE) Failed to load module "psbdrv"',
153 '(EE) Failed to load module psbdrv',
154 '(EE) open /dev/fb0: No such file or directory',
155 '(EE) AIGLX: reverting to software rendering',
156 'dmi: Firmware registration failed.',
157 'ioremap error for 0x78',
158 ] + x86_common,
159 'intel-corei7-64' : [
160 'can\'t set Max Payload Size to 256',
161 'intel_punit_ipc: can\'t request region for resource',
162 '[drm] parse error at position 4 in video mode \'efifb\'',
163 'ACPI Error: Could not enable RealTimeClock event',
164 'ACPI Warning: Could not enable fixed event - RealTimeClock',
165 'hci_intel INT33E1:00: Unable to retrieve gpio',
166 'hci_intel: probe of INT33E1:00 failed',
167 'can\'t derive routing for PCI INT A',
168 'failed to read out thermal zone',
169 'Bluetooth: hci0: Setting Intel event mask failed',
170 'ttyS2 - failed to request DMA',
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500171 'Bluetooth: hci0: Failed to send firmware data (-38)',
172 'atkbd serio0: Failed to enable keyboard on isa0060/serio0',
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500173 ] + x86_common,
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500174 'genericx86' : x86_common,
175 'genericx86-64' : [
176 'Direct firmware load for i915',
177 'Failed to load firmware i915',
178 'Failed to fetch GuC',
179 'Failed to initialize GuC',
180 'Failed to load DMC firmware',
181 'The driver is built-in, so to load the firmware you need to',
182 ] + x86_common,
Brad Bishop19323692019-04-05 15:28:33 -0400183 'beaglebone-yocto' : [
184 'Direct firmware load for regulatory.db',
185 'failed to load regulatory.db',
186 'l4_wkup_cm',
187 'Failed to load module "glx"',
188 'Failed to make EGL context current',
189 'glamor initialization failed',
190 ] + common_errors,
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500191}
192
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500193class ParseLogsTest(OERuntimeTestCase):
194
Andrew Geissler220dafd2023-10-04 10:18:08 -0500195 # Which log files should be collected
196 log_locations = ["/var/log/", "/var/log/dmesg", "/tmp/dmesg_output.log"]
197
198 # The keywords that identify error messages in the log files
199 errors = ["error", "cannot", "can't", "failed"]
200
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500201 @classmethod
202 def setUpClass(cls):
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500203 # When systemd is enabled we need to notice errors on
204 # circular dependencies in units.
Andrew Geissler220dafd2023-10-04 10:18:08 -0500205 if 'systemd' in cls.td.get('DISTRO_FEATURES'):
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500206 cls.errors.extend([
207 'Found ordering cycle on',
208 'Breaking ordering cycle by deleting job',
209 'deleted to break ordering cycle',
210 'Ordering cycle found, skipping',
211 ])
212
Andrew Geissler220dafd2023-10-04 10:18:08 -0500213 cls.errors = [s.casefold() for s in cls.errors]
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500214
Andrew Geissler220dafd2023-10-04 10:18:08 -0500215 try:
216 cls.ignore_errors = [s.casefold() for s in ignore_errors[cls.td.get('MACHINE')]]
217 except KeyError:
218 cls.logger.info('No ignore list found for this machine, using default')
219 cls.ignore_errors = [s.casefold() for s in ignore_errors['default']]
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500220
221 # Go through the log locations provided and if it's a folder
222 # create a list with all the .log files in it, if it's a file
223 # just add it to that list.
224 def getLogList(self, log_locations):
225 logs = []
226 for location in log_locations:
Andrew Geissler220dafd2023-10-04 10:18:08 -0500227 status, _ = self.target.run('test -f %s' % location)
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500228 if status == 0:
Andrew Geissler220dafd2023-10-04 10:18:08 -0500229 logs.append(location)
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500230 else:
Andrew Geissler220dafd2023-10-04 10:18:08 -0500231 status, _ = self.target.run('test -d %s' % location)
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500232 if status == 0:
Andrew Geissler220dafd2023-10-04 10:18:08 -0500233 cmd = 'find %s -name \\*.log -maxdepth 1 -type f' % location
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500234 status, output = self.target.run(cmd)
235 if status == 0:
236 output = output.splitlines()
237 for logfile in output:
Andrew Geissler220dafd2023-10-04 10:18:08 -0500238 logs.append(os.path.join(location, logfile))
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500239 return logs
240
241 # Copy the log files to be parsed locally
242 def transfer_logs(self, log_list):
Andrew Geissler220dafd2023-10-04 10:18:08 -0500243 workdir = self.td.get('WORKDIR')
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500244 self.target_logs = workdir + '/' + 'target_logs'
245 target_logs = self.target_logs
246 if os.path.exists(target_logs):
247 rmtree(self.target_logs)
248 os.makedirs(target_logs)
249 for f in log_list:
250 self.target.copyFrom(str(f), target_logs)
251
252 # Get the local list of logs
253 def get_local_log_list(self, log_locations):
254 self.transfer_logs(self.getLogList(log_locations))
255 list_dir = os.listdir(self.target_logs)
256 dir_files = [os.path.join(self.target_logs, f) for f in list_dir]
257 logs = [f for f in dir_files if os.path.isfile(f)]
258 return logs
259
Andrew Geissler220dafd2023-10-04 10:18:08 -0500260 def get_context(self, lines, index, before=6, after=3):
261 """
262 Given a set of lines and the index of the line that is important, return
263 a number of lines surrounding that line.
264 """
265 last = len(lines)
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500266
Andrew Geissler220dafd2023-10-04 10:18:08 -0500267 start = index - before
268 end = index + after + 1
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500269
Andrew Geissler220dafd2023-10-04 10:18:08 -0500270 if start < 0:
271 end -= start
272 start = 0
273 if end > last:
274 start -= end - last
275 end = last
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500276
Andrew Geissler220dafd2023-10-04 10:18:08 -0500277 return lines[start:end]
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500278
Andrew Geissler220dafd2023-10-04 10:18:08 -0500279 def test_get_context(self):
280 """
281 A test case for the test case.
282 """
283 lines = list(range(0,10))
284 self.assertEqual(self.get_context(lines, 0, 2, 1), [0, 1, 2, 3])
285 self.assertEqual(self.get_context(lines, 5, 2, 1), [3, 4, 5, 6])
286 self.assertEqual(self.get_context(lines, 9, 2, 1), [6, 7, 8, 9])
287
288 def parse_logs(self, logs, lines_before=10, lines_after=10):
289 """
290 Search the log files @logs looking for error lines (marked by
291 @self.errors), ignoring anything listed in @self.ignore_errors.
292
293 Returns a dictionary of log filenames to a dictionary of error lines to
294 the error context (controlled by @lines_before and @lines_after).
295 """
296 results = collections.defaultdict(dict)
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500297
298 for log in logs:
Andrew Geissler220dafd2023-10-04 10:18:08 -0500299 with open(log) as f:
300 lines = f.readlines()
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500301
Andrew Geissler220dafd2023-10-04 10:18:08 -0500302 for i, line in enumerate(lines):
303 line = line.strip()
304 line_lower = line.casefold()
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500305
Andrew Geissler220dafd2023-10-04 10:18:08 -0500306 if any(keyword in line_lower for keyword in self.errors):
307 if not any(ignore in line_lower for ignore in self.ignore_errors):
308 results[log][line] = "".join(self.get_context(lines, i, lines_before, lines_after))
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500309
310 return results
311
312 # Get the output of dmesg and write it in a file.
313 # This file is added to log_locations.
314 def write_dmesg(self):
315 (status, dmesg) = self.target.run('dmesg > /tmp/dmesg_output.log')
316
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500317 @OETestDepends(['ssh.SSHTest.test_ssh'])
318 def test_parselogs(self):
319 self.write_dmesg()
320 log_list = self.get_local_log_list(self.log_locations)
Andrew Geissler220dafd2023-10-04 10:18:08 -0500321 result = self.parse_logs(log_list)
322
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500323 errcount = 0
Andrew Geissler220dafd2023-10-04 10:18:08 -0500324 self.msg = ""
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500325 for log in result:
326 self.msg += 'Log: ' + log + '\n'
327 self.msg += '-----------------------\n'
328 for error in result[log]:
329 errcount += 1
Andrew Geissler220dafd2023-10-04 10:18:08 -0500330 self.msg += 'Central error: ' + error + '\n'
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500331 self.msg += '***********************\n'
Andrew Geissler220dafd2023-10-04 10:18:08 -0500332 self.msg += result[log][error] + '\n'
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500333 self.msg += '***********************\n'
334 self.msg += '%s errors found in logs.' % errcount
335 self.assertEqual(errcount, 0, msg=self.msg)