public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [Patch 1/1] BaseTools: fix the split output files root dir
@ 2021-02-01  1:52 Bob Feng
  0 siblings, 0 replies; only message in thread
From: Bob Feng @ 2021-02-01  1:52 UTC (permalink / raw)
  To: devel; +Cc: Liming Gao, Yuwei Chen

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@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Yuwei Chen <yuwei.chen@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


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2021-02-01  1:52 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-02-01  1:52 [Patch 1/1] BaseTools: fix the split output files root dir Bob Feng

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox