|
From: <jlj...@us...> - 2012-04-03 20:14:37
|
Revision: 2515
http://edk2-buildtools.svn.sourceforge.net/edk2-buildtools/?rev=2515&view=rev
Author: jljusten
Date: 2012-04-03 20:14:31 +0000 (Tue, 03 Apr 2012)
Log Message:
-----------
BaseTools/Tests/TestTools.py: Look for tools in more places
When testing tools in non-Windows enviroments, the
tools can be found in 3 possible places:
1. BaseTools/Bin/`uname -sm`
2. BaseTools/BinWrappers/`uname -sm`
3. BaseTools/BinWrappers/PosixLike
Signed-off-by: Jordan Justen <jor...@in...>
Reviewed-by: Erik Bjorge <eri...@in...>
Modified Paths:
--------------
trunk/BaseTools/Tests/TestTools.py
Modified: trunk/BaseTools/Tests/TestTools.py
===================================================================
--- trunk/BaseTools/Tests/TestTools.py 2012-04-02 00:22:32 UTC (rev 2514)
+++ trunk/BaseTools/Tests/TestTools.py 2012-04-03 20:14:31 UTC (rev 2515)
@@ -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 @@
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 @@
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 @@
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 @@
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):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: Andrew F. <af...@ap...> - 2012-04-03 20:16:42
|
I don't see the error after your fix. Andrew Fish On Apr 3, 2012, at 1:14 PM, jlj...@us... wrote: > Revision: 2515 > http://edk2-buildtools.svn.sourceforge.net/edk2-buildtools/?rev=2515&view=rev > Author: jljusten > Date: 2012-04-03 20:14:31 +0000 (Tue, 03 Apr 2012) > Log Message: > ----------- > BaseTools/Tests/TestTools.py: Look for tools in more places > > When testing tools in non-Windows enviroments, the > tools can be found in 3 possible places: > 1. BaseTools/Bin/`uname -sm` > 2. BaseTools/BinWrappers/`uname -sm` > 3. BaseTools/BinWrappers/PosixLike > > Signed-off-by: Jordan Justen <jor...@in...> > Reviewed-by: Erik Bjorge <eri...@in...> > > Modified Paths: > -------------- > trunk/BaseTools/Tests/TestTools.py > > Modified: trunk/BaseTools/Tests/TestTools.py > =================================================================== > --- trunk/BaseTools/Tests/TestTools.py 2012-04-02 00:22:32 UTC (rev 2514) > +++ trunk/BaseTools/Tests/TestTools.py 2012-04-03 20:14:31 UTC (rev 2515) > @@ -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 @@ > 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 @@ > 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 @@ > 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 @@ > 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): > > This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. > > > ------------------------------------------------------------------------------ > Better than sec? Nothing is better than sec when it comes to > monitoring Big Data applications. Try Boundary one-second > resolution app monitoring today. Free. > http://p.sf.net/sfu/Boundary-dev2dev > _______________________________________________ > edk2-buildtools-commits mailing list > edk...@li... > https://lists.sourceforge.net/lists/listinfo/edk2-buildtools-commits |