public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
From: Uladzimir Bely <ubely@ilbers.de>
To: isar-users@googlegroups.com
Subject: [PATCH 2/2] testsuite: check Isar image for reproducability.
Date: Tue, 29 Nov 2022 18:58:14 +0100	[thread overview]
Message-ID: <20221129175814.16355-3-ubely@ilbers.de> (raw)
In-Reply-To: <20221129175814.16355-1-ubely@ilbers.de>

This test uses 'diffoscope'[1] tool to check the difference between
two consecutive builds and copy the differeneces in html format.

[1] https://diffoscope.org/

Signed-off-by: Uladzimir Bely <ubely@ilbers.de>
---
 testsuite/cibase.py | 44 ++++++++++++++++++++++++++++++++++++++++++++
 testsuite/citest.py | 18 ++++++++++++++++++
 2 files changed, 62 insertions(+)

diff --git a/testsuite/cibase.py b/testsuite/cibase.py
index 6239b4de..8a6d4c6e 100755
--- a/testsuite/cibase.py
+++ b/testsuite/cibase.py
@@ -2,6 +2,7 @@
 
 import glob
 import os
+import subprocess
 import re
 import tempfile
 import time
@@ -55,6 +56,49 @@ class CIBaseTest(CIBuilder):
             # Try to build with changed configuration with no cleanup
             self.bitbake(targets, **kwargs)
 
+    def perform_reproducable_test(self, targets, **kwargs):
+        def get_bitbake_var(output, var):
+            ret = ''
+            for line in output.splitlines():
+                if line.startswith(var + '='):
+                    ret = line.split('"')[1]
+            return ret
+
+        self.configure(**kwargs)
+
+        self.log.info('Starting first build...')
+        self.bitbake(targets, **kwargs)
+
+        self.move_in_build_dir('tmp', 'tmp1')
+        self.delete_from_build_dir('sstate-cache')
+        self.delete_from_build_dir('ccache')
+
+        self.log.info('Starting second build...')
+        self.bitbake(targets, **kwargs)
+        self.bitbake(targets, **kwargs)
+
+        self.move_in_build_dir('tmp', 'tmp2')
+        self.delete_from_build_dir('sstate-cache')
+        self.delete_from_build_dir('ccache')
+
+        for target in targets:
+            output = subprocess.check_output(['bitbake', '-e', target]).decode()
+
+            machine=get_bitbake_var(output, 'MACHINE')
+            distro=get_bitbake_var(output, 'DISTRO')
+
+            cmdline = ['diffoscope']
+            cmdline.extend(['--html-dir', 'diffoscope_out'])
+            cmdline.extend(['tmp1/deploy/images/' + machine + '/isar-image-base-' + distro + '-' + machine + '.tar.gz'])
+            cmdline.extend(['tmp2/deploy/images/' + machine + '/isar-image-base-' + distro + '-' + machine + '.tar.gz'])
+
+            print(cmdline)
+
+            p1 = subprocess.call(cmdline)
+
+            if p1.returncode:
+                self.fail('Image is not reproducable')
+
     def perform_ccache_test(self, targets, **kwargs):
         def ccache_stats(dir, field):
             # Look ccache source's 'src/core/Statistic.hpp' for field meanings
diff --git a/testsuite/citest.py b/testsuite/citest.py
index 2dc78015..aa63e848 100755
--- a/testsuite/citest.py
+++ b/testsuite/citest.py
@@ -48,6 +48,24 @@ class ReproTest(CIBaseTest):
         finally:
             self.move_in_build_dir('tmp', 'tmp_repro_unsigned')
 
+class ReproducableTest(CIBaseTest):
+
+    """
+    Test cached base repository
+
+    :avocado: tags=reproducable
+    """
+    def test_reproducable(self):
+        targets = [
+            'mc:qemuamd64-bullseye:isar-image-base'
+                  ]
+
+        self.init()
+        try:
+            self.perform_reproducable_test(targets)
+        except:
+            self.cancel('KFAIL')
+
 class CcacheTest(CIBaseTest):
 
     """
-- 
2.20.1


      parent reply	other threads:[~2022-11-29 17:58 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-29 17:58 [RFC PATCH 0/2] " Uladzimir Bely
2022-11-29 17:58 ` [PATCH 1/2] Install diffoscope binary if not installed Uladzimir Bely
2022-11-29 17:58 ` Uladzimir Bely [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221129175814.16355-3-ubely@ilbers.de \
    --to=ubely@ilbers.de \
    --cc=isar-users@googlegroups.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox