Skip to contentSkip to conversation

sstatetests: Use python function instead of bitbake-diffsigs script

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

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH 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 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 | 6 ++++++
 1 file changed, 6 insertions(+)
meta/lib/oeqa/selftest/cases/sstatetests.py +6 -0
index 0b36027918..695e2a86d5 100644
@@ -468,9 +468,15 @@ http_proxy = "http://example.com/"
             # No changes, so we're done
             return
 
+        i_sigfile, max_sigfiles_to_compare = 0, 20
         for k in files1.keys() | files2.keys():
             if k in files1 and k in files2:
+                i_sigfile += 1
                 print("%s differs:" % k)
+                # this is an expensive computation, thus just compare the first
+                # 'max_sigfiles_to_compare' k files
+                if i_sigfile > max_sigfiles_to_compare:
+                    continue
                 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)
Signature · 1 line
2.12.3
#2 lore raw

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

Quoted 11 lines · On 4 August 2017 at 19:57, <[email protected]> wrote:
meta/lib/oeqa/selftest/cases/sstatetests.py +3 -0
+        i_sigfile, max_sigfiles_to_compare = 0, 20
         for k in files1.keys() | files2.keys():
             if k in files1 and k in files2:
+                i_sigfile += 1
                 print("%s differs:" % k)
+                # this is an expensive computation, thus just compare the

first

meta/lib/oeqa/selftest/cases/sstatetests.py +3 -0
+                # 'max_sigfiles_to_compare' k files
+                if i_sigfile > max_sigfiles_to_compare:
+                    continue
                 sigdatafile1 = self.topdir +
Quoted 6 lines

"/tmp-sstatesamehash/stamps/" + k + "." + files1[k]
sigdatafile2 = self.topdir +
"/tmp-sstatesamehash2/stamps/" + k + "." + files2[k]
output = bb.siggen.compare_sigfiles(sigdatafile1,
sigdatafile2)

A neater way to do this:

-for k in files1.keys() | files2.keys():
+for k in list(files1.keys() | files2.key())[:20];

(take the union of the files1 and files2 keys, turn it into a list, and slice off up to the first 20)

Ross

#3 lore raw

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

Quoted 25 lines · Ross

On 4 August 2017 at 19:57, <[email protected]> wrote:
+ i_sigfile, max_sigfiles_to_compare = 0, 20
for k in files1.keys() | files2.keys():
if k in files1 and k in files2:
+ i_sigfile += 1
print("%s differs:" % k)
+ # this is an expensive computation, thus just
compare the first
+ # 'max_sigfiles_to_compare' k files
+ if i_sigfile > max_sigfiles_to_compare:
+ continue
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)

A neater way to do this:

Review

Quoted 2 lines
(quoted diff) +1 -1
-for k in files1.keys() | files2.keys():
+for k in list(files1.keys() | files2.key())[:20];

yes, but we this way, we are not listing those > 20 and I believe this is important. This fix just diffsigs the first 20, and the rest are just listed for convenience.

also, sets are not 'subscriptable' thus slicing is not possible on sets.

Leo

Quoted 5 lines

(take the union of the files1 and files2 keys, turn it into a list, and slice off up to the first 20)

Ross

#4 lore raw

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

Quoted 4 lines · Leonardo Sandoval

yes, but we this way, we are not listing those > 20 and I believe this is important. This fix just diffsigs the first 20, and the rest are just listed for convenience.

Good point. You could neatly print the filenames in one iteration, and then the first 20 diffs in another loop.

also, sets are not 'subscriptable' thus slicing is not possible on sets.

Quoted 1 line

Which is why I called list() before slicing.

Ross

#5 lore raw

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

Quoted 11 lines · Ross

On 7 August 2017 at 18:06, Leonardo Sandoval <[email protected]> wrote:
yes, but we this way, we are not listing those > 20 and I believe this
is important. This fix just diffsigs the first 20, and the rest are just
listed for convenience.

Good point. You could neatly print the filenames in one iteration, and then the first 20 diffs in another loop.

not super convinced but yes, that can be a another way to avoid the if inside the for body. I will send a v2.

Leo

Quoted 10 lines

also, sets are not 'subscriptable' thus slicing is not possible on sets.

Which is why I called list() before slicing.

Ross