blob: e16c230dfa47aa54771ba3a9daf7680a7f14c935 [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",
Brad Bishop6e60e8b2018-02-01 10:27:11 -050070 ]
71
72video_related = [
Brad Bishop6e60e8b2018-02-01 10:27:11 -050073]
74
75x86_common = [
76 '[drm:psb_do_init] *ERROR* Debug is',
77 'wrong ELF class',
78 'Could not enable PowerButton event',
79 'probe of LNXPWRBN:00 failed with error -22',
80 'pmd_set_huge: Cannot satisfy',
81 'failed to setup card detect gpio',
82 'amd_nb: Cannot enumerate AMD northbridges',
83 'failed to retrieve link info, disabling eDP',
84 'Direct firmware load for iwlwifi',
Brad Bishop19323692019-04-05 15:28:33 -040085 'Direct firmware load for regulatory.db',
86 'failed to load regulatory.db',
Brad Bishop6e60e8b2018-02-01 10:27:11 -050087] + common_errors
88
89qemux86_common = [
90 'wrong ELF class',
91 "fail to add MMCONFIG information, can't access extended PCI configuration space under this bridge.",
92 "can't claim BAR ",
93 'amd_nb: Cannot enumerate AMD northbridges',
Brad Bishop6e60e8b2018-02-01 10:27:11 -050094 'tsc: HPET/PMTIMER calibration failed',
Brad Bishop79641f22019-09-10 07:20:22 -040095 "modeset(0): Failed to initialize the DRI2 extension",
Brad Bishop79641f22019-09-10 07:20:22 -040096 "glamor initialization failed",
Andrew Geisslerc926e172021-05-07 16:11:35 -050097 "blk_update_request: I/O error, dev fd0, sector 0 op 0x0:(READ)",
98 "floppy: error",
Andrew Geissler5199d832021-09-24 16:47:35 -050099 'failed to IDENTIFY (I/O error, err_mask=0x4)',
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500100] + common_errors
101
102ignore_errors = {
103 'default' : common_errors,
104 'qemux86' : [
105 'Failed to access perfctr msr (MSR',
106 'pci 0000:00:00.0: [Firmware Bug]: reg 0x..: invalid BAR (can\'t size)',
107 ] + qemux86_common,
108 'qemux86-64' : qemux86_common,
109 'qemumips' : [
110 'Failed to load module "glx"',
111 'pci 0000:00:00.0: [Firmware Bug]: reg 0x..: invalid BAR (can\'t size)',
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500112 'cacheinfo: Failed to find cpu0 device node',
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500113 ] + common_errors,
114 'qemumips64' : [
115 'pci 0000:00:00.0: [Firmware Bug]: reg 0x..: invalid BAR (can\'t size)',
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500116 'cacheinfo: Failed to find cpu0 device node',
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500117 ] + common_errors,
118 'qemuppc' : [
119 'PCI 0000:00 Cannot reserve Legacy IO [io 0x0000-0x0fff]',
120 'host side 80-wire cable detection failed, limiting max speed',
121 'mode "640x480" test failed',
122 'Failed to load module "glx"',
123 'can\'t handle BAR above 4GB',
124 'Cannot reserve Legacy IO',
125 ] + common_errors,
Andrew Geissler95ac1b82021-03-31 14:34:31 -0500126 'qemuppc64' : [
127 'vio vio: uevent: failed to send synthetic uevent',
128 'synth uevent: /devices/vio: failed to send uevent',
129 'PCI 0000:00 Cannot reserve Legacy IO [io 0x10000-0x10fff]',
130 ] + common_errors,
Patrick Williams213cb262021-08-07 19:21:33 -0500131 'qemuarmv5' : [
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500132 'mmci-pl18x: probe of fpga:05 failed with error -22',
133 'mmci-pl18x: probe of fpga:0b failed with error -22',
134 'Failed to load module "glx"',
135 'OF: amba_device_add() failed (-19) for /amba/smc@10100000',
136 'OF: amba_device_add() failed (-19) for /amba/mpmc@10110000',
137 'OF: amba_device_add() failed (-19) for /amba/sctl@101e0000',
138 'OF: amba_device_add() failed (-19) for /amba/watchdog@101e1000',
139 'OF: amba_device_add() failed (-19) for /amba/sci@101f0000',
Brad Bishop19323692019-04-05 15:28:33 -0400140 'OF: amba_device_add() failed (-19) for /amba/spi@101f4000',
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500141 'OF: amba_device_add() failed (-19) for /amba/ssp@101f4000',
142 'OF: amba_device_add() failed (-19) for /amba/fpga/sci@a000',
143 'Failed to initialize \'/amba/timer@101e3000\': -22',
144 'jitterentropy: Initialization failed with host not compliant with requirements: 2',
Patrick Williams213cb262021-08-07 19:21:33 -0500145 'clcd-pl11x: probe of 10120000.display failed with error -2',
Patrick Williams92b42cb2022-09-03 06:53:57 -0500146 'arm-charlcd 10008000.lcd: error -ENXIO: IRQ index 0 not found'
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500147 ] + common_errors,
148 'qemuarm64' : [
149 'Fatal server error:',
150 '(EE) Server terminated with error (1). Closing log file.',
151 'dmi: Firmware registration failed.',
152 'irq: type mismatch, failed to map hwirq-27 for /intc',
Andrew Geissler82c905d2020-04-13 13:39:40 -0500153 'logind: failed to get session seat',
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500154 ] + common_errors,
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500155 'intel-core2-32' : [
156 'ACPI: No _BQC method, cannot determine initial brightness',
157 '[Firmware Bug]: ACPI: No _BQC method, cannot determine initial brightness',
158 '(EE) Failed to load module "psb"',
159 '(EE) Failed to load module psb',
160 '(EE) Failed to load module "psbdrv"',
161 '(EE) Failed to load module psbdrv',
162 '(EE) open /dev/fb0: No such file or directory',
163 '(EE) AIGLX: reverting to software rendering',
164 'dmi: Firmware registration failed.',
165 'ioremap error for 0x78',
166 ] + x86_common,
167 'intel-corei7-64' : [
168 'can\'t set Max Payload Size to 256',
169 'intel_punit_ipc: can\'t request region for resource',
170 '[drm] parse error at position 4 in video mode \'efifb\'',
171 'ACPI Error: Could not enable RealTimeClock event',
172 'ACPI Warning: Could not enable fixed event - RealTimeClock',
173 'hci_intel INT33E1:00: Unable to retrieve gpio',
174 'hci_intel: probe of INT33E1:00 failed',
175 'can\'t derive routing for PCI INT A',
176 'failed to read out thermal zone',
177 'Bluetooth: hci0: Setting Intel event mask failed',
178 'ttyS2 - failed to request DMA',
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500179 'Bluetooth: hci0: Failed to send firmware data (-38)',
180 'atkbd serio0: Failed to enable keyboard on isa0060/serio0',
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500181 ] + x86_common,
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500182 'genericx86' : x86_common,
183 'genericx86-64' : [
184 'Direct firmware load for i915',
185 'Failed to load firmware i915',
186 'Failed to fetch GuC',
187 'Failed to initialize GuC',
188 'Failed to load DMC firmware',
189 'The driver is built-in, so to load the firmware you need to',
190 ] + x86_common,
191 'edgerouter' : [
Brad Bishop19323692019-04-05 15:28:33 -0400192 'not creating \'/sys/firmware/fdt\'',
193 'Failed to find cpu0 device node',
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500194 'Fatal server error:',
Brad Bishop19323692019-04-05 15:28:33 -0400195 'Server terminated with error',
196 ] + common_errors,
197 'beaglebone-yocto' : [
198 'Direct firmware load for regulatory.db',
199 'failed to load regulatory.db',
200 'l4_wkup_cm',
201 'Failed to load module "glx"',
202 'Failed to make EGL context current',
203 'glamor initialization failed',
204 ] + common_errors,
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500205}
206
207log_locations = ["/var/log/","/var/log/dmesg", "/tmp/dmesg_output.log"]
208
209class ParseLogsTest(OERuntimeTestCase):
210
211 @classmethod
212 def setUpClass(cls):
213 cls.errors = errors
214
215 # When systemd is enabled we need to notice errors on
216 # circular dependencies in units.
217 if 'systemd' in cls.td.get('DISTRO_FEATURES', ''):
218 cls.errors.extend([
219 'Found ordering cycle on',
220 'Breaking ordering cycle by deleting job',
221 'deleted to break ordering cycle',
222 'Ordering cycle found, skipping',
223 ])
224
225 cls.ignore_errors = ignore_errors
226 cls.log_locations = log_locations
227 cls.msg = ''
228 is_lsb, _ = cls.tc.target.run("which LSB_Test.sh")
229 if is_lsb == 0:
230 for machine in cls.ignore_errors:
231 cls.ignore_errors[machine] = cls.ignore_errors[machine] \
232 + video_related
233
234 def getMachine(self):
235 return self.td.get('MACHINE', '')
236
237 def getWorkdir(self):
238 return self.td.get('WORKDIR', '')
239
240 # Get some information on the CPU of the machine to display at the
241 # beginning of the output. This info might be useful in some cases.
242 def getHardwareInfo(self):
243 hwi = ""
244 cmd = ('cat /proc/cpuinfo | grep "model name" | head -n1 | '
245 " awk 'BEGIN{FS=\":\"}{print $2}'")
246 _, cpu_name = self.target.run(cmd)
247
248 cmd = ('cat /proc/cpuinfo | grep "cpu cores" | head -n1 | '
249 "awk {'print $4'}")
250 _, cpu_physical_cores = self.target.run(cmd)
251
252 cmd = 'cat /proc/cpuinfo | grep "processor" | wc -l'
253 _, cpu_logical_cores = self.target.run(cmd)
254
255 _, cpu_arch = self.target.run('uname -m')
256
257 hwi += 'Machine information: \n'
258 hwi += '*******************************\n'
259 hwi += 'Machine name: ' + self.getMachine() + '\n'
260 hwi += 'CPU: ' + str(cpu_name) + '\n'
261 hwi += 'Arch: ' + str(cpu_arch)+ '\n'
262 hwi += 'Physical cores: ' + str(cpu_physical_cores) + '\n'
263 hwi += 'Logical cores: ' + str(cpu_logical_cores) + '\n'
264 hwi += '*******************************\n'
265
266 return hwi
267
268 # Go through the log locations provided and if it's a folder
269 # create a list with all the .log files in it, if it's a file
270 # just add it to that list.
271 def getLogList(self, log_locations):
272 logs = []
273 for location in log_locations:
274 status, _ = self.target.run('test -f ' + str(location))
275 if status == 0:
276 logs.append(str(location))
277 else:
278 status, _ = self.target.run('test -d ' + str(location))
279 if status == 0:
280 cmd = 'find ' + str(location) + '/*.log -maxdepth 1 -type f'
281 status, output = self.target.run(cmd)
282 if status == 0:
283 output = output.splitlines()
284 for logfile in output:
285 logs.append(os.path.join(location, str(logfile)))
286 return logs
287
288 # Copy the log files to be parsed locally
289 def transfer_logs(self, log_list):
290 workdir = self.getWorkdir()
291 self.target_logs = workdir + '/' + 'target_logs'
292 target_logs = self.target_logs
293 if os.path.exists(target_logs):
294 rmtree(self.target_logs)
295 os.makedirs(target_logs)
296 for f in log_list:
297 self.target.copyFrom(str(f), target_logs)
298
299 # Get the local list of logs
300 def get_local_log_list(self, log_locations):
301 self.transfer_logs(self.getLogList(log_locations))
302 list_dir = os.listdir(self.target_logs)
303 dir_files = [os.path.join(self.target_logs, f) for f in list_dir]
304 logs = [f for f in dir_files if os.path.isfile(f)]
305 return logs
306
307 # Build the grep command to be used with filters and exclusions
308 def build_grepcmd(self, errors, ignore_errors, log):
309 grepcmd = 'grep '
310 grepcmd += '-Ei "'
311 for error in errors:
Andrew Geissler595f6302022-01-24 19:11:47 +0000312 grepcmd += r'\<' + error + r'\>' + '|'
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500313 grepcmd = grepcmd[:-1]
314 grepcmd += '" ' + str(log) + " | grep -Eiv \'"
315
316 try:
317 errorlist = ignore_errors[self.getMachine()]
318 except KeyError:
319 self.msg += 'No ignore list found for this machine, using default\n'
320 errorlist = ignore_errors['default']
321
322 for ignore_error in errorlist:
Andrew Geissler595f6302022-01-24 19:11:47 +0000323 ignore_error = ignore_error.replace('(', r'\(')
324 ignore_error = ignore_error.replace(')', r'\)')
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500325 ignore_error = ignore_error.replace("'", '.')
Andrew Geissler595f6302022-01-24 19:11:47 +0000326 ignore_error = ignore_error.replace('?', r'\?')
327 ignore_error = ignore_error.replace('[', r'\[')
328 ignore_error = ignore_error.replace(']', r'\]')
329 ignore_error = ignore_error.replace('*', r'\*')
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500330 ignore_error = ignore_error.replace('0-9', '[0-9]')
331 grepcmd += ignore_error + '|'
332 grepcmd = grepcmd[:-1]
333 grepcmd += "\'"
334
335 return grepcmd
336
337 # Grep only the errors so that their context could be collected.
338 # Default context is 10 lines before and after the error itself
339 def parse_logs(self, errors, ignore_errors, logs,
340 lines_before = 10, lines_after = 10):
341 results = {}
342 rez = []
343 grep_output = ''
344
345 for log in logs:
346 result = None
347 thegrep = self.build_grepcmd(errors, ignore_errors, log)
348
349 try:
350 result = check_output(thegrep, shell=True).decode('utf-8')
351 except:
352 pass
353
354 if result is not None:
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800355 results[log] = {}
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500356 rez = result.splitlines()
357
358 for xrez in rez:
359 try:
360 cmd = ['grep', '-F', xrez, '-B', str(lines_before)]
361 cmd += ['-A', str(lines_after), log]
362 grep_output = check_output(cmd).decode('utf-8')
363 except:
364 pass
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800365 results[log][xrez]=grep_output
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500366
367 return results
368
369 # Get the output of dmesg and write it in a file.
370 # This file is added to log_locations.
371 def write_dmesg(self):
372 (status, dmesg) = self.target.run('dmesg > /tmp/dmesg_output.log')
373
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500374 @OETestDepends(['ssh.SSHTest.test_ssh'])
375 def test_parselogs(self):
376 self.write_dmesg()
377 log_list = self.get_local_log_list(self.log_locations)
378 result = self.parse_logs(self.errors, self.ignore_errors, log_list)
379 print(self.getHardwareInfo())
380 errcount = 0
381 for log in result:
382 self.msg += 'Log: ' + log + '\n'
383 self.msg += '-----------------------\n'
384 for error in result[log]:
385 errcount += 1
386 self.msg += 'Central error: ' + str(error) + '\n'
387 self.msg += '***********************\n'
388 self.msg += result[str(log)][str(error)] + '\n'
389 self.msg += '***********************\n'
390 self.msg += '%s errors found in logs.' % errcount
391 self.assertEqual(errcount, 0, msg=self.msg)