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 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 7 | import os |
| 8 | |
| 9 | from subprocess import check_output |
| 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 | from oeqa.core.decorator.data import skipIfDataVar |
| 14 | from oeqa.runtime.decorator.package import OEHasPackage |
| 15 | |
| 16 | #in the future these lists could be moved outside of module |
| 17 | errors = ["error", "cannot", "can\'t", "failed"] |
| 18 | |
| 19 | common_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 Geissler | eff2747 | 2021-10-29 15:35:00 -0500 | [diff] [blame] | 37 | "[drm] Cannot find any crtc or sizes", |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 38 | "_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 Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 57 | "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 Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 60 | "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 Geissler | 5f35090 | 2021-07-23 13:09:54 -0400 | [diff] [blame] | 64 | "[rndr ]: Initialization Failed", |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 65 | "[pulseaudio] authkey.c: Failed to open cookie file", |
| 66 | "[pulseaudio] authkey.c: Failed to load authentication key", |
Andrew Geissler | 595f630 | 2022-01-24 19:11:47 +0000 | [diff] [blame] | 67 | "was skipped because of a failed condition check", |
| 68 | "was skipped because all trigger condition checks failed", |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 69 | "xf86OpenConsole: Switching VT failed", |
Andrew Geissler | 87f5cff | 2022-09-30 13:13:31 -0500 | [diff] [blame^] | 70 | "Failed to read LoaderConfigTimeoutOneShot variable, ignoring: Operation not supported", |
| 71 | "Failed to read LoaderEntryOneShot variable, ignoring: Operation not supported", |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 72 | ] |
| 73 | |
| 74 | video_related = [ |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 75 | ] |
| 76 | |
| 77 | x86_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 Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 87 | 'Direct firmware load for regulatory.db', |
| 88 | 'failed to load regulatory.db', |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 89 | ] + common_errors |
| 90 | |
| 91 | qemux86_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 Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 96 | 'tsc: HPET/PMTIMER calibration failed', |
Brad Bishop | 79641f2 | 2019-09-10 07:20:22 -0400 | [diff] [blame] | 97 | "modeset(0): Failed to initialize the DRI2 extension", |
Brad Bishop | 79641f2 | 2019-09-10 07:20:22 -0400 | [diff] [blame] | 98 | "glamor initialization failed", |
Andrew Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame] | 99 | "blk_update_request: I/O error, dev fd0, sector 0 op 0x0:(READ)", |
| 100 | "floppy: error", |
Andrew Geissler | 5199d83 | 2021-09-24 16:47:35 -0500 | [diff] [blame] | 101 | 'failed to IDENTIFY (I/O error, err_mask=0x4)', |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 102 | ] + common_errors |
| 103 | |
| 104 | ignore_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 Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 114 | 'cacheinfo: Failed to find cpu0 device node', |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 115 | ] + common_errors, |
| 116 | 'qemumips64' : [ |
| 117 | 'pci 0000:00:00.0: [Firmware Bug]: reg 0x..: invalid BAR (can\'t size)', |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 118 | 'cacheinfo: Failed to find cpu0 device node', |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 119 | ] + 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 Geissler | 95ac1b8 | 2021-03-31 14:34:31 -0500 | [diff] [blame] | 128 | '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 Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 133 | 'qemuarmv5' : [ |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 134 | '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 Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 142 | 'OF: amba_device_add() failed (-19) for /amba/spi@101f4000', |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 143 | '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 Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 147 | 'clcd-pl11x: probe of 10120000.display failed with error -2', |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 148 | 'arm-charlcd 10008000.lcd: error -ENXIO: IRQ index 0 not found' |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 149 | ] + 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 Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 155 | 'logind: failed to get session seat', |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 156 | ] + common_errors, |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 157 | '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 Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 181 | 'Bluetooth: hci0: Failed to send firmware data (-38)', |
| 182 | 'atkbd serio0: Failed to enable keyboard on isa0060/serio0', |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 183 | ] + x86_common, |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 184 | '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 Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 194 | 'not creating \'/sys/firmware/fdt\'', |
| 195 | 'Failed to find cpu0 device node', |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 196 | 'Fatal server error:', |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 197 | '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 Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 207 | } |
| 208 | |
| 209 | log_locations = ["/var/log/","/var/log/dmesg", "/tmp/dmesg_output.log"] |
| 210 | |
| 211 | class 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 Geissler | 595f630 | 2022-01-24 19:11:47 +0000 | [diff] [blame] | 314 | grepcmd += r'\<' + error + r'\>' + '|' |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 315 | 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 Geissler | 595f630 | 2022-01-24 19:11:47 +0000 | [diff] [blame] | 325 | ignore_error = ignore_error.replace('(', r'\(') |
| 326 | ignore_error = ignore_error.replace(')', r'\)') |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 327 | ignore_error = ignore_error.replace("'", '.') |
Andrew Geissler | 595f630 | 2022-01-24 19:11:47 +0000 | [diff] [blame] | 328 | 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 Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 332 | 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 Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 357 | results[log] = {} |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 358 | 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 Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 367 | results[log][xrez]=grep_output |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 368 | |
| 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 Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 376 | @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) |