blob: e67d3750dada9c56111a7efa89ecc745d5b38b47 [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
Brad Bishop6e60e8b2018-02-01 10:27:11 -05007import os
8
9from subprocess import check_output
10from shutil import rmtree
11from oeqa.runtime.case import OERuntimeTestCase
12from oeqa.core.decorator.depends import OETestDepends
Brad Bishop6e60e8b2018-02-01 10:27:11 -050013from oeqa.core.decorator.data import skipIfDataVar
14from oeqa.runtime.decorator.package import OEHasPackage
15
16#in the future these lists could be moved outside of module
17errors = ["error", "cannot", "can\'t", "failed"]
18
19common_errors = [
20 "(WW) warning, (EE) error, (NI) not implemented, (??) unknown.",
21 "dma timeout",
22 "can\'t add hid device:",
23 "usbhid: probe of ",
24 "_OSC failed (AE_ERROR)",
25 "_OSC failed (AE_SUPPORT)",
26 "AE_ALREADY_EXISTS",
27 "ACPI _OSC request failed (AE_SUPPORT)",
28 "can\'t disable ASPM",
29 "Failed to load module \"vesa\"",
30 "Failed to load module vesa",
31 "Failed to load module \"modesetting\"",
32 "Failed to load module modesetting",
33 "Failed to load module \"glx\"",
34 "Failed to load module \"fbdev\"",
35 "Failed to load module fbdev",
36 "Failed to load module glx",
Andrew Geisslereff27472021-10-29 15:35:00 -050037 "[drm] Cannot find any crtc or sizes",
Brad Bishop6e60e8b2018-02-01 10:27:11 -050038 "_OSC failed (AE_NOT_FOUND); disabling ASPM",
39 "Open ACPI failed (/var/run/acpid.socket) (No such file or directory)",
40 "NX (Execute Disable) protection cannot be enabled: non-PAE kernel!",
41 "hd.: possibly failed opcode",
42 'NETLINK INITIALIZATION FAILED',
43 'kernel: Cannot find map file',
44 'omap_hwmod: debugss: _wait_target_disable failed',
45 'VGA arbiter: cannot open kernel arbiter, no multi-card support',
46 'Failed to find URL:http://ipv4.connman.net/online/status.html',
47 'Online check failed for',
48 'netlink init failed',
49 'Fast TSC calibration',
50 "BAR 0-9",
51 "Failed to load module \"ati\"",
52 "controller can't do DEVSLP, turning off",
53 "stmmac_dvr_probe: warning: cannot get CSR clock",
54 "error: couldn\'t mount because of unsupported optional features",
55 "GPT: Use GNU Parted to correct GPT errors",
56 "Cannot set xattr user.Librepo.DownloadInProgress",
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080057 "Failed to read /var/lib/nfs/statd/state: Success",
58 "error retry time-out =",
59 "logind: cannot setup systemd-logind helper (-61), using legacy fallback",
Andrew Geissler82c905d2020-04-13 13:39:40 -050060 "Failed to rename network interface",
61 "Failed to process device, ignoring: Device or resource busy",
62 "Cannot find a map file",
63 "[rdrand]: Initialization Failed",
Andrew Geissler5f350902021-07-23 13:09:54 -040064 "[rndr ]: Initialization Failed",
Andrew Geissler82c905d2020-04-13 13:39:40 -050065 "[pulseaudio] authkey.c: Failed to open cookie file",
66 "[pulseaudio] authkey.c: Failed to load authentication key",
Andrew Geissler595f6302022-01-24 19:11:47 +000067 "was skipped because of a failed condition check",
68 "was skipped because all trigger condition checks failed",
Patrick Williams92b42cb2022-09-03 06:53:57 -050069 "xf86OpenConsole: Switching VT failed",
Andrew Geissler87f5cff2022-09-30 13:13:31 -050070 "Failed to read LoaderConfigTimeoutOneShot variable, ignoring: Operation not supported",
71 "Failed to read LoaderEntryOneShot variable, ignoring: Operation not supported",
Brad Bishop6e60e8b2018-02-01 10:27:11 -050072 ]
73
74video_related = [
Brad Bishop6e60e8b2018-02-01 10:27:11 -050075]
76
77x86_common = [
78 '[drm:psb_do_init] *ERROR* Debug is',
79 'wrong ELF class',
80 'Could not enable PowerButton event',
81 'probe of LNXPWRBN:00 failed with error -22',
82 'pmd_set_huge: Cannot satisfy',
83 'failed to setup card detect gpio',
84 'amd_nb: Cannot enumerate AMD northbridges',
85 'failed to retrieve link info, disabling eDP',
86 'Direct firmware load for iwlwifi',
Brad Bishop19323692019-04-05 15:28:33 -040087 'Direct firmware load for regulatory.db',
88 'failed to load regulatory.db',
Brad Bishop6e60e8b2018-02-01 10:27:11 -050089] + common_errors
90
91qemux86_common = [
92 'wrong ELF class',
93 "fail to add MMCONFIG information, can't access extended PCI configuration space under this bridge.",
94 "can't claim BAR ",
95 'amd_nb: Cannot enumerate AMD northbridges',
Brad Bishop6e60e8b2018-02-01 10:27:11 -050096 'tsc: HPET/PMTIMER calibration failed',
Brad Bishop79641f22019-09-10 07:20:22 -040097 "modeset(0): Failed to initialize the DRI2 extension",
Brad Bishop79641f22019-09-10 07:20:22 -040098 "glamor initialization failed",
Andrew Geisslerc926e172021-05-07 16:11:35 -050099 "blk_update_request: I/O error, dev fd0, sector 0 op 0x0:(READ)",
100 "floppy: error",
Andrew Geissler5199d832021-09-24 16:47:35 -0500101 'failed to IDENTIFY (I/O error, err_mask=0x4)',
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500102] + common_errors
103
104ignore_errors = {
105 'default' : common_errors,
106 'qemux86' : [
107 'Failed to access perfctr msr (MSR',
108 'pci 0000:00:00.0: [Firmware Bug]: reg 0x..: invalid BAR (can\'t size)',
109 ] + qemux86_common,
110 'qemux86-64' : qemux86_common,
111 'qemumips' : [
112 'Failed to load module "glx"',
113 'pci 0000:00:00.0: [Firmware Bug]: reg 0x..: invalid BAR (can\'t size)',
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500114 'cacheinfo: Failed to find cpu0 device node',
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500115 ] + common_errors,
116 'qemumips64' : [
117 'pci 0000:00:00.0: [Firmware Bug]: reg 0x..: invalid BAR (can\'t size)',
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500118 'cacheinfo: Failed to find cpu0 device node',
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500119 ] + common_errors,
120 'qemuppc' : [
121 'PCI 0000:00 Cannot reserve Legacy IO [io 0x0000-0x0fff]',
122 'host side 80-wire cable detection failed, limiting max speed',
123 'mode "640x480" test failed',
124 'Failed to load module "glx"',
125 'can\'t handle BAR above 4GB',
126 'Cannot reserve Legacy IO',
127 ] + common_errors,
Andrew Geissler95ac1b82021-03-31 14:34:31 -0500128 'qemuppc64' : [
129 'vio vio: uevent: failed to send synthetic uevent',
130 'synth uevent: /devices/vio: failed to send uevent',
131 'PCI 0000:00 Cannot reserve Legacy IO [io 0x10000-0x10fff]',
132 ] + common_errors,
Patrick Williams213cb262021-08-07 19:21:33 -0500133 'qemuarmv5' : [
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500134 'mmci-pl18x: probe of fpga:05 failed with error -22',
135 'mmci-pl18x: probe of fpga:0b failed with error -22',
136 'Failed to load module "glx"',
137 'OF: amba_device_add() failed (-19) for /amba/smc@10100000',
138 'OF: amba_device_add() failed (-19) for /amba/mpmc@10110000',
139 'OF: amba_device_add() failed (-19) for /amba/sctl@101e0000',
140 'OF: amba_device_add() failed (-19) for /amba/watchdog@101e1000',
141 'OF: amba_device_add() failed (-19) for /amba/sci@101f0000',
Brad Bishop19323692019-04-05 15:28:33 -0400142 'OF: amba_device_add() failed (-19) for /amba/spi@101f4000',
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500143 'OF: amba_device_add() failed (-19) for /amba/ssp@101f4000',
144 'OF: amba_device_add() failed (-19) for /amba/fpga/sci@a000',
145 'Failed to initialize \'/amba/timer@101e3000\': -22',
146 'jitterentropy: Initialization failed with host not compliant with requirements: 2',
Patrick Williams213cb262021-08-07 19:21:33 -0500147 'clcd-pl11x: probe of 10120000.display failed with error -2',
Patrick Williams92b42cb2022-09-03 06:53:57 -0500148 'arm-charlcd 10008000.lcd: error -ENXIO: IRQ index 0 not found'
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500149 ] + common_errors,
150 'qemuarm64' : [
151 'Fatal server error:',
152 '(EE) Server terminated with error (1). Closing log file.',
153 'dmi: Firmware registration failed.',
154 'irq: type mismatch, failed to map hwirq-27 for /intc',
Andrew Geissler82c905d2020-04-13 13:39:40 -0500155 'logind: failed to get session seat',
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500156 ] + common_errors,
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500157 'intel-core2-32' : [
158 'ACPI: No _BQC method, cannot determine initial brightness',
159 '[Firmware Bug]: ACPI: No _BQC method, cannot determine initial brightness',
160 '(EE) Failed to load module "psb"',
161 '(EE) Failed to load module psb',
162 '(EE) Failed to load module "psbdrv"',
163 '(EE) Failed to load module psbdrv',
164 '(EE) open /dev/fb0: No such file or directory',
165 '(EE) AIGLX: reverting to software rendering',
166 'dmi: Firmware registration failed.',
167 'ioremap error for 0x78',
168 ] + x86_common,
169 'intel-corei7-64' : [
170 'can\'t set Max Payload Size to 256',
171 'intel_punit_ipc: can\'t request region for resource',
172 '[drm] parse error at position 4 in video mode \'efifb\'',
173 'ACPI Error: Could not enable RealTimeClock event',
174 'ACPI Warning: Could not enable fixed event - RealTimeClock',
175 'hci_intel INT33E1:00: Unable to retrieve gpio',
176 'hci_intel: probe of INT33E1:00 failed',
177 'can\'t derive routing for PCI INT A',
178 'failed to read out thermal zone',
179 'Bluetooth: hci0: Setting Intel event mask failed',
180 'ttyS2 - failed to request DMA',
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500181 'Bluetooth: hci0: Failed to send firmware data (-38)',
182 'atkbd serio0: Failed to enable keyboard on isa0060/serio0',
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500183 ] + x86_common,
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500184 'genericx86' : x86_common,
185 'genericx86-64' : [
186 'Direct firmware load for i915',
187 'Failed to load firmware i915',
188 'Failed to fetch GuC',
189 'Failed to initialize GuC',
190 'Failed to load DMC firmware',
191 'The driver is built-in, so to load the firmware you need to',
192 ] + x86_common,
193 'edgerouter' : [
Brad Bishop19323692019-04-05 15:28:33 -0400194 'not creating \'/sys/firmware/fdt\'',
195 'Failed to find cpu0 device node',
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500196 'Fatal server error:',
Brad Bishop19323692019-04-05 15:28:33 -0400197 'Server terminated with error',
198 ] + common_errors,
199 'beaglebone-yocto' : [
200 'Direct firmware load for regulatory.db',
201 'failed to load regulatory.db',
202 'l4_wkup_cm',
203 'Failed to load module "glx"',
204 'Failed to make EGL context current',
205 'glamor initialization failed',
206 ] + common_errors,
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500207}
208
209log_locations = ["/var/log/","/var/log/dmesg", "/tmp/dmesg_output.log"]
210
211class ParseLogsTest(OERuntimeTestCase):
212
213 @classmethod
214 def setUpClass(cls):
215 cls.errors = errors
216
217 # When systemd is enabled we need to notice errors on
218 # circular dependencies in units.
219 if 'systemd' in cls.td.get('DISTRO_FEATURES', ''):
220 cls.errors.extend([
221 'Found ordering cycle on',
222 'Breaking ordering cycle by deleting job',
223 'deleted to break ordering cycle',
224 'Ordering cycle found, skipping',
225 ])
226
227 cls.ignore_errors = ignore_errors
228 cls.log_locations = log_locations
229 cls.msg = ''
230 is_lsb, _ = cls.tc.target.run("which LSB_Test.sh")
231 if is_lsb == 0:
232 for machine in cls.ignore_errors:
233 cls.ignore_errors[machine] = cls.ignore_errors[machine] \
234 + video_related
235
236 def getMachine(self):
237 return self.td.get('MACHINE', '')
238
239 def getWorkdir(self):
240 return self.td.get('WORKDIR', '')
241
242 # Get some information on the CPU of the machine to display at the
243 # beginning of the output. This info might be useful in some cases.
244 def getHardwareInfo(self):
245 hwi = ""
246 cmd = ('cat /proc/cpuinfo | grep "model name" | head -n1 | '
247 " awk 'BEGIN{FS=\":\"}{print $2}'")
248 _, cpu_name = self.target.run(cmd)
249
250 cmd = ('cat /proc/cpuinfo | grep "cpu cores" | head -n1 | '
251 "awk {'print $4'}")
252 _, cpu_physical_cores = self.target.run(cmd)
253
254 cmd = 'cat /proc/cpuinfo | grep "processor" | wc -l'
255 _, cpu_logical_cores = self.target.run(cmd)
256
257 _, cpu_arch = self.target.run('uname -m')
258
259 hwi += 'Machine information: \n'
260 hwi += '*******************************\n'
261 hwi += 'Machine name: ' + self.getMachine() + '\n'
262 hwi += 'CPU: ' + str(cpu_name) + '\n'
263 hwi += 'Arch: ' + str(cpu_arch)+ '\n'
264 hwi += 'Physical cores: ' + str(cpu_physical_cores) + '\n'
265 hwi += 'Logical cores: ' + str(cpu_logical_cores) + '\n'
266 hwi += '*******************************\n'
267
268 return hwi
269
270 # Go through the log locations provided and if it's a folder
271 # create a list with all the .log files in it, if it's a file
272 # just add it to that list.
273 def getLogList(self, log_locations):
274 logs = []
275 for location in log_locations:
276 status, _ = self.target.run('test -f ' + str(location))
277 if status == 0:
278 logs.append(str(location))
279 else:
280 status, _ = self.target.run('test -d ' + str(location))
281 if status == 0:
282 cmd = 'find ' + str(location) + '/*.log -maxdepth 1 -type f'
283 status, output = self.target.run(cmd)
284 if status == 0:
285 output = output.splitlines()
286 for logfile in output:
287 logs.append(os.path.join(location, str(logfile)))
288 return logs
289
290 # Copy the log files to be parsed locally
291 def transfer_logs(self, log_list):
292 workdir = self.getWorkdir()
293 self.target_logs = workdir + '/' + 'target_logs'
294 target_logs = self.target_logs
295 if os.path.exists(target_logs):
296 rmtree(self.target_logs)
297 os.makedirs(target_logs)
298 for f in log_list:
299 self.target.copyFrom(str(f), target_logs)
300
301 # Get the local list of logs
302 def get_local_log_list(self, log_locations):
303 self.transfer_logs(self.getLogList(log_locations))
304 list_dir = os.listdir(self.target_logs)
305 dir_files = [os.path.join(self.target_logs, f) for f in list_dir]
306 logs = [f for f in dir_files if os.path.isfile(f)]
307 return logs
308
309 # Build the grep command to be used with filters and exclusions
310 def build_grepcmd(self, errors, ignore_errors, log):
311 grepcmd = 'grep '
312 grepcmd += '-Ei "'
313 for error in errors:
Andrew Geissler595f6302022-01-24 19:11:47 +0000314 grepcmd += r'\<' + error + r'\>' + '|'
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500315 grepcmd = grepcmd[:-1]
316 grepcmd += '" ' + str(log) + " | grep -Eiv \'"
317
318 try:
319 errorlist = ignore_errors[self.getMachine()]
320 except KeyError:
321 self.msg += 'No ignore list found for this machine, using default\n'
322 errorlist = ignore_errors['default']
323
324 for ignore_error in errorlist:
Andrew Geissler595f6302022-01-24 19:11:47 +0000325 ignore_error = ignore_error.replace('(', r'\(')
326 ignore_error = ignore_error.replace(')', r'\)')
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500327 ignore_error = ignore_error.replace("'", '.')
Andrew Geissler595f6302022-01-24 19:11:47 +0000328 ignore_error = ignore_error.replace('?', r'\?')
329 ignore_error = ignore_error.replace('[', r'\[')
330 ignore_error = ignore_error.replace(']', r'\]')
331 ignore_error = ignore_error.replace('*', r'\*')
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500332 ignore_error = ignore_error.replace('0-9', '[0-9]')
333 grepcmd += ignore_error + '|'
334 grepcmd = grepcmd[:-1]
335 grepcmd += "\'"
336
337 return grepcmd
338
339 # Grep only the errors so that their context could be collected.
340 # Default context is 10 lines before and after the error itself
341 def parse_logs(self, errors, ignore_errors, logs,
342 lines_before = 10, lines_after = 10):
343 results = {}
344 rez = []
345 grep_output = ''
346
347 for log in logs:
348 result = None
349 thegrep = self.build_grepcmd(errors, ignore_errors, log)
350
351 try:
352 result = check_output(thegrep, shell=True).decode('utf-8')
353 except:
354 pass
355
356 if result is not None:
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800357 results[log] = {}
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500358 rez = result.splitlines()
359
360 for xrez in rez:
361 try:
362 cmd = ['grep', '-F', xrez, '-B', str(lines_before)]
363 cmd += ['-A', str(lines_after), log]
364 grep_output = check_output(cmd).decode('utf-8')
365 except:
366 pass
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800367 results[log][xrez]=grep_output
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500368
369 return results
370
371 # Get the output of dmesg and write it in a file.
372 # This file is added to log_locations.
373 def write_dmesg(self):
374 (status, dmesg) = self.target.run('dmesg > /tmp/dmesg_output.log')
375
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500376 @OETestDepends(['ssh.SSHTest.test_ssh'])
377 def test_parselogs(self):
378 self.write_dmesg()
379 log_list = self.get_local_log_list(self.log_locations)
380 result = self.parse_logs(self.errors, self.ignore_errors, log_list)
381 print(self.getHardwareInfo())
382 errcount = 0
383 for log in result:
384 self.msg += 'Log: ' + log + '\n'
385 self.msg += '-----------------------\n'
386 for error in result[log]:
387 errcount += 1
388 self.msg += 'Central error: ' + str(error) + '\n'
389 self.msg += '***********************\n'
390 self.msg += result[str(log)][str(error)] + '\n'
391 self.msg += '***********************\n'
392 self.msg += '%s errors found in logs.' % errcount
393 self.assertEqual(errcount, 0, msg=self.msg)