BaseTools: Update Tests/TestTools.py to allow it to work on Windows

On Windows, executables have a '.exe' suffix which needs to be added for
them to be found in a path.

Also, files need to be explicitly opened as binary.

Signed-off-by: Rebecca Cran <rebecca@bsdio.com>
This commit is contained in:
Rebecca Cran 2023-05-06 05:01:49 -06:00 committed by Mikhail Krichanov
parent 1b765a0b7c
commit ac593ee4d7

View File

@ -109,6 +109,8 @@ class BaseToolsTest(unittest.TestCase):
else: logFile = None else: logFile = None
if toolName is None: toolName = self.toolName if toolName is None: toolName = self.toolName
if sys.platform == "win32":
toolName += ".exe"
bin = self.FindToolBin(toolName) bin = self.FindToolBin(toolName)
if logFile is not None: if logFile is not None:
logFile = open(os.path.join(self.testDir, logFile), 'w') logFile = open(os.path.join(self.testDir, logFile), 'w')
@ -135,7 +137,7 @@ class BaseToolsTest(unittest.TestCase):
return open(os.path.join(self.testDir, fileName), mode) return open(os.path.join(self.testDir, fileName), mode)
def ReadTmpFile(self, fileName): def ReadTmpFile(self, fileName):
f = open(self.GetTmpFilePath(fileName), 'r') f = open(self.GetTmpFilePath(fileName), 'rb')
data = f.read() data = f.read()
f.close() f.close()
return data return data