aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Fung <stevefung@google.com>2016-04-20 16:21:13 -0700
committerSteve Fung <stevefung@google.com>2016-04-20 16:21:21 -0700
commitaa9237ae7ff032eae67a2b1cf01bb8bfc5be8ff3 (patch)
treeaed7ccd35fd7ae9609fdd08d2169aae181306679
parent7c494df9a8338c874bcd5c42e6a46e197da8cfd0 (diff)
downloadbdk-aa9237ae7ff032eae67a2b1cf01bb8bfc5be8ff3.tar.gz
Fix style issues
Fix a few last style issues. Bug: 28007659 Test: `python test_runner.py` passes Test: pylint passes Change-Id: Ib559fa6192e662658e0290f7279a4c14d5a04454
-rw-r--r--cli/lib/core/image_build.py3
-rw-r--r--cli/lib/core/image_build_unittest.py146
2 files changed, 75 insertions, 74 deletions
diff --git a/cli/lib/core/image_build.py b/cli/lib/core/image_build.py
index a67c341..77aac2d 100644
--- a/cli/lib/core/image_build.py
+++ b/cli/lib/core/image_build.py
@@ -276,7 +276,8 @@ def CreateTargetCache(spec, target, cache_dir, mountpoint='/', update=True,
(('etc', 'fs_config_dirs'), sorted_dirs),
(('etc', 'fs_config_files'), fs_config_files.values()),
]
- # Walk the base names, create the file, then append any pre-existing content.
+ # Walk the base names, create the file, then append any pre-existing
+ # content.
for name, data in metadata_files:
data_file = os.path.join(cache_dir, *name)
tgt_file = os.path.join(cache_root, 'system', *name)
diff --git a/cli/lib/core/image_build_unittest.py b/cli/lib/core/image_build_unittest.py
index 1992e98..7d4b312 100644
--- a/cli/lib/core/image_build_unittest.py
+++ b/cli/lib/core/image_build_unittest.py
@@ -358,79 +358,79 @@ class CreateTargetCacheTest(TestData, unittest.TestCase):
'{}($|\n)'.format(self.copy.acl.fs_config(binary=True)))
def test_copy_system_with_custom_deep_file(self):
- # When copying a "system" pack, we rely on two sources of
- # ACL setting:
- # - compiled in fs_config values
- # - includes etc/fs_config_{files,dirs}
- # This test ensures that neither are overridden.
-
- # A custom file.
- self.copy.dst = '/system/bin/xyzzy.txt'
- self.copy.dst_type = pack.CopyType.FILE
- self.copy.acl.user = 1234
- self.copy.acl.group = 4321
-
- p = pack.Pack('brillo.{}'.format(self._BRILLO_VERSION), 'some_os_stuff')
- p.add_provides('os.core')
- p.add_copy(pack.Copy(p,
- dst='/system/bin/servicemanager', dst_type=pack.CopyType.FILE,
- src='/tmp/a_file', src_type=pack.CopyType.FILE))
- copy_servicemanager = p.copies[-1]
- copy_servicemanager.acl.override_build = False
- p.add_copy(pack.Copy(p,
- dst='/system/etc/fs_config_files', dst_type=pack.CopyType.FILE,
- src='/tmp/fs_config_files', src_type=pack.CopyType.FILE))
- copy_fs_config_files = p.copies[-1]
- copy_fs_config_files.acl.override_build = False
- p.add_copy(pack.Copy(p,
- dst='/system/etc/fs_config_dirs', dst_type=pack.CopyType.FILE,
- src='/tmp/fs_config_dirs', src_type=pack.CopyType.FILE))
- p.copies[-1].acl.override_build = False
-
- copies = p.copies + [self.copy]
- simple_map = packmap_stub.StubPackMap(
- destinations={copy.dst: [copy] for copy in copies})
- target = target_stub.StubTarget(
- os='brillo', os_version=self._BRILLO_VERSION, board=self._BSP,
- submaps=[simple_map])
- self.stub_sysroot_generator.should_makedirs = [
- self.stub_os.path.dirname(copy_servicemanager.dst)[1:],
- self.stub_os.path.dirname(copy_fs_config_files.dst)[1:]]
- self.stub_sysroot_generator.should_add_file = [
- (copy.src, copy.dst.lstrip('/')) for copy in copies
- ]
-
- # Needed for ensuring fs_config_files appending works.
- existing = self.stub_os.path.join(self.cache_dir, 'root', 'system',
- 'etc', 'fs_config_files')
- self.stub_os.path.should_exist.append(existing)
- system_fs_config_files = 'abc123'
- self.stub_open.files[existing] = stubs.StubFile(system_fs_config_files)
-
- existing = self.stub_os.path.join(self.cache_dir, 'root', 'system',
- 'etc', 'fs_config_dirs')
- self.stub_os.path.should_exist.append(existing)
- system_fs_config_dirs = '321bca'
- self.stub_open.files[existing] = stubs.StubFile(system_fs_config_dirs)
-
- image_build.CreateTargetCache(self.spec, target, self.cache_dir,
- mountpoint='/')
- # Ensure the ACLs were copied and the system fs_config_* are appended
- # to the build-specific changes.
- fs_config_files = self.stub_open.files[
- self.stub_os.path.join(self.cache_dir, 'etc',
- 'fs_config_files')].contents
- self.assertEqual(
- ['%\x00\x00\x01\xd2\x04\xe1\x10\x00\x00\x00\x00\x00\x00\x00\x00'
- 'system/bin/xyzzy.txt\x00',
- system_fs_config_files],
- fs_config_files)
- # Ensure that no directory ACLs were implicitly placed on
- # system or system/bin/.
- fs_config_dirs = self.stub_open.files[
- self.stub_os.path.join(self.cache_dir, 'etc',
- 'fs_config_dirs')].contents
- self.assertEqual(fs_config_dirs, ['', system_fs_config_dirs])
+ # When copying a "system" pack, we rely on two sources of
+ # ACL setting:
+ # - compiled in fs_config values
+ # - includes etc/fs_config_{files,dirs}
+ # This test ensures that neither are overridden.
+
+ # A custom file.
+ self.copy.dst = '/system/bin/xyzzy.txt'
+ self.copy.dst_type = pack.CopyType.FILE
+ self.copy.acl.user = 1234
+ self.copy.acl.group = 4321
+
+ p = pack.Pack('brillo.{}'.format(self._BRILLO_VERSION), 'some_os_stuff')
+ p.add_provides('os.core')
+ p.add_copy(pack.Copy(
+ p, dst='/system/bin/servicemanager', dst_type=pack.CopyType.FILE,
+ src='/tmp/a_file', src_type=pack.CopyType.FILE))
+ copy_servicemanager = p.copies[-1]
+ copy_servicemanager.acl.override_build = False
+ p.add_copy(pack.Copy(
+ p, dst='/system/etc/fs_config_files', dst_type=pack.CopyType.FILE,
+ src='/tmp/fs_config_files', src_type=pack.CopyType.FILE))
+ copy_fs_config_files = p.copies[-1]
+ copy_fs_config_files.acl.override_build = False
+ p.add_copy(pack.Copy(
+ p, dst='/system/etc/fs_config_dirs', dst_type=pack.CopyType.FILE,
+ src='/tmp/fs_config_dirs', src_type=pack.CopyType.FILE))
+ p.copies[-1].acl.override_build = False
+
+ copies = p.copies + [self.copy]
+ simple_map = packmap_stub.StubPackMap(
+ destinations={copy.dst: [copy] for copy in copies})
+ target = target_stub.StubTarget(
+ os='brillo', os_version=self._BRILLO_VERSION, board=self._BSP,
+ submaps=[simple_map])
+ self.stub_sysroot_generator.should_makedirs = [
+ self.stub_os.path.dirname(copy_servicemanager.dst)[1:],
+ self.stub_os.path.dirname(copy_fs_config_files.dst)[1:]]
+ self.stub_sysroot_generator.should_add_file = [
+ (copy_.src, copy_.dst.lstrip('/')) for copy_ in copies
+ ]
+
+ # Needed for ensuring fs_config_files appending works.
+ existing = self.stub_os.path.join(self.cache_dir, 'root', 'system',
+ 'etc', 'fs_config_files')
+ self.stub_os.path.should_exist.append(existing)
+ system_fs_config_files = 'abc123'
+ self.stub_open.files[existing] = stubs.StubFile(system_fs_config_files)
+
+ existing = self.stub_os.path.join(self.cache_dir, 'root', 'system',
+ 'etc', 'fs_config_dirs')
+ self.stub_os.path.should_exist.append(existing)
+ system_fs_config_dirs = '321bca'
+ self.stub_open.files[existing] = stubs.StubFile(system_fs_config_dirs)
+
+ image_build.CreateTargetCache(self.spec, target, self.cache_dir,
+ mountpoint='/')
+ # Ensure the ACLs were copied and the system fs_config_* are appended
+ # to the build-specific changes.
+ fs_config_files = self.stub_open.files[
+ self.stub_os.path.join(self.cache_dir, 'etc',
+ 'fs_config_files')].contents
+ self.assertEqual(
+ ['%\x00\x00\x01\xd2\x04\xe1\x10\x00\x00\x00\x00\x00\x00\x00\x00'
+ 'system/bin/xyzzy.txt\x00',
+ system_fs_config_files],
+ fs_config_files)
+ # Ensure that no directory ACLs were implicitly placed on
+ # system or system/bin/.
+ fs_config_dirs = self.stub_open.files[
+ self.stub_os.path.join(self.cache_dir, 'etc',
+ 'fs_config_dirs')].contents
+ self.assertEqual(fs_config_dirs, ['', system_fs_config_dirs])
def test_copy_glob(self):
self.copy.src = '/my/bins/*'