Mesa (main): pan/va: Add assembler test harness
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Tue Jul 27 20:33:39 UTC 2021
Module: Mesa
Branch: main
Commit: f917fb63e7a86cbffeb33085bc8d841d45061ca1
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=f917fb63e7a86cbffeb33085bc8d841d45061ca1
Author: Alyssa Rosenzweig <alyssa at collabora.com>
Date: Tue Jul 27 15:26:07 2021 -0400
pan/va: Add assembler test harness
Integration regression testing. Nothing fancy.
Signed-off-by: Alyssa Rosenzweig <alyssa at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12025>
---
src/panfrost/bifrost/valhall/test-assembly.py | 85 +++++++++++++++++++++++++++
1 file changed, 85 insertions(+)
diff --git a/src/panfrost/bifrost/valhall/test-assembly.py b/src/panfrost/bifrost/valhall/test-assembly.py
new file mode 100644
index 00000000000..9aa7a223657
--- /dev/null
+++ b/src/panfrost/bifrost/valhall/test-assembly.py
@@ -0,0 +1,85 @@
+#encoding=utf-8
+
+# Copyright (C) 2020 Collabora, Ltd.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the "Software"),
+# to deal in the Software without restriction, including without limitation
+# the rights to use, copy, modify, merge, publish, distribute, sublicense,
+# and/or sell copies of the Software, and to permit persons to whom the
+# Software is furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice (including the next
+# paragraph) shall be included in all copies or substantial portions of the
+# Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+# IN THE SOFTWARE.
+
+from asm import parse_asm, ParseError
+import sys
+
+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)])
+
+# 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)}"
+ except ParseError as exc:
+ return f"Unexpected exception: {exc}"
+
+# These should throw exceptions
+def negative_test(assembly):
+ try:
+ parse_asm(assembly)
+ return "Expected exception"
+ except Exception:
+ return None
+
+PASS = []
+FAIL = []
+
+def record_case(case, error):
+ if error is None:
+ PASS.append(case)
+ else:
+ FAIL.append((case, error))
+
+if len(sys.argv) < 3:
+ print("Expected positive and negative case lists")
+ sys.exit(1)
+
+with open(sys.argv[1], "r") as f:
+ cases = f.read().split('\n')
+ cases = [x for x in cases if len(x) > 0 and x[0] != '#']
+
+ for case in cases:
+ (machine, assembly) = case.split(' ')
+ record_case(case, positive_test(machine, assembly))
+
+with open(sys.argv[2], "r") as f:
+ cases = f.read().split('\n')
+ cases = [x for x in cases if len(x) > 0]
+
+ for case in cases:
+ record_case(case, negative_test(case))
+
+print("Passed {}/{} tests.".format(len(PASS), len(PASS) + len(FAIL)))
+
+if len(FAIL) > 0:
+ print("Failures:")
+ for (fail, err) in FAIL:
+ print("")
+ print(fail)
+ print(err)
+ sys.exit(1)
More information about the mesa-commit
mailing list