Mesa (main): pan/va: Improve assembler unit test output

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Dec 6 23:24:25 UTC 2021


Module: Mesa
Branch: main
Commit: 9da627fd6d8176028850fddcae5d0e57c75b162f
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=9da627fd6d8176028850fddcae5d0e57c75b162f

Author: Alyssa Rosenzweig <alyssa at collabora.com>
Date:   Sat Dec  4 18:40:36 2021 -0500

pan/va: Improve assembler unit test output

Instead of using Python hex() to print the result, print the result in
the same format as the disassembler for easy visual comparison. This
means we don't need to reprint the expectation. This gives output like:

   7c 7d 11 33 04 80 66 00    LD_ATTR_IMM.v4.f16.slot0 @r0:r1, `r60, `r61, index:0x1
   7c 7d 10 33 04 80 66 00    Incorrect assembly

Signed-off-by: Alyssa Rosenzweig <alyssa at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14065>

---

 src/panfrost/bifrost/valhall/test-assembly.py | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/panfrost/bifrost/valhall/test-assembly.py b/src/panfrost/bifrost/valhall/test-assembly.py
index 9aa7a223657..4249ce82ad0 100644
--- a/src/panfrost/bifrost/valhall/test-assembly.py
+++ b/src/panfrost/bifrost/valhall/test-assembly.py
@@ -23,18 +23,24 @@
 
 from asm import parse_asm, ParseError
 import sys
+import struct
 
 def parse_hex_8(s):
     b = [int(x, base=16) for x in s.split(' ')]
     return sum([x << (8 * i) for i, x in enumerate(b)])
 
+def hex_8(u64):
+    as_bytes = struct.pack('<Q', u64)
+    as_strings = [('0' + hex(byte)[2:])[-2:] for byte in as_bytes]
+    return ' '.join(as_strings)
+
 # These should not throw exceptions
 def positive_test(machine, assembly):
     try:
         expected = parse_hex_8(machine)
         val = parse_asm(assembly)
         if val != expected:
-            return f"Expected {hex(expected)} but got {hex(val)}"
+            return f"{hex_8(val)}    Incorrect assembly"
     except ParseError as exc:
         return f"Unexpected exception: {exc}"
 



More information about the mesa-commit mailing list