From 3909f2f32eb413e2a7fecd0daabc924085266f3c Mon Sep 17 00:00:00 2001 From: Valentin Schneider Date: Wed, 6 Jun 2018 16:54:11 +0100 Subject: [PATCH] utils/wa_results_collector: Add fallback sha1 acquisition method To map a WA run with a kernel commit sha1, we currently read whatever __meta/target_info.json reports for "kernel_release" (which should be the equivalent of uname -r). However, there are cases where this doesn't seem to be reported. For instance, a HiKey960 built with hikey960_defconfig will not report the commit sha1 in its version data, which will cause an exception in the results collector code. Since the sha1 is included in the results directory name, use that as a backup. --- libs/utils/wa_results_collector.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/libs/utils/wa_results_collector.py b/libs/utils/wa_results_collector.py index a1a4eeaaf..fbb035ca2 100644 --- a/libs/utils/wa_results_collector.py +++ b/libs/utils/wa_results_collector.py @@ -112,6 +112,8 @@ class WaResultsCollector(object): cached in the provided output directories. Set this param to False to disable this caching. """ + RE_WLTEST_DIR = re.compile(r"wa\.(?P\w+)_(?P.+)") + def __init__(self, base_dir=None, wa_dirs=".*", platform=None, kernel_repo_path=None, parse_traces=True, use_cached_trace_metrics=True): @@ -517,7 +519,21 @@ class WaResultsCollector(object): """ with open(os.path.join(wa_dir, '__meta', 'target_info.json')) as f: target_info = json.load(f) - return KernelVersion(target_info['kernel_release']).sha1 + + # Read the kernel release reported by the target + sha1 = KernelVersion(target_info['kernel_release']).sha1 + if sha1: + return sha1 + + # Couldn't get the release sha1, default to reading it from the + # directory name built by test_series + res_dir = os.path.basename(wa_dir) + match = re.search(WaResultsCollector.RE_WLTEST_DIR, res_dir) + if match: + return match.group("sha1") + + raise RuntimeError("Couldn't find the sha1 of the kernel of the device " + "that produced {}".format(wa_dir)) @memoized def _select(self, tag='.*', kernel='.*', test='.*'): -- GitLab