Add Python3 compatibility to verification scripts
authorSamuel Iglesias Gonsálvez <siglesias@igalia.com>
Mon, 2 Dec 2019 12:14:04 +0000 (13:14 +0100)
committerAlexander Galazin <Alexander.Galazin@arm.com>
Thu, 13 Feb 2020 09:53:50 +0000 (04:53 -0500)
Components: Framework
VK-GL-CTS issue: 1930

Change-Id: I94ba1d798f64928dada5ee7ec7deaf2704c817a4

scripts/log/log_parser.py
scripts/verify/verify.py

index 2b3eb7b04cd39189d528652ff9fded502e95af4d..b77af3fc7b538e9fc6c17c7c6d2bcf471119d1ff 100644 (file)
@@ -131,7 +131,8 @@ class BatchResultParser:
                self.filename                   = filename
 
        def parseLine (self, line):
-               if len(line) > 0 and line[0] == '#':
+               text = line.decode('utf-8')
+               if len(text) > 0 and text[0] == '#':
                        return self.parseContainerLine(line)
                elif self.curResultText != None:
                        self.curResultText += line
@@ -140,7 +141,8 @@ class BatchResultParser:
 
        def parseContainerLine (self, line):
                isTestCaseResult = False
-               args = splitContainerLine(line)
+               text = line.decode('utf-8')
+               args = splitContainerLine(text)
                if args[0] == "#sessionInfo":
                        if len(args) < 3:
                                print(args)
@@ -152,7 +154,7 @@ class BatchResultParser:
                        if len(args) != 2 or self.curCaseName != None:
                                self.parseError("Invalid #beginTestCaseResult")
                        self.curCaseName        = args[1]
-                       self.curResultText      = ""
+                       self.curResultText      = b""
                elif args[0] == "#endTestCaseResult":
                        if len(args) != 1 or self.curCaseName == None:
                                self.parseError("Invalid #endTestCaseResult")
index dff0f8f2e86526c3f8fc9bd8bcfc1814e39079c9..b4ac832417d04cce2ff6dfa7aff35981c14a544a 100644 (file)
@@ -38,7 +38,7 @@ ALLOWED_STATUS_CODES = set([
        ])
 
 def readMustpass (filename):
-       f = open(filename, 'rb')
+       f = open(filename, 'rt')
        cases = []
        for line in f:
                s = line.strip()
@@ -63,7 +63,7 @@ def verifyTestLog (filename, mustpass):
                messages.append(error(filename, "Wrong number of test results, expected %d, found %d" % (len(mustpass), len(results))))
 
        caseNameToResultNdx = {}
-       for ndx in xrange(len(results)):
+       for ndx in range(len(results)):
                result = results[ndx]
                if not result in caseNameToResultNdx:
                        caseNameToResultNdx[result.name] = ndx
@@ -71,7 +71,7 @@ def verifyTestLog (filename, mustpass):
                        messages.append(error(filename, "Multiple results for " + result.name))
 
        # Verify that all results are present and valid
-       for ndx in xrange(len(mustpass)):
+       for ndx in range(len(mustpass)):
                caseName = mustpass[ndx]
 
                if caseName in caseNameToResultNdx: