tests,python: Upgrading testlib to function with Python2

Change-Id: I9926b1507e9069ae8564c31bdd377b2b916462a2
Issue-on: https://gem5.atlassian.net/browse/GEM5-395
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/29088
Reviewed-by: Bobby R. Bruce <bbruce@ucdavis.edu>
Maintainer: Bobby R. Bruce <bbruce@ucdavis.edu>
Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
Bobby R. Bruce
2020-04-16 11:55:17 -07:00
parent 80a2636983
commit 7ffd684334
31 changed files with 190 additions and 164 deletions

View File

@@ -30,10 +30,10 @@ import os
import pickle
import xml.sax.saxutils
from config import config
import helper
import state
import log
from testlib.configuration import config
import testlib.helper as helper
import testlib.state as state
import testlib.log as log
def _create_uid_index(iterable):
index = {}
@@ -62,7 +62,7 @@ class _CommonMetadataMixin:
return self._metadata.result.value != state.Result.Passed
class InternalTestResult(object, _CommonMetadataMixin):
class InternalTestResult(_CommonMetadataMixin):
def __init__(self, obj, suite, directory):
self._metadata = obj.metadata
self.suite = suite
@@ -77,7 +77,7 @@ class InternalTestResult(object, _CommonMetadataMixin):
)
class InternalSuiteResult(object, _CommonMetadataMixin):
class InternalSuiteResult(_CommonMetadataMixin):
def __init__(self, obj, directory):
self._metadata = obj.metadata
self.directory = directory
@@ -104,7 +104,7 @@ class InternalSuiteResult(object, _CommonMetadataMixin):
return results
class InternalLibraryResults(object, _CommonMetadataMixin):
class InternalLibraryResults(_CommonMetadataMixin):
def __init__(self, obj, directory):
self.directory = directory
self._metadata = obj.metadata
@@ -159,12 +159,12 @@ class InternalSavedResults:
if exc.errno != errno.EEXIST:
raise
with open(path, 'w') as f:
with open(path, 'wb') as f:
pickle.dump(results, f, protocol)
@staticmethod
def load(path):
with open(path, 'r') as f:
with open(path, 'rb') as f:
return pickle.load(f)