summaryrefslogtreecommitdiff
path: root/BaseTools/Tests/TestTools.py
diff options
context:
space:
mode:
authorlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>2012-04-10 07:18:20 +0000
committerlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>2012-04-10 07:18:20 +0000
commit64b2609fcff9d6412eea4c74c8e74bed33dc3235 (patch)
treeb2fa2c1493272b91a04ff4f12384f3ceaa23f1a7 /BaseTools/Tests/TestTools.py
parent09e4dbeb5c0ef7d9e178e81f73c9e43f8ef48559 (diff)
downloadedk2-platforms-64b2609fcff9d6412eea4c74c8e74bed33dc3235.tar.xz
Sync BaseTools Trunk (version r2518) to EDKII main trunk.
Signed-off-by: Liming Gao <liming.gao@intel.com> git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13178 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'BaseTools/Tests/TestTools.py')
-rw-r--r--BaseTools/Tests/TestTools.py35
1 files changed, 21 insertions, 14 deletions
diff --git a/BaseTools/Tests/TestTools.py b/BaseTools/Tests/TestTools.py
index 4a70e92bcd..e838ae4294 100644
--- a/BaseTools/Tests/TestTools.py
+++ b/BaseTools/Tests/TestTools.py
@@ -1,7 +1,7 @@
## @file
# Utility functions and classes for BaseTools unit tests
#
-# Copyright (c) 2008, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2008 - 2012, Intel Corporation. All rights reserved.<BR>
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
@@ -41,21 +41,20 @@ def MakeTheTestSuite(localItems):
tests.append(item())
return lambda: unittest.TestSuite(tests)
-def GetBaseToolsPath():
+def GetBaseToolsPaths():
if sys.platform in ('win32', 'win64'):
- return os.path.join(BaseToolsDir, 'Bin', sys.platform.title())
- elif sys.platform in ('cygwin'):
- uname = os.popen('uname -sm').read().strip()
- for char in (' ', '/'):
- uname = uname.replace(char, '-')
- return os.path.join(BaseToolsDir, 'Bin', uname)
+ return [ os.path.join(BaseToolsDir, 'Bin', sys.platform.title()) ]
else:
uname = os.popen('uname -sm').read().strip()
for char in (' ', '/'):
uname = uname.replace(char, '-')
- return os.path.join(BaseToolsDir, 'BinWrappers', uname)
+ return [
+ os.path.join(BaseToolsDir, 'Bin', uname),
+ os.path.join(BaseToolsDir, 'BinWrappers', uname),
+ os.path.join(BaseToolsDir, 'BinWrappers', 'PosixLike')
+ ]
-BaseToolsBinPath = GetBaseToolsPath()
+BaseToolsBinPaths = GetBaseToolsPaths()
class BaseToolsTest(unittest.TestCase):
@@ -93,6 +92,14 @@ class BaseToolsTest(unittest.TestCase):
sys.stdout.write(self.ReadTmpFile(fileName))
sys.stdout.flush()
+ def FindToolBin(self, toolName):
+ for binPath in BaseToolsBinPaths:
+ bin = os.path.join(binPath, toolName)
+ if os.path.exists(bin):
+ break
+ assert os.path.exists(bin)
+ return bin
+
def RunTool(self, *args, **kwd):
if 'toolName' in kwd: toolName = kwd['toolName']
else: toolName = None
@@ -100,7 +107,7 @@ class BaseToolsTest(unittest.TestCase):
else: logFile = None
if toolName is None: toolName = self.toolName
- bin = os.path.join(self.baseToolsBins, toolName)
+ bin = self.FindToolBin(toolName)
if logFile is not None:
logFile = open(os.path.join(self.testDir, logFile), 'w')
popenOut = logFile
@@ -154,9 +161,9 @@ class BaseToolsTest(unittest.TestCase):
self.savedEnvPath = os.environ['PATH']
self.savedSysPath = sys.path[:]
- self.baseToolsBins = BaseToolsBinPath
- os.environ['PATH'] = \
- os.path.pathsep.join((os.environ['PATH'], self.baseToolsBins))
+ for binPath in BaseToolsBinPaths:
+ os.environ['PATH'] = \
+ os.path.pathsep.join((os.environ['PATH'], binPath))
self.testDir = TestTempDir
if not os.path.exists(self.testDir):