summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/selftest/cases/oelib
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2020-06-03 16:01:02 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2020-06-15 14:53:45 +0100
commiteb226b897fcba0ec1d94e15957e714d241931813 (patch)
tree585b5623a6b52bf9868e19801b78512ce21ea5fc /meta/lib/oeqa/selftest/cases/oelib
parent26ae42ded7f2a59f7ccc8e8e8b763b4613a2bbdb (diff)
downloadpoky-eb226b897fcba0ec1d94e15957e714d241931813.tar.gz
buildhistory: Add simplistic file move detection
We'd like to use buildhistory more during patch review however its proving hard, particularly where whole subtrees of files move, such as a kernel version upgrade, or where a software module moves include directory. This adds file rename matching which covers our common case of library moves, kernel upgrades and more. A new test case is also added so that someone in the future can change the code and test the logic is still doing the expected things. (From OE-Core rev: 791ce304f5e066759874beac0feef5ee62a1c255) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oeqa/selftest/cases/oelib')
-rw-r--r--meta/lib/oeqa/selftest/cases/oelib/buildhistory.py46
1 files changed, 46 insertions, 0 deletions
diff --git a/meta/lib/oeqa/selftest/cases/oelib/buildhistory.py b/meta/lib/oeqa/selftest/cases/oelib/buildhistory.py
index d4664bd0df..802a91a488 100644
--- a/meta/lib/oeqa/selftest/cases/oelib/buildhistory.py
+++ b/meta/lib/oeqa/selftest/cases/oelib/buildhistory.py
@@ -5,6 +5,7 @@
5import os 5import os
6from oeqa.selftest.case import OESelftestTestCase 6from oeqa.selftest.case import OESelftestTestCase
7import tempfile 7import tempfile
8import operator
8from oeqa.utils.commands import get_bb_var 9from oeqa.utils.commands import get_bb_var
9 10
10class TestBlobParsing(OESelftestTestCase): 11class TestBlobParsing(OESelftestTestCase):
@@ -97,3 +98,48 @@ class TestBlobParsing(OESelftestTestCase):
97 var_changes[x.fieldname] = (oldvalue, x.newvalue) 98 var_changes[x.fieldname] = (oldvalue, x.newvalue)
98 99
99 self.assertEqual(defaultmap, var_changes, "Defaults not set properly") 100 self.assertEqual(defaultmap, var_changes, "Defaults not set properly")
101
102class TestFileListCompare(OESelftestTestCase):
103
104 def test_compare_file_lists(self):
105 # Test that a directory tree that moves location such as /lib/modules/5.4.40-yocto-standard -> /lib/modules/5.4.43-yocto-standard
106 # is correctly identified as a move
107 from oe.buildhistory_analysis import compare_file_lists, FileChange
108
109 with open(self.tc.files_dir + "/buildhistory_filelist1.txt", "r") as f:
110 filelist1 = f.readlines()
111 with open(self.tc.files_dir + "/buildhistory_filelist2.txt", "r") as f:
112 filelist2 = f.readlines()
113
114 expectedResult = [
115 '/lib/libcap.so.2 changed symlink target from libcap.so.2.33 to libcap.so.2.34',
116 '/lib/libcap.so.2.33 moved to /lib/libcap.so.2.34',
117 '/lib/modules/5.4.40-yocto-standard moved to /lib/modules/5.4.43-yocto-standard',
118 '/lib/modules/5.4.43-yocto-standard/modules.builtin.alias.bin was added',
119 '/usr/bin/gawk-5.0.1 moved to /usr/bin/gawk-5.1.0',
120 '/usr/lib/libbtrfsutil.so changed symlink target from libbtrfsutil.so.1.1.1 to libbtrfsutil.so.1.2.0',
121 '/usr/lib/libbtrfsutil.so.1 changed symlink target from libbtrfsutil.so.1.1.1 to libbtrfsutil.so.1.2.0',
122 '/usr/lib/libbtrfsutil.so.1.1.1 moved to /usr/lib/libbtrfsutil.so.1.2.0',
123 '/usr/lib/libkmod.so changed symlink target from libkmod.so.2.3.4 to libkmod.so.2.3.5',
124 '/usr/lib/libkmod.so.2 changed symlink target from libkmod.so.2.3.4 to libkmod.so.2.3.5',
125 '/usr/lib/libkmod.so.2.3.4 moved to /usr/lib/libkmod.so.2.3.5',
126 '/usr/lib/libpixman-1.so.0 changed symlink target from libpixman-1.so.0.38.4 to libpixman-1.so.0.40.0',
127 '/usr/lib/libpixman-1.so.0.38.4 moved to /usr/lib/libpixman-1.so.0.40.0',
128 '/usr/lib/opkg/alternatives/rtcwake was added',
129 '/usr/lib/python3.8/site-packages/PyGObject-3.34.0.egg-info moved to /usr/lib/python3.8/site-packages/PyGObject-3.36.1.egg-info',
130 '/usr/lib/python3.8/site-packages/btrfsutil-1.1.1-py3.8.egg-info moved to /usr/lib/python3.8/site-packages/btrfsutil-1.2.0-py3.8.egg-info',
131 '/usr/lib/python3.8/site-packages/pycairo-1.19.0.egg-info moved to /usr/lib/python3.8/site-packages/pycairo-1.19.1.egg-info',
132 '/usr/sbin/rtcwake changed type from file to symlink',
133 '/usr/sbin/rtcwake changed permissions from rwxr-xr-x to rwxrwxrwx',
134 '/usr/sbin/rtcwake changed symlink target from None to /usr/sbin/rtcwake.util-linux',
135 '/usr/sbin/rtcwake.util-linux was added'
136 ]
137
138 result = compare_file_lists(filelist1, filelist2)
139 rendered = []
140 for entry in sorted(result, key=operator.attrgetter("path")):
141 rendered.append(str(entry))
142
143 self.maxDiff = None
144 self.assertCountEqual(rendered, expectedResult)
145