Merge ~cypressyew/qa-regression-testing:phlin/text-mode-for-config-gz into qa-regression-testing:master

Proposed by Po-Hsu Lin
Status: Merged
Merged at revision: ac459f23afcb6e94211fa9521cec53f497936723
Proposed branch: ~cypressyew/qa-regression-testing:phlin/text-mode-for-config-gz
Merge into: qa-regression-testing:master
Diff against target: 13 lines (+1/-1)
1 file modified
scripts/test-kernel-security.py (+1/-1)
Reviewer Review Type Date Requested Status
Steve Beattie Approve
Review via email: mp+443563@code.launchpad.net

Commit message

While testing J-xilinx kernel, all of the KernelSecurityConfigTests
are failing with:

Traceback (most recent call last):
  File "./test-kernel-security.py", line 2215, in test_010_kaslr_config
    self.assertKernelConfig('RANDOMIZE_BASE', expected)
  File "./test-kernel-security.py", line 231, in assertKernelConfig
    self.assertKernelConfigSet(name)
  File "./test-kernel-security.py", line 217, in assertKernelConfigSet
    self.assertTrue(self._test_config(name),
  File "./test-kernel-security.py", line 199, in _test_config
    setting = self._get_config(name)
  File "./test-kernel-security.py", line 193, in _get_config
    if line.startswith('CONFIG_%s=' % (name)):
TypeError: startswith first arg must be bytes or a tuple of bytes, not str

This is because the /proc/config.gz was not opened in text mode with
the python gzip module. Set it to 'rt' (text mode) to fix this issue.

To post a comment you must log in.
Revision history for this message
Po-Hsu Lin (cypressyew) wrote :

Please find the config.gz copied from the J-xilinx unit here:
https://people.canonical.com/~phlin/qrt/config.gz

Read it with:
import gzip
with gzip.open('config.gz', 'r') as f:
  content = f.readlines()

And check the content.

Revision history for this message
Steve Beattie (sbeattie) wrote :

Ack, sorry for the delay, merged.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/scripts/test-kernel-security.py b/scripts/test-kernel-security.py
2index ba1a5b3..61d662f 100755
3--- a/scripts/test-kernel-security.py
4+++ b/scripts/test-kernel-security.py
5@@ -172,7 +172,7 @@ class KernelSecurityBaseTest(testlib.TestlibCase):
6 def _open_config(self):
7 name = "/proc/config.gz"
8 if os.path.exists(name):
9- return gzip.open(name, "r")
10+ return gzip.open(name, "rt")
11 for name in ["/boot/config-%s" % (self.kernel_version),
12 "/boot/config"]:
13 if os.path.exists(name):

Subscribers

People subscribed via source and target branches