diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-11-13 00:20:25 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-11-13 00:20:25 +0000 |
commit | 517424dcc11380511bc34f4a081f119104ff9e80 (patch) | |
tree | 77dc031614745bb406dbd90cea9a082a1b5cdd54 /llvm_tools/chroot_unittest.py | |
parent | 4d310bf178aa94bdc46c1b86b9937312ddac644a (diff) | |
parent | 40214b48188358a80b7478bfff21d4814dd9177c (diff) | |
download | toolchain-utils-android14-gsi.tar.gz |
Snap for 9286241 from 40214b48188358a80b7478bfff21d4814dd9177c to udc-releaseandroid-vts-14.0_r4android-vts-14.0_r3android-vts-14.0_r2android-vts-14.0_r1android-security-14.0.0_r9android-security-14.0.0_r8android-security-14.0.0_r7android-security-14.0.0_r6android-security-14.0.0_r5android-security-14.0.0_r4android-security-14.0.0_r3android-security-14.0.0_r2android-security-14.0.0_r1android-platform-14.0.0_r1android-cts-14.0_r4android-cts-14.0_r3android-cts-14.0_r2android-cts-14.0_r1android-14.0.0_r28android-14.0.0_r2android-14.0.0_r15android-14.0.0_r14android-14.0.0_r13android-14.0.0_r1android14-tests-releaseandroid14-security-releaseandroid14-s2-releaseandroid14-s1-releaseandroid14-releaseandroid14-platform-releaseandroid14-gsi
Change-Id: I709f9d23cce32c5c2c81fc2d5869983d17b416ed
Diffstat (limited to 'llvm_tools/chroot_unittest.py')
-rwxr-xr-x | llvm_tools/chroot_unittest.py | 75 |
1 files changed, 41 insertions, 34 deletions
diff --git a/llvm_tools/chroot_unittest.py b/llvm_tools/chroot_unittest.py index 5eec5675..f1a6a626 100755 --- a/llvm_tools/chroot_unittest.py +++ b/llvm_tools/chroot_unittest.py @@ -1,12 +1,11 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- -# Copyright 2020 The Chromium OS Authors. All rights reserved. +# Copyright 2020 The ChromiumOS Authors # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. """Unit tests for chroot helper functions.""" -from __future__ import print_function import subprocess import unittest @@ -14,53 +13,61 @@ import unittest.mock as mock import chroot + # These are unittests; protected access is OK to a point. # pylint: disable=protected-access class HelperFunctionsTest(unittest.TestCase): - """Test class for updating LLVM hashes of packages.""" + """Test class for updating LLVM hashes of packages.""" - @mock.patch.object(subprocess, 'check_output') - def testSucceedsToGetChrootEbuildPathForPackage(self, mock_chroot_command): - package_chroot_path = '/chroot/path/to/package.ebuild' + @mock.patch.object(subprocess, "check_output") + def testSucceedsToGetChrootEbuildPathForPackage(self, mock_chroot_command): + package_chroot_path = "/chroot/path/to/package.ebuild" - # Emulate ChrootRunCommandWOutput behavior when a chroot path is found for - # a valid package. - mock_chroot_command.return_value = package_chroot_path + # Emulate ChrootRunCommandWOutput behavior when a chroot path is found for + # a valid package. + mock_chroot_command.return_value = package_chroot_path - chroot_path = '/test/chroot/path' - package_list = ['new-test/package'] + chroot_path = "/test/chroot/path" + package_list = ["new-test/package"] - self.assertEqual( - chroot.GetChrootEbuildPaths(chroot_path, package_list), - [package_chroot_path]) + self.assertEqual( + chroot.GetChrootEbuildPaths(chroot_path, package_list), + [package_chroot_path], + ) - mock_chroot_command.assert_called_once() + mock_chroot_command.assert_called_once() - def testFailedToConvertChrootPathWithInvalidPrefix(self): - chroot_path = '/path/to/chroot' - chroot_file_path = '/src/package.ebuild' + def testFailedToConvertChrootPathWithInvalidPrefix(self): + chroot_path = "/path/to/chroot" + chroot_file_path = "/src/package.ebuild" - # Verify the exception is raised when a chroot path does not have the prefix - # '/mnt/host/source/'. - with self.assertRaises(ValueError) as err: - chroot.ConvertChrootPathsToAbsolutePaths(chroot_path, [chroot_file_path]) + # Verify the exception is raised when a chroot path does not have the prefix + # '/mnt/host/source/'. + with self.assertRaises(ValueError) as err: + chroot.ConvertChrootPathsToAbsolutePaths( + chroot_path, [chroot_file_path] + ) - self.assertEqual( - str(err.exception), 'Invalid prefix for the chroot path: ' - '%s' % chroot_file_path) + self.assertEqual( + str(err.exception), + "Invalid prefix for the chroot path: " "%s" % chroot_file_path, + ) - def testSucceedsToConvertChrootPathToAbsolutePath(self): - chroot_path = '/path/to/chroot' - chroot_file_paths = ['/mnt/host/source/src/package.ebuild'] + def testSucceedsToConvertChrootPathToAbsolutePath(self): + chroot_path = "/path/to/chroot" + chroot_file_paths = ["/mnt/host/source/src/package.ebuild"] - expected_abs_path = '/path/to/chroot/src/package.ebuild' + expected_abs_path = "/path/to/chroot/src/package.ebuild" - self.assertEqual( - chroot.ConvertChrootPathsToAbsolutePaths( - chroot_path, chroot_file_paths), [expected_abs_path]) + self.assertEqual( + chroot.ConvertChrootPathsToAbsolutePaths( + chroot_path, chroot_file_paths + ), + [expected_abs_path], + ) -if __name__ == '__main__': - unittest.main() +if __name__ == "__main__": + unittest.main() |