From patchwork Mon Dec 19 14:41:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: venkata.pyla@toshiba-tsip.com X-Patchwork-Id: 2340 Return-Path: Received: from shymkent.ilbers.de ([unix socket]) by shymkent (Cyrus 2.5.10-Debian-2.5.10-3+deb9u2) with LMTPA; Mon, 19 Dec 2022 15:42:01 +0100 X-Sieve: CMU Sieve 2.4 Received: from mail-pl1-f186.google.com (mail-pl1-f186.google.com [209.85.214.186]) by shymkent.ilbers.de (8.15.2/8.15.2/Debian-8+deb9u1) with ESMTPS id 2BJEg0qr029353 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 19 Dec 2022 15:42:01 +0100 Received: by mail-pl1-f186.google.com with SMTP id k18-20020a170902c41200b001896d523dc8sf7062684plk.19; Mon, 19 Dec 2022 06:42:01 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1671460914; cv=pass; d=google.com; s=arc-20160816; b=PkIBOytSASlch8+MTOix/MWbobFlF7QHDZMZ1XoC0S/qlKsp2objxJGA9rjAiZi+Dq Yg7IvaQdKxPaCZIcMDIkYG0RT6vqJExLLhhHw55OkIXyYMyT1F/MLgo0fp7RKaIdNVkU fLMWoi3glTgM+DWMiP3KVLTFzYGNCycdwVohsFi/Ltr7tvX+dwg520vHNs9IejsNmWa1 P5PLshK6QNnzZB1G5HnxOHD0CqOSSi9Z/n5KATUfEvSVWJfro5t0MtKn927yHmv59MGf r0CSCtblAcNNdDYsYIbfe+Ds9XnAjNLXG6BAUv/gZsEWL4OaKPPGmDqvZ6MMaJW8r1HD caWg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:dkim-signature; bh=Y4GH37UVd8YHJk/ysBWcmmQzfSdrEZhNoJQ7vvN9B/w=; b=ERbrq5xk7XxxVPOUWQt47Rw3F05ZbJFVQc53KUgaY1m20jXl+SgZUg2eS7f+NLc1QP NeP5FmRY/f2j3qHj1qiz8V48Mu0diOqyoJi8/dMvZiHfzL0FIrBASwUWZ87dzjvew7cF EVOOXU0Xe5SMT2+HC271fyozScun0CeqjNmzkJyX7nUDRU557DTo4pQNXegrHeXgNc1V 5Y0iFIjnMOgIXYHnHpqA1bVHX0itbQ2lI43COG/VEFDWeQDdDAIZfk3ZSoRmDjK8TUec 6y29bK5sntFCHp6iepNfx9xeJi/O1h/UTbW9FnvQJnxdufRdjqE9K5MRIRWOBfqDw5Wh 2qOw== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=pass (google.com: domain of venkata.pyla@toshiba-tsip.com designates 210.130.202.154 as permitted sender) smtp.mailfrom=venkata.pyla@toshiba-tsip.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20210112; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:x-original-authentication-results :x-original-sender:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:sender:from:to:cc:subject:date:message-id :reply-to; bh=Y4GH37UVd8YHJk/ysBWcmmQzfSdrEZhNoJQ7vvN9B/w=; b=n41sp+no/68NFxt7dl1/CjVvLlw5GoOq55QV4cweVAGAabM1RxfQVxkBQJAJs/eacg qouXuuNkMou7gG5I9kQjcvumHIVP+Fba9MadOsTA6XD5uJ0lVLnKQn3vSVSg2p/6fOWn 0i6XO6eP7mXG6wDqycDCnSDRPXGN8u4kLtGcU1wrYeTF3nJHrT4dQ064ONeL0RWP3nlq RwpgMy6NYpRydSPRirSK2S/Z2XWaxSiMWSnMafEYAkukcUmcprhR7HXopgAn309pQz3u fb8mAkKHBRVD0SU12rbGi6h40HAu3wkgiPVrx0MKDfORgKdElNXS+Qc8ZgtR9mir+hwj 9OFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :x-original-authentication-results:x-original-sender:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :x-gm-message-state:sender:from:to:cc:subject:date:message-id :reply-to; bh=Y4GH37UVd8YHJk/ysBWcmmQzfSdrEZhNoJQ7vvN9B/w=; b=fUMtxshChvm5cfJllQXfRqPOIX6LRrb0ToxiZ1XyDO1CoDLwnSE8SR9YANeJwxigep kd70EBTEGstIgrBiE1sO/lv1DvoJWkzGpBv1C2K0yj7p9y15HmvgD8ouf2yRtOG0wMrR CV9sfV2TtzMFtIkZQoHSDwGgG9drueUa6FKOgu/xvwzG/rYabDdqIRHUhfUedrb0NcbV dPOrXfZ2bi0m8EYw6qnC4UGD8bZozRrDHJgJ5i9YDwH+wzPFA/RaN7XE+2cXoXMTj2g7 +iapSwFzaHs+GLvmQ422b39+dYKHsd5ewwNkc9cQTrV0Zs798LBiDVxsL6srpK626nl4 UQ5g== Sender: isar-users@googlegroups.com X-Gm-Message-State: ANoB5pneKqmGSKQCnw9CjmF/nfbVjvggKnVPvY/Soowb8JkosfXVaI4L T8kYZfJuSAdqEvrQAJNOcmw= X-Google-Smtp-Source: AA0mqf46/9BpdRD9wbAfhUj1vsP5fpo2G5ku6X2kkQNRxDrDYViw6YptZmnq5Jk0VHwQrMsCAOWOHw== X-Received: by 2002:a63:311:0:b0:478:ba6c:3879 with SMTP id 17-20020a630311000000b00478ba6c3879mr19007534pgd.440.1671460914255; Mon, 19 Dec 2022 06:41:54 -0800 (PST) X-BeenThere: isar-users@googlegroups.com Received: by 2002:a17:902:c205:b0:178:35a3:84d9 with SMTP id 5-20020a170902c20500b0017835a384d9ls10327470pll.10.-pod-prod-gmail; Mon, 19 Dec 2022 06:41:53 -0800 (PST) X-Received: by 2002:a17:902:e149:b0:186:5f5a:5842 with SMTP id d9-20020a170902e14900b001865f5a5842mr9337435pla.11.1671460913520; Mon, 19 Dec 2022 06:41:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671460913; cv=none; d=google.com; s=arc-20160816; b=C4+WWJ0Y3EvlPu531SRMdcLg0SfVXOHP8TUc73+VIMMl99MpNjUYISQAGp+IExezux lU1woOVYo9NEXBlO+sl5EXn5akia37n6OhZtyZltfpYXW0AtFj1+QnlY4gM8FLxfPkam 27BnhO+oo+DbUAYacoDg8Mcqcv6NKtzMKP+DgX7yaJvBTJWT67qu9zTkej1U0K6N/fec iRvMvpiSBt4h2lV6euMV7SOCwMh/aak2rbpSRfQyKpcltmmM9WozV5hhfzTAj/09vQkg GsOzpxVU7f7pgVKU17VAX5mc5PNvGcCb8M+1BfKVpI5i5tfAiG1Gf/Ik3i2c7qJKFeK/ sl+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=WRWjSyJWt6YaonYpLowz14ZNZgEgV+5MmQbXJOWSWAQ=; b=bw1XnNAFMjEZw57AX1yCcA7RF88GUObO+qO2X9Vx9MRdN0CzHE5ufHxlJO7h96ec/3 tvZP1sISRVtnGApoT6T+MU6FhclnNZ+tJk0+o94LCxBCRWOVPSYPYnuzVSKLh31DCTyE GvQs7sLzUNVqcmqmYlmezX+zJSOtIg/S7FhPB0VXvXjMZY3MJimr0/ODapV+qpCAsKPj kAc3qBt49TDKwwniLATutlIAyhVBqZH8jzsKbU7fAPPKSPe1m7AIN+QoeZfm8d9FterA z7+9HHJ5pUEYpgifh1YdTsTfUobrLUSRlhwCqLSbm8wZAtFXskPaDh2YV2MggQFH+Q53 10nQ== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of venkata.pyla@toshiba-tsip.com designates 210.130.202.154 as permitted sender) smtp.mailfrom=venkata.pyla@toshiba-tsip.com Received: from mo-csw.securemx.jp (mo-csw1515.securemx.jp. [210.130.202.154]) by gmr-mx.google.com with ESMTPS id m3-20020a170902db0300b0018712ccd6e0si972221plx.2.2022.12.19.06.41.53 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Dec 2022 06:41:53 -0800 (PST) Received-SPF: pass (google.com: domain of venkata.pyla@toshiba-tsip.com designates 210.130.202.154 as permitted sender) client-ip=210.130.202.154; Received: by mo-csw.securemx.jp (mx-mo-csw1515) id 2BJEfpee031117; Mon, 19 Dec 2022 23:41:51 +0900 X-Iguazu-Qid: 34trDbI6Ag4CdYaq0G X-Iguazu-QSIG: v=2; s=0; t=1671460911; q=34trDbI6Ag4CdYaq0G; m=gdfjbguzTtivE/53lhzGMuh8Fqoo12ARm9i9Fp2oPy4= Received: from imx2-a.toshiba.co.jp (imx2-a.toshiba.co.jp [106.186.93.35]) by relay.securemx.jp (mx-mr1513) id 2BJEfoVa031925 (version=TLSv1.2 cipher=AES128-GCM-SHA256 bits=128 verify=NOT); Mon, 19 Dec 2022 23:41:51 +0900 From: venkata.pyla@toshiba-tsip.com To: isar-users@googlegroups.com Cc: venkata pyla , jan.kiszka@siemens.com, henning.schild@siemens.com, kazuhiro3.hayashi@toshiba.co.jp, dinesh.kumar@toshiba-tsip.com Subject: [PATCH 2/2] repro-build-test.py: Test to check images are reproducible Date: Mon, 19 Dec 2022 20:11:47 +0530 X-TSB-HOP2: ON Message-Id: <20221219144147.31245-3-venkata.pyla@toshiba-tsip.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 X-OriginalArrivalTime: 19 Dec 2022 14:41:48.0346 (UTC) FILETIME=[063929A0:01D913B8] X-Original-Sender: venkata.pyla@toshiba-tsip.com X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of venkata.pyla@toshiba-tsip.com designates 210.130.202.154 as permitted sender) smtp.mailfrom=venkata.pyla@toshiba-tsip.com Precedence: list Mailing-list: list isar-users@googlegroups.com; contact isar-users+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: isar-users@googlegroups.com X-Google-Group-Id: 914930254986 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on shymkent.ilbers.de X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= From: venkata pyla This test verifies whether the images are reproducible by checking with in-depth comparision tool `diffoscope` and produces a comparision output in plain text format for checking the differences. Signed-off-by: venkata pyla --- testsuite/repro-build-test.py | 68 +++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100755 testsuite/repro-build-test.py diff --git a/testsuite/repro-build-test.py b/testsuite/repro-build-test.py new file mode 100755 index 0000000..e89becf --- /dev/null +++ b/testsuite/repro-build-test.py @@ -0,0 +1,68 @@ +#!/usr/bin/env python3 + +import glob +import os +import re +import tempfile +import time + +from cibuilder import CIBuilder, isar_root +from avocado.utils import process + +class ReproBuild(CIBuilder): + + """ + Test reproducible builds by comparing the artifacts + + :avocado: tags=repro-build + """ + def test_repro_build(self): + target = self.params.get('build_target', default='mc:qemuamd64-bullseye:isar-image-base') + source_date_epoch = self.params.get('source_date_epoch', default=self.git_last_commit_timestamp()) + self.init() + self.build_repro_image(target, source_date_epoch, 'image1.tar.gz') + self.build_repro_image(target, source_date_epoch, 'image2.tar.gz') + self.compare_repro_image('image1.tar.gz', 'image2.tar.gz') + + def git_last_commit_timestamp(self): + return process.run('git log -1 --pretty=%ct').stdout + + def get_image_path(self, target_name): + image_dir = "tmp/deploy/images" + target_params = target_name.split(':') + machine = target_params[1].split('-')[0] + distro = 'debian-' + target_params[1].split('-')[1] + image_type = target_params[2] + return f'{image_dir}/{machine}/{image_type}-{distro}-{machine}.tar.gz' + + def build_repro_image(self, target, source_date_epoch=None ,image_name='image.tar.gz'): + + if not source_date_epoch: + self.error("Reproducible build should configure with source_date_epoch time") + + # clean artifacts before build + self.clean() + + # Build + self.log.info("Started Build " + image_name) + self.configure(source_date_epoch=source_date_epoch) + self.bitbake(target) + + # copy the artifacts image name with given name + image_path = self.get_image_path(target) + self.log.info("Copy image " + image_path + " as " + image_name) + self.move_in_build_dir(image_path, image_name) + + def clean(self): + self.delete_from_build_dir('tmp') + self.delete_from_build_dir('sstate-cache') + + def compare_repro_image(self, image1, image2): + self.log.info("Compare artifacts image1: " + image1 + ", image2: " + image2) + result = process.run('diffoscope ' + '--text ' + self.build_dir + '/diffoscope-output.txt' + ' ' + self.build_dir + '/' + image1 + + ' ' + self.build_dir + '/' + image2 , + ignore_status = True) + if result.exit_status > 0: + self.fail(f'Images {image1} and {image2} are not reproducible')