Merge ~canonical-kernel-team/+git/autotest-client-tests:phlin/bt-log-core into ~canonical-kernel-team/+git/autotest-client-tests:master

Proposed by Po-Hsu Lin
Status: Merged
Merge reported by: Po-Hsu Lin
Merged at revision: 44d89f3898428532e29fdbc15df23e5c52de1bd9
Proposed branch: ~canonical-kernel-team/+git/autotest-client-tests:phlin/bt-log-core
Merge into: ~canonical-kernel-team/+git/autotest-client-tests:master
Diff against target: 29 lines (+10/-5)
1 file modified
ubuntu_boot/ubuntu_boot.py (+10/-5)
Reviewer Review Type Date Requested Status
Francis Ginther Approve
Review via email: mp+465563@code.launchpad.net

Commit message

KERNTT-464
Add support to read log from journalctl, so that the log check test can
be run on Ubuntu Core systems.

To post a comment you must log in.
Revision history for this message
Francis Ginther (fginther) wrote :

Changes look reasonable. Have you been able to catch one of these issues on a core system to ensure that this test will correctly fail?

review: Approve
Revision history for this message
Po-Hsu Lin (cypressyew) wrote :

No, I use a Google n2d-standard-64 instance (which is expected to raise WARNING in syslog) with Focal to test the regex.

In syslog:
May 7 01:50:37 f-l-gen-s2-n2dstd64-u-boot kernel: [ 181.772052] nvme 0000:00:04.0: overflow 0x0008003edbbac000+262144 of DMA mask ffffffffffffffff bus mask 0
May 7 01:50:37 f-l-gen-s2-n2dstd64-u-boot kernel: [ 181.781746] ------------[ cut here ]------------
May 7 01:50:37 f-l-gen-s2-n2dstd64-u-boot kernel: [ 181.781750] WARNING: CPU: 58 PID: 3002 at kernel/dma/direct.c:35 report_addr+0x37/0x60

From journalctl:
May 07 01:50:37 f-l-gen-s2-n2dstd64-u-boot kernel: ------------[ cut here ]------------
May 07 01:50:37 f-l-gen-s2-n2dstd64-u-boot kernel: WARNING: CPU: 58 PID: 3002 at kernel/dma/direct.c:35 report_addr+0x37/0x60

This has been tested by removing the /var/log/syslog to force it to use journalctl:
02:08:33 DEBUG| Running 'journalctl -k > /tmp/journalctl-syslog'
02:08:33 INFO | Checking error message in /tmp/journalctl-syslog:
02:08:33 INFO | Scanning for pattern "kernel:( \[ *\d+\.\d+\])? BUG:.*"
02:08:33 INFO | PASSED, log clean.
02:08:33 INFO | Scanning for pattern "kernel:( \[ *\d+\.\d+\])? Oops:.*"
02:08:33 INFO | PASSED, log clean.
02:08:33 INFO | Scanning for pattern "kernel:( \[ *\d+\.\d+\])? kernel BUG at.*"
02:08:33 INFO | PASSED, log clean.
02:08:33 INFO | Scanning for pattern "kernel:( \[ *\d+\.\d+\])? WARNING:.*"
02:08:33 INFO | Pattern found. Matching lines as follows:
02:08:33 INFO | kernel: WARNING: CPU: 58 PID: 3002 at kernel/dma/direct.c:35 report_addr+0x37/0x60

I will amend the commit message to make it more clear.

Revision history for this message
Po-Hsu Lin (cypressyew) wrote :

Commit message amended to:
    KERNTT-464
    Add support to read log from journalctl, so that the log check test can
    be run on Ubuntu Core systems.

    The regex must be modified. Here is an example of WARNING taken from
    the syslog of a Google n2d-standard-64 instance:

      May 7 01:50:37 f-l-gen-s2-n2dstd64-u-boot kernel: [ 181.781750] WARNING: CPU: 58 PID: 3002 at kernel/dma/direct.c:35 report_addr+0x37/0x60

    Here is the output of journalctl on this instance:

      May 07 01:50:37 f-l-gen-s2-n2dstd64-u-boot kernel: WARNING: CPU: 58 PID: 3002 at kernel/dma/direct.c:35 report_addr+0x37/0x60

    I have this code test on this instance by removing /var/log/syslog to
    force it to use journalctl output and it's failing as expected:

      Running 'journalctl -k > /tmp/journalctl-syslog'
      Checking error message in /tmp/journalctl-syslog:
      Scanning for pattern "kernel:( \[ *\d+\.\d+\])? BUG:.*"
      PASSED, log clean.
      Scanning for pattern "kernel:( \[ *\d+\.\d+\])? Oops:.*"
      PASSED, log clean.
      Scanning for pattern "kernel:( \[ *\d+\.\d+\])? kernel BUG at.*"
      PASSED, log clean.
      Scanning for pattern "kernel:( \[ *\d+\.\d+\])? WARNING:.*"
      Pattern found. Matching lines as follows:
      kernel: WARNING: CPU: 58 PID: 3002 at kernel/dma/direct.c:35 report_addr+0x37/0x60

Applied and pushed, thanks!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/ubuntu_boot/ubuntu_boot.py b/ubuntu_boot/ubuntu_boot.py
2index 93068c6..2d813e0 100644
3--- a/ubuntu_boot/ubuntu_boot.py
4+++ b/ubuntu_boot/ubuntu_boot.py
5@@ -28,14 +28,19 @@ class ubuntu_boot(test.test):
6 else:
7 logfile = '/var/log/syslog'
8 patterns = [
9- 'kernel: \[ *\d+\.\d+\] BUG:.*',
10- 'kernel: \[ *\d+\.\d+\] Oops:.*',
11- 'kernel: \[ *\d+\.\d+\] kernel BUG at.*',
12- 'kernel: \[ *\d+\.\d+\] WARNING:.*'
13+ 'kernel:( \[ *\d+\.\d+\])? BUG:.*',
14+ 'kernel:( \[ *\d+\.\d+\])? Oops:.*',
15+ 'kernel:( \[ *\d+\.\d+\])? kernel BUG at.*',
16+ 'kernel:( \[ *\d+\.\d+\])? WARNING:.*'
17 ]
18 test_passed = True
19- print('Checking error message in {}:'.format(logfile))
20+ if not os.path.exists(logfile):
21+ # Hack for systems without syslog (Ubuntu Core)
22+ logfile = '/tmp/journalctl-syslog'
23+ utils.system('journalctl -k > {}'.format(logfile))
24+
25 if os.path.exists(logfile):
26+ print('Checking error message in {}:'.format(logfile))
27 with open(logfile) as f:
28 content = f.read()
29 for pat in patterns:

Subscribers

People subscribed via source and target branches

to all changes: