summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIsaac J. Manjarres <isaacmanjarres@google.com>2024-02-16 10:42:19 -0800
committerAndroid Build Cherrypicker Worker <android-build-cherrypicker-worker@google.com>2024-02-22 02:06:42 +0000
commite1990202a6f1bc731600e65310da78b33ae5edac (patch)
tree9881ed0e8e57ecf9c498d0b87f3cda394bc1e19e
parentf6c0c2b7da5ccca93ffc0f34540c14e65520a184 (diff)
downloadbuild-e1990202a6f1bc731600e65310da78b33ae5edac.tar.gz
kleaf: Fix initramfs modules lists test
The initramfs modules lists test is currently not comparing the lists for equality; it is merely doing a check for None == None, which is vacuously true. This is because the assertion compares the return values of the sort() method on two lists. The sort() method does not return anything, and instead sorts the lists in place, so use the assertCountEqual() method instead, so that the order of the lists is not a concern. Also, fix whitespace issues and coding style when reading the lists. Fixes: Fixes: d08605f4c795 ("kleaf: Add support for specifying modules for recovery/charger") Bug: 266752750 Signed-off-by: Isaac J. Manjarres <isaacmanjarres@google.com> (cherry picked from https://android-review.googlesource.com/q/commit:3c47d6386f4a502272913d00e18b8b62c9fba9ef) Merged-In: I6582bcc04efa5542725ca9be4df420b12919ebe0 Change-Id: I6582bcc04efa5542725ca9be4df420b12919ebe0
-rw-r--r--kleaf/artifact_tests/initramfs_modules_lists_test.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/kleaf/artifact_tests/initramfs_modules_lists_test.py b/kleaf/artifact_tests/initramfs_modules_lists_test.py
index ac31d0c..7129255 100644
--- a/kleaf/artifact_tests/initramfs_modules_lists_test.py
+++ b/kleaf/artifact_tests/initramfs_modules_lists_test.py
@@ -66,9 +66,9 @@ class InitramfsModulesLists(unittest.TestCase):
with open(modules_load_path) as modules_load_file, \
open(expected_modules_list_path) as expected_modules_list_file:
- modules_load_lines = [os.path.basename(f) for f in modules_load_file.readlines()]
- expected_modules_list_lines = expected_modules_list_file.readlines()
- self.assertEqual(modules_load_lines.sort(), expected_modules_list_lines.sort())
+ modules_load_lines = [os.path.basename(line).strip() for line in modules_load_file]
+ expected_modules_list_lines = [line.strip() for line in expected_modules_list_file]
+ self.assertCountEqual(modules_load_lines, expected_modules_list_lines)
def test_diff(self):
initramfs_list = [f for f in arguments.files if os.path.basename(f) == "initramfs.img"]