Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 1 | # |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 2 | # Copyright OpenEmbedded Contributors |
| 3 | # |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 4 | # SPDX-License-Identifier: MIT |
| 5 | # |
| 6 | |
Andrew Geissler | 220dafd | 2023-10-04 10:18:08 -0500 | [diff] [blame] | 7 | import collections |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 8 | import os |
| 9 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 10 | from shutil import rmtree |
| 11 | from oeqa.runtime.case import OERuntimeTestCase |
| 12 | from oeqa.core.decorator.depends import OETestDepends |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 13 | |
| 14 | common_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 Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 32 | "[drm] Cannot find any crtc or sizes", |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 33 | "_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 Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 52 | "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 Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 55 | "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 Geissler | 5f35090 | 2021-07-23 13:09:54 -0400 | [diff] [blame] | 59 | "[rndr ]: Initialization Failed", |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 60 | "[pulseaudio] authkey.c: Failed to open cookie file", |
| 61 | "[pulseaudio] authkey.c: Failed to load authentication key", |
Andrew Geissler | 595f630 | 2022-01-24 19:11:47 +0000 | [diff] [blame] | 62 | "was skipped because of a failed condition check", |
| 63 | "was skipped because all trigger condition checks failed", |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 64 | "xf86OpenConsole: Switching VT failed", |
Andrew Geissler | 87f5cff | 2022-09-30 13:13:31 -0500 | [diff] [blame] | 65 | "Failed to read LoaderConfigTimeoutOneShot variable, ignoring: Operation not supported", |
| 66 | "Failed to read LoaderEntryOneShot variable, ignoring: Operation not supported", |
Andrew Geissler | 220dafd | 2023-10-04 10:18:08 -0500 | [diff] [blame] | 67 | "invalid BAR (can't size)", |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 68 | ] |
| 69 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 70 | x86_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 Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 80 | 'Direct firmware load for regulatory.db', |
| 81 | 'failed to load regulatory.db', |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 82 | ] + common_errors |
| 83 | |
| 84 | qemux86_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 Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 89 | 'tsc: HPET/PMTIMER calibration failed', |
Brad Bishop | 79641f2 | 2019-09-10 07:20:22 -0400 | [diff] [blame] | 90 | "modeset(0): Failed to initialize the DRI2 extension", |
Brad Bishop | 79641f2 | 2019-09-10 07:20:22 -0400 | [diff] [blame] | 91 | "glamor initialization failed", |
Andrew Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame] | 92 | "blk_update_request: I/O error, dev fd0, sector 0 op 0x0:(READ)", |
| 93 | "floppy: error", |
Andrew Geissler | 5199d83 | 2021-09-24 16:47:35 -0500 | [diff] [blame] | 94 | 'failed to IDENTIFY (I/O error, err_mask=0x4)', |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 95 | ] + common_errors |
| 96 | |
| 97 | ignore_errors = { |
| 98 | 'default' : common_errors, |
| 99 | 'qemux86' : [ |
| 100 | 'Failed to access perfctr msr (MSR', |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 101 | ] + qemux86_common, |
| 102 | 'qemux86-64' : qemux86_common, |
| 103 | 'qemumips' : [ |
| 104 | 'Failed to load module "glx"', |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 105 | 'cacheinfo: Failed to find cpu0 device node', |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 106 | ] + common_errors, |
| 107 | 'qemumips64' : [ |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 108 | 'cacheinfo: Failed to find cpu0 device node', |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 109 | ] + 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 Geissler | 95ac1b8 | 2021-03-31 14:34:31 -0500 | [diff] [blame] | 118 | '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 Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 123 | 'qemuarmv5' : [ |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 124 | '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 Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 132 | 'OF: amba_device_add() failed (-19) for /amba/spi@101f4000', |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 133 | '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 Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 137 | 'clcd-pl11x: probe of 10120000.display failed with error -2', |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 138 | 'arm-charlcd 10008000.lcd: error -ENXIO: IRQ index 0 not found' |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 139 | ] + 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 Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 145 | 'logind: failed to get session seat', |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 146 | ] + common_errors, |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 147 | '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 Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 171 | 'Bluetooth: hci0: Failed to send firmware data (-38)', |
| 172 | 'atkbd serio0: Failed to enable keyboard on isa0060/serio0', |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 173 | ] + x86_common, |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 174 | '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 Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 183 | '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 Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 191 | } |
| 192 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 193 | class ParseLogsTest(OERuntimeTestCase): |
| 194 | |
Andrew Geissler | 220dafd | 2023-10-04 10:18:08 -0500 | [diff] [blame] | 195 | # 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 Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 201 | @classmethod |
| 202 | def setUpClass(cls): |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 203 | # When systemd is enabled we need to notice errors on |
| 204 | # circular dependencies in units. |
Andrew Geissler | 220dafd | 2023-10-04 10:18:08 -0500 | [diff] [blame] | 205 | if 'systemd' in cls.td.get('DISTRO_FEATURES'): |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 206 | 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 Geissler | 220dafd | 2023-10-04 10:18:08 -0500 | [diff] [blame] | 213 | cls.errors = [s.casefold() for s in cls.errors] |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 214 | |
Andrew Geissler | 220dafd | 2023-10-04 10:18:08 -0500 | [diff] [blame] | 215 | 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 Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 220 | |
| 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 Geissler | 220dafd | 2023-10-04 10:18:08 -0500 | [diff] [blame] | 227 | status, _ = self.target.run('test -f %s' % location) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 228 | if status == 0: |
Andrew Geissler | 220dafd | 2023-10-04 10:18:08 -0500 | [diff] [blame] | 229 | logs.append(location) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 230 | else: |
Andrew Geissler | 220dafd | 2023-10-04 10:18:08 -0500 | [diff] [blame] | 231 | status, _ = self.target.run('test -d %s' % location) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 232 | if status == 0: |
Andrew Geissler | 220dafd | 2023-10-04 10:18:08 -0500 | [diff] [blame] | 233 | cmd = 'find %s -name \\*.log -maxdepth 1 -type f' % location |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 234 | status, output = self.target.run(cmd) |
| 235 | if status == 0: |
| 236 | output = output.splitlines() |
| 237 | for logfile in output: |
Andrew Geissler | 220dafd | 2023-10-04 10:18:08 -0500 | [diff] [blame] | 238 | logs.append(os.path.join(location, logfile)) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 239 | return logs |
| 240 | |
| 241 | # Copy the log files to be parsed locally |
| 242 | def transfer_logs(self, log_list): |
Andrew Geissler | 220dafd | 2023-10-04 10:18:08 -0500 | [diff] [blame] | 243 | workdir = self.td.get('WORKDIR') |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 244 | 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 Geissler | 220dafd | 2023-10-04 10:18:08 -0500 | [diff] [blame] | 260 | 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 Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 266 | |
Andrew Geissler | 220dafd | 2023-10-04 10:18:08 -0500 | [diff] [blame] | 267 | start = index - before |
| 268 | end = index + after + 1 |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 269 | |
Andrew Geissler | 220dafd | 2023-10-04 10:18:08 -0500 | [diff] [blame] | 270 | if start < 0: |
| 271 | end -= start |
| 272 | start = 0 |
| 273 | if end > last: |
| 274 | start -= end - last |
| 275 | end = last |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 276 | |
Andrew Geissler | 220dafd | 2023-10-04 10:18:08 -0500 | [diff] [blame] | 277 | return lines[start:end] |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 278 | |
Andrew Geissler | 220dafd | 2023-10-04 10:18:08 -0500 | [diff] [blame] | 279 | 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 Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 297 | |
| 298 | for log in logs: |
Andrew Geissler | 220dafd | 2023-10-04 10:18:08 -0500 | [diff] [blame] | 299 | with open(log) as f: |
| 300 | lines = f.readlines() |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 301 | |
Andrew Geissler | 220dafd | 2023-10-04 10:18:08 -0500 | [diff] [blame] | 302 | for i, line in enumerate(lines): |
| 303 | line = line.strip() |
| 304 | line_lower = line.casefold() |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 305 | |
Andrew Geissler | 220dafd | 2023-10-04 10:18:08 -0500 | [diff] [blame] | 306 | 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 Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 309 | |
| 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 Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 317 | @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 Geissler | 220dafd | 2023-10-04 10:18:08 -0500 | [diff] [blame] | 321 | result = self.parse_logs(log_list) |
| 322 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 323 | errcount = 0 |
Andrew Geissler | 220dafd | 2023-10-04 10:18:08 -0500 | [diff] [blame] | 324 | self.msg = "" |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 325 | for log in result: |
| 326 | self.msg += 'Log: ' + log + '\n' |
| 327 | self.msg += '-----------------------\n' |
| 328 | for error in result[log]: |
| 329 | errcount += 1 |
Andrew Geissler | 220dafd | 2023-10-04 10:18:08 -0500 | [diff] [blame] | 330 | self.msg += 'Central error: ' + error + '\n' |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 331 | self.msg += '***********************\n' |
Andrew Geissler | 220dafd | 2023-10-04 10:18:08 -0500 | [diff] [blame] | 332 | self.msg += result[log][error] + '\n' |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 333 | self.msg += '***********************\n' |
| 334 | self.msg += '%s errors found in logs.' % errcount |
| 335 | self.assertEqual(errcount, 0, msg=self.msg) |