[igt-dev] [PATCH i-g-t 2/8] lib/i915/perf: fixup converter script

Lionel Landwerlin lionel.g.landwerlin at intel.com
Fri Aug 28 11:16:28 UTC 2020


This script was previous run in python2, but because IGT is python3
only there are differences in what it generates. In particular the
attribute order differs in the tostring() of the ElementTree
function...

Reorder them alphabetically manually.

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
Fixes: 53f8f541caae ("lib: Add i915_perf library")
---
 lib/i915/perf-configs/oa_guid_registry.py | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/lib/i915/perf-configs/oa_guid_registry.py b/lib/i915/perf-configs/oa_guid_registry.py
index 0ed3983f..2df6bdfb 100644
--- a/lib/i915/perf-configs/oa_guid_registry.py
+++ b/lib/i915/perf-configs/oa_guid_registry.py
@@ -54,9 +54,19 @@ class Registry:
         changes that might affect our useages.
         """
 
+        def reorder_attributes(root):
+            for el in root.iter():
+                attrib = el.attrib
+                if len(attrib) > 1:
+                    # adjust attribute order, e.g. by sorting
+                    attribs = sorted(attrib.items())
+                    attrib.clear()
+                    attrib.update(attribs)
+
         config = et.Element('config')
         for registers in mdapi_metric_set.findall(".//RegConfigStart"):
             config.append(copy.deepcopy(registers))
+        reorder_attributes(config)
         registers_str = et.tostring(config)
 
         return hashlib.md5(registers_str).hexdigest()
-- 
2.28.0



More information about the igt-dev mailing list