]> git.cworth.org Git - apitrace-tests/commitdiff
Be more lenient with shader matching.
authorJosé Fonseca <jfonseca@vmware.com>
Fri, 22 Feb 2013 15:04:20 +0000 (15:04 +0000)
committerJosé Fonseca <jfonseca@vmware.com>
Fri, 22 Feb 2013 15:04:20 +0000 (15:04 +0000)
tracematch.py

index ec0509e5285e0983a3203dd989129aef08b13afb..45228bfd250fbd94c676e21526ae133b83075caf 100755 (executable)
@@ -112,6 +112,27 @@ class ApproxMatcher(Matcher):
         return repr(self.refValue)
 
 
         return repr(self.refValue)
 
 
+class StringMatcher(Matcher):
+
+    def __init__(self, refValue):
+        self.refValue = refValue
+
+    def isShaderDisassembly(self, value):
+        return value.find('// Generated by Microsoft (R) D3D Shader Disassembler\n') != -1
+
+    def normalizeShaderDisassembly(self, value):
+        # Unfortunately slightly different disassemblers produce different output
+        return '\n'.join([line.strip() for line in value.split('\n') if line.strip() and not line.startswith('//')])
+
+    def match(self, value, mo):
+        if self.isShaderDisassembly(self.refValue) and self.isShaderDisassembly(value):
+            return self.normalizeShaderDisassembly(self.refValue) == self.normalizeShaderDisassembly(value)
+        return self.refValue == value
+
+    def __str__(self):
+        return repr(self.refValue)
+
+
 class BitmaskMatcher(Matcher):
 
     def __init__(self, refElements):
 class BitmaskMatcher(Matcher):
 
     def __init__(self, refElements):
@@ -398,6 +419,9 @@ class Lexer:
             self.col = ((self.col - 1)//self.tabsize + 1)*self.tabsize + 1
             pos = tabpos + 1
         self.col += len(text) - pos
             self.col = ((self.col - 1)//self.tabsize + 1)*self.tabsize + 1
             pos = tabpos + 1
         self.col += len(text) - pos
+    
+    def filter(self, type, text):
+        return type, text
 
 
 class Parser:
 
 
 class Parser:
@@ -486,16 +510,9 @@ class CallLexer(Lexer):
         if type == STRING:
             text = text[1:-1]
 
         if type == STRING:
             text = text[1:-1]
 
-            # line continuations
-            text = text.replace('\\\r\n', '')
-            text = text.replace('\\\r', '')
-            text = text.replace('\\\n', '')
-            
             # quotes
             text = text.replace('\\"', '"')
 
             # quotes
             text = text.replace('\\"', '"')
 
-            type = ID
-
         return type, text
 
 
         return type, text
 
 
@@ -702,7 +719,7 @@ class RefTraceParser(TraceParser):
         return ApproxMatcher(value)
 
     def handleString(self, value):
         return ApproxMatcher(value)
 
     def handleString(self, value):
-        return LiteralMatcher(value)
+        return StringMatcher(value)
 
     def handleBitmask(self, value):
         return BitmaskMatcher(value)
 
     def handleBitmask(self, value):
         return BitmaskMatcher(value)