X-Git-Url: https://git.cworth.org/git?p=apitrace-tests;a=blobdiff_plain;f=tracematch.py;h=45228bfd250fbd94c676e21526ae133b83075caf;hp=ec0509e5285e0983a3203dd989129aef08b13afb;hb=8351c1e187d8f65477db05a07bacd5d184c2b950;hpb=29bc86c9885156cfb998ae3aa42ddb026c300398 diff --git a/tracematch.py b/tracematch.py index ec0509e..45228bf 100755 --- a/tracematch.py +++ b/tracematch.py @@ -112,6 +112,27 @@ class ApproxMatcher(Matcher): 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): @@ -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 + + def filter(self, type, text): + return type, text class Parser: @@ -486,16 +510,9 @@ class CallLexer(Lexer): 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('\\"', '"') - type = ID - return type, text @@ -702,7 +719,7 @@ class RefTraceParser(TraceParser): return ApproxMatcher(value) def handleString(self, value): - return LiteralMatcher(value) + return StringMatcher(value) def handleBitmask(self, value): return BitmaskMatcher(value)