From: Atharva Lele <itsatharva@gmail.com>
To: buildroot@busybox.net
Subject: [Buildroot] [PATCH 5/6] autobuild-run: initial implementation of get_reproducibility_failure_reason()
Date: Tue, 6 Aug 2019 23:42:50 +0530 [thread overview]
Message-ID: <20190806181251.21885-5-itsatharva@gmail.com> (raw)
In-Reply-To: <20190806181251.21885-1-itsatharva@gmail.com>
Analyze the JSON formatted output from diffoscope and check if
the differences are due to a filesystem reproducibility issue
or a package reproducibility issue.
Also, discard the deltas because they might take up too much space.
Signed-off-by: Atharva Lele <itsatharva@gmail.com>
---
scripts/autobuild-run | 71 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 71 insertions(+)
diff --git a/scripts/autobuild-run b/scripts/autobuild-run
index 520cfe2..f2f6460 100755
--- a/scripts/autobuild-run
+++ b/scripts/autobuild-run
@@ -131,6 +131,7 @@ import csv
import docopt
import errno
import hashlib
+import json
import mmap
import multiprocessing
import os
@@ -596,6 +597,76 @@ class Builder:
if reject_results():
return
+ def get_reproducibility_failure_reason(reproducible_results):
+ def clean_delta(delta):
+ added = []
+ deleted = []
+ for line in delta:
+ if line.startswith("+"):
+ added.append(line)
+ if line.startswith("-"):
+ deleted.append(line)
+ return added, deleted
+
+ with open(reproducible_results, "r") as reproduciblef:
+ json_data = json.load(reproduciblef)
+
+ packages_file_list = os.path.join(self.outputdir, "build", "packages-file-list.txt")
+
+ if json_data["unified_diff"] == None:
+ if json_data["details"][0]["source1"] == "file list":
+ json_data["details"].pop(0)
+
+ for i in range(0, len(json_data["details"])):
+ diff_source = json_data["details"][i]["source1"]
+ with open(packages_file_list, "r") as packagef:
+ for line in packagef:
+ if diff_source in line:
+ package = line.split(',')[0]
+
+ # Get package version
+ package_info = json.loads(subprocess.check_output(["make", "--no-print-directory",
+ "O=%s" % self.outputdir,
+ "-C", self.srcdir,
+ "%s-show-info" % package]))
+ if "version" in package_info[package]:
+ version = package_info[package]["version"]
+ reason = [package, version]
+ else:
+ reason = [package]
+ json_data["details"][i]["package"] = reason
+ json_data["details"][i].pop("source2")
+ if json_data["details"][i]["unified_diff"] == None:
+ json_data["details"][i].pop("unified_diff")
+ for j in range(0, len(json_data["details"][i]["details"])):
+ delta = json_data["details"][i]["details"][j]["unified_diff"].split("\n")
+ deltas = clean_delta(delta)
+ json_data["details"][i]["details"][j]["added"] = deltas[0][:100]
+ json_data["details"][i]["details"][j]["deleted"] = deltas[1][:100]
+ try:
+ json_data["details"][i]["details"][j].pop("unified_diff")
+ json_data["details"][i]["details"][j].pop("source2")
+ except KeyError as e:
+ log_write(self.log, "KeyError: %s not found in JSON details[%d][%d]" % (e, i, j))
+ else:
+ delta = json_data["details"][i]["unified_diff"]
+ deltas = clean_delta(delta)
+ json_data["details"][i]["added"] = deltas[0][:100]
+ json_data["details"][i]["deleted"] = deltas[1][:100]
+ try:
+ json_data["details"][i].pop("unified_diff")
+ json_data["details"][i].pop("source2")
+ except KeyError as e:
+ log_write(self.log, "KeyError: %s not found in JSON details[%d]" % (e, i))
+ reason = json_data["details"][0]["package"]
+ else:
+ reason = "filesystem"
+
+ with open(reproducible_results, "w") as reproduciblef:
+ json.dump(json_data, reproduciblef, sort_keys=True, indent=4)
+
+ return reason
+
def get_failure_reason():
# Output is a tuple (package, version), or None.
lastlines = decode_bytes(subprocess.Popen(
--
2.22.0
next prev parent reply other threads:[~2019-08-06 18:12 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-06 18:12 [Buildroot] [PATCH 1/6] autobuild-run: use different output directories for reproducible builds testing Atharva Lele
2019-08-06 18:12 ` [Buildroot] [PATCH 2/6] autobuild-run: make prepare_build() clean the output directory used for reproducibility testing Atharva Lele
2019-08-06 18:12 ` [Buildroot] [PATCH 3/6] autobuild-run: fix cross tools prefix for diffoscope Atharva Lele
2019-08-06 20:18 ` Thomas Petazzoni
2019-08-06 18:12 ` [Buildroot] [PATCH 4/6] autobuild-run: make diffoscope output to a JSON-formatted file Atharva Lele
2019-08-06 19:40 ` Thomas Petazzoni
2019-08-07 6:12 ` Atharva Lele
2019-08-06 18:12 ` Atharva Lele [this message]
2019-08-06 20:21 ` [Buildroot] [PATCH 5/6] autobuild-run: initial implementation of get_reproducibility_failure_reason() Thomas Petazzoni
2019-08-07 6:07 ` Atharva Lele
2019-08-06 18:12 ` [Buildroot] [PATCH 6/6] autobuild-run: account for reproducibility failures in get_failure_reason() Atharva Lele
2019-08-06 19:37 ` [Buildroot] [PATCH 1/6] autobuild-run: use different output directories for reproducible builds testing Thomas Petazzoni
2019-08-07 6:02 ` Atharva Lele
2019-08-07 8:33 ` Thomas Petazzoni
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=20190806181251.21885-5-itsatharva@gmail.com \
--to=itsatharva@gmail.com \
--cc=buildroot@busybox.net \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.