From: "Bob Feng" <bob.c.feng@intel.com>
To: devel@edk2.groups.io
Cc: Liming Gao <gaoliming@byosoft.com.cn>, Yuwei Chen <yuwei.chen@intel.com>
Subject: [Patch 1/1] BaseTools: fix the split output files root dir
Date: Mon, 1 Feb 2021 09:52:04 +0800 [thread overview]
Message-ID: <20210201015204.1008-1-bob.c.feng@intel.com> (raw)
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
reply other threads:[~2021-02-01 1:52 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210201015204.1008-1-bob.c.feng@intel.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox