1From 53ceb2d4167b05374678b966031b3d52fc5080a2 Mon Sep 17 00:00:00 2001
2From: Debbie Martin <Debbie.Martin@arm.com>
3Date: Fri, 29 Sep 2023 15:22:17 +0100
4Subject: [PATCH] check-sr-results: Device tree improvements
5
6Make check-sr-results.py accept 'extra_compat' configuration for
7devicetree files, and pass these in the compat list given to
8dt-parser.py.
9
10Update dt-parser.py to parse the GCC version line in the dtb log.
11
12Upstream-Status: Pending
13Signed-off-by: Debbie Martin <Debbie.Martin@arm.com>
14---
15 check-sr-results.py | 12 ++++++++++--
16 dt-parser.py        |  8 ++++++++
17 2 files changed, 18 insertions(+), 2 deletions(-)
18
19diff --git a/check-sr-results.py b/check-sr-results.py
20index 48658f0..a207a39 100755
21--- a/check-sr-results.py
22+++ b/check-sr-results.py
23@@ -598,7 +598,7 @@ def need_regen(filename, deps, margin=0):
24 # We run dtc and dt-validate to produce the log when needed.
25 # We add markers to the log, which will be ignored by dt-parser.py.
26 # We return a Stats object.
27-def check_devicetree(filename):
28+def check_devicetree(filename, extra_compat=None):
29     logging.debug(f"Check Devicetree `{filename}'")
30     stats = Stats()
31     log = f"{filename}.log"
32@@ -644,6 +644,9 @@ def check_devicetree(filename):
33     # We use the compatible strings extracted from Linux bindings to filter out
34     # more false positive.
35     compat = get_compat()
36+    if extra_compat:
37+        with open(compat, "a") as compat_file:
38+            compat_file.write("\n".join(extra_compat))
39     cp = run(f"{dt_parser} --compatibles '{compat}' '{log}'")
40
41     if cp.returncode:
42@@ -930,7 +933,12 @@ def check_file(conffile, filename):
43                 stats.add(check_uefi_capsule(filename))
44
45             if 'devicetree' in conffile:
46-                stats.add(check_devicetree(filename))
47+                stats.add(
48+                    check_devicetree(
49+                        filename,
50+                        extra_compat=conffile.get("extra_compat")
51+                    )
52+                )
53
54             if 'uefi-sniff' in conffile:
55                 stats.add(check_uefi_sniff(filename))
56diff --git a/dt-parser.py b/dt-parser.py
57index 3eccd74..c1c0031 100755
58--- a/dt-parser.py
59+++ b/dt-parser.py
60@@ -181,6 +181,14 @@ def parse(filename):
61                 }
62                 continue
63
64+            # line [GCC <version>]
65+            m = re.match(r'\[GCC [0-9\.]+\]', line)
66+            if m:
67+                logging.debug(
68+                    f"line {i}: GCC version (`{line}')"
69+                )
70+                continue
71+
72             # If we could not parse the line we arrive here and complain.
73             logging.warning(f"Unparsed line {i}: `{line}'")
74
75--
762.25.1
77
78