[edk2-devel] [Patch 1/1] BaseTools: fix the split output files root dir

Bob Feng bob.c.feng at intel.com
Mon Feb 1 01:52:04 UTC 2021


If the output file path is a relative path, the split
tool will create the output file under the input file path.
But the expected behavior for this case is the output file
should be relative to the current directory. This patch will
fix this bug.

Signed-off-by: Bob Feng <bob.c.feng at intel.com>
Cc: Liming Gao <gaoliming at byosoft.com.cn>
Cc: Yuwei Chen <yuwei.chen at intel.com>
---
 BaseTools/Source/Python/Split/Split.py            | 2 +-
 BaseTools/Source/Python/tests/Split/test_split.py | 9 +++++----
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/BaseTools/Source/Python/Split/Split.py b/BaseTools/Source/Python/Split/Split.py
index 45a5a060474c..41196c347179 100644
--- a/BaseTools/Source/Python/Split/Split.py
+++ b/BaseTools/Source/Python/Split/Split.py
@@ -98,11 +98,11 @@ def splitFile(inputfile, position, outputdir=None, outputfile1=None, outputfile2
     Split the inputfile into outputfile1 and outputfile2 from the position.
     '''
     logger = logging.getLogger('Split')
 
     inputfile = os.path.abspath(inputfile)
-    workspace = os.path.dirname(inputfile)
+    workspace = os.getcwd()
     if not os.path.exists(inputfile):
         logger.error("File Not Found: %s" % inputfile)
         raise(Exception)
 
     if outputfile1 and outputfile2 and outputfile1 == outputfile2:
diff --git a/BaseTools/Source/Python/tests/Split/test_split.py b/BaseTools/Source/Python/tests/Split/test_split.py
index 82f71ecf5372..43602da3fc87 100644
--- a/BaseTools/Source/Python/tests/Split/test_split.py
+++ b/BaseTools/Source/Python/tests/Split/test_split.py
@@ -16,17 +16,18 @@ import Split.Split as sp
 import struct as st
 
 
 class TestSplit(unittest.TestCase):
     def setUp(self):
-        self.WORKSPACE = tempfile.mkdtemp()
-        self.binary_file = os.path.join(self.WORKSPACE, "Binary.bin")
+        self.tmpdir = tempfile.mkdtemp()
+        self.WORKSPACE = os.getcwd()
+        self.binary_file = os.path.join(self.tmpdir, "Binary.bin")
         self.create_inputfile()
 
     def tearDown(self):
-        if os.path.exists(self.WORKSPACE):
-            shutil.rmtree(self.WORKSPACE)
+        if os.path.exists(self.tmpdir):
+            shutil.rmtree(self.tmpdir)
 
     def test_splitFile_position(self):
         position = [-1, 0, 256, 512, 700, 1024, 2048]
         result = [(0, 1024), (0, 1024), (256, 768),
                   (512, 512), (700, 324), (1024, 0), (1024, 0)]
-- 
2.29.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#70992): https://edk2.groups.io/g/devel/message/70992
Mute This Topic: https://groups.io/mt/80274371/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-





More information about the edk2-devel-archive mailing list