Skip to contentSkip to conversation

sstatetests: Use python function instead of bitbake-diffsigs script

PATCH Superseded [email protected] 2 participants 4 messages Aug 7, 2017 – Aug 8, 2017

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/2 sstatetests: Use python function instead of bitbake-diffsigs script

From: Leonardo Sandoval <[email protected]>

Using a python function instead of launching a subprocess fasten the diffsigs computation.

[YOCTO #11651]

---
 meta/lib/oeqa/selftest/cases/sstatetests.py | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
meta/lib/oeqa/selftest/cases/sstatetests.py +7 -3
index 07a206824a..0b36027918 100644
@@ -8,6 +8,8 @@ from oeqa.utils.commands import runCmd, bitbake, get_bb_var, get_test_layer
 from oeqa.selftest.cases.sstate import SStateBase
 from oeqa.core.decorator.oeid import OETestID
 
+import bb.siggen
+
 class SStateTests(SStateBase):
 
     # Test sstate files creation and their location
@@ -469,9 +471,11 @@ http_proxy = "http://example.com/"
         for k in files1.keys() | files2.keys():
             if k in files1 and k in files2:
                 print("%s differs:" % k)
-                print(subprocess.check_output(("bitbake-diffsigs",
-                                               self.topdir + "/tmp-sstatesamehash/stamps/" + k + "." + files1[k],
-                                               self.topdir + "/tmp-sstatesamehash2/stamps/" + k + "." + files2[k])))
+                sigdatafile1 = self.topdir + "/tmp-sstatesamehash/stamps/" + k + "." + files1[k]
+                sigdatafile2 = self.topdir + "/tmp-sstatesamehash2/stamps/" + k + "." + files2[k]
+                output = bb.siggen.compare_sigfiles(sigdatafile1, sigdatafile2)
+                if output:
+                    print('\n'.join(output))
             elif k in files1 and k not in files2:
                 print("%s in files1" % k)
             elif k not in files1 and k in files2:
Signature · 1 line
2.12.3
#1 lore raw

PATCH v3 2/2 sstatetests: limit the number of signature comparisons when differ

From: Leonardo Sandoval <[email protected]>

For perfomance reasons, limit the number of signature comparisons when stamps differ. The limit set is hardcoded to 20.

[YOCTO #11651]

---
 meta/lib/oeqa/selftest/cases/sstatetests.py | 40 +++++++++++++++++++----------
 1 file changed, 26 insertions(+), 14 deletions(-)
meta/lib/oeqa/selftest/cases/sstatetests.py +26 -14
index 0b36027918..6298443a18 100644
@@ -458,6 +458,25 @@ http_proxy = "http://example.com/"
                     base = os.sep.join(root.rsplit(os.sep, 2)[-2:] + [name])
                     f[base] = shash
             return f
+
+        def compare_sigfiles(files, files1, files2, compare=False):
+            for k in files:
+                if k in files1 and k in files2:
+                    i_sigfile += 1
+                    print("%s differs:" % k)
+                    if compare:
+                        sigdatafile1 = self.topdir + "/tmp-sstatesamehash/stamps/" + k + "." + files1[k]
+                        sigdatafile2 = self.topdir + "/tmp-sstatesamehash2/stamps/" + k + "." + files2[k]
+                        output = bb.siggen.compare_sigfiles(sigdatafile1, sigdatafile2)
+                        if output:
+                            print('\n'.join(output))
+                elif k in files1 and k not in files2:
+                    print("%s in files1" % k)
+                elif k not in files1 and k in files2:
+                    print("%s in files2" % k)
+                else:
+                    assert "shouldn't reach here"
+
         files1 = get_files(self.topdir + "/tmp-sstatesamehash/stamps/")
         files2 = get_files(self.topdir + "/tmp-sstatesamehash2/stamps/")
         # Remove items that are identical in both sets
@@ -468,18 +487,11 @@ http_proxy = "http://example.com/"
             # No changes, so we're done
             return
 
-        for k in files1.keys() | files2.keys():
-            if k in files1 and k in files2:
-                print("%s differs:" % k)
-                sigdatafile1 = self.topdir + "/tmp-sstatesamehash/stamps/" + k + "." + files1[k]
-                sigdatafile2 = self.topdir + "/tmp-sstatesamehash2/stamps/" + k + "." + files2[k]
-                output = bb.siggen.compare_sigfiles(sigdatafile1, sigdatafile2)
-                if output:
-                    print('\n'.join(output))
-            elif k in files1 and k not in files2:
-                print("%s in files1" % k)
-            elif k not in files1 and k in files2:
-                print("%s in files2" % k)
-            else:
-                assert "shouldn't reach here"
+        files = list(files1.keys() | files2.keys())
+        # this is an expensive computation, thus just compare the first 'max_sigfiles_to_compare' k files
+        max_sigfiles_to_compare = 20
+        first, rest = files[:max_sigfiles_to_compare], files[max_sigfiles_to_compare:]
+        compare_sigfiles(first, files1.keys(), files2.keys(), compare=True)
+        compare_sigfiles(rest, files1.keys(), files2.keys(), compare=False)
+
         self.fail("sstate hashes not identical.")
Signature · 1 line
2.12.3
#2 lore raw

Re: [PATCH v3 2/2] sstatetests: limit the number of signature comparisons when differ

Quoted 20 lines · On 7 August 2017 at 22:33, <[email protected]> wrote:

From: Leonardo Sandoval <[email protected]>

For perfomance reasons, limit the number of signature comparisons when stamps differ. The limit set is hardcoded to 20.

[YOCTO #11651]

linux.intel.com>

---
 meta/lib/oeqa/selftest/cases/sstatetests.py | 40
+++++++++++++++++++----------
 1 file changed, 26 insertions(+), 14 deletions(-)
meta/lib/oeqa/selftest/cases/sstatetests.py +0 -0
index 0b36027918..6298443a18 100644

meta/lib/oeqa/selftest/cases/sstatetests.py http_proxy = "http://example.com/" · line 467

Quoted 10 lines
meta/lib/oeqa/selftest/cases/sstatetests.py +5 -0
@@ -458,6 +458,25 @@ http_proxy = "http://example.com/"
                     base = os.sep.join(root.rsplit(os.sep, 2)[-2:] +
 [name])
                     f[base] = shash
             return f
+
+        def compare_sigfiles(files, files1, files2, compare=False):
+            for k in files:
+                if k in files1 and k in files2:
+                    i_sigfile += 1
 

Surely this is going to produce an i_sigfile is not defined error?

Ross

#3 lore raw

Re: [PATCH v3 2/2] sstatetests: limit the number of signature comparisons when differ

Quoted 36 lines · Ross

On 7 August 2017 at 22:33, <[email protected]> wrote:
From: Leonardo Sandoval <[email protected]>

For perfomance reasons, limit the number of signature comparisons when
stamps differ. The limit set is hardcoded to 20.

[YOCTO #11651]

Signed-off-by: Leonardo Sandoval <[email protected]>
---
meta/lib/oeqa/selftest/cases/sstatetests.py | 40
+++++++++++++++++++----------
1 file changed, 26 insertions(+), 14 deletions(-)

diff --git a/meta/lib/oeqa/selftest/cases/sstatetests.py b/meta/lib/oeqa/selftest/cases/sstatetests.py index 0b36027918..6298443a18 100644
--- a/meta/lib/oeqa/selftest/cases/sstatetests.py +++ b/meta/lib/oeqa/selftest/cases/sstatetests.py @@ -458,6 +458,25 @@ http_proxy = "http://example.com/"
base = os.sep.join(root.rsplit(os.sep,
2)[-2:] + [name])
f[base] = shash
return f
+
+ def compare_sigfiles(files, files1, files2,
compare=False):
+ for k in files:
+ if k in files1 and k in files2:
+ i_sigfile += 1

Quoted 1 line

Surely this is going to produce an i_sigfile is not defined error?

Right, I forgot to remove that line and test it properly. Will send another revision.

Leo

Quoted 3 lines

Ross