From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mx.groups.io with SMTP id smtpd.web08.27866.1612144330326059573 for ; Sun, 31 Jan 2021 17:52:10 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 134.134.136.65, mailfrom: bob.c.feng@intel.com) IronPort-SDR: NT9RI3I8A2XqJFEmFHJbZMos79PvSQKv5Q5XUGFzgAClrAvpCw75Wb9L77aUd9BcM6Hyia5wAO n6+S/c+/94yw== X-IronPort-AV: E=McAfee;i="6000,8403,9881"; a="180697826" X-IronPort-AV: E=Sophos;i="5.79,391,1602572400"; d="scan'208";a="180697826" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Jan 2021 17:52:09 -0800 IronPort-SDR: f36kcRdjXpn2CRBX5ly8XhFrfiEe1d0E+NilAJPpYMS9DoEL7znpO0H1R60Fmaw2+V5j4a6fM5 BPJ56SO2+wdw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.79,391,1602572400"; d="scan'208";a="432015844" Received: from shwdepsi1121.ccr.corp.intel.com ([10.239.158.32]) by orsmga001.jf.intel.com with ESMTP; 31 Jan 2021 17:52:08 -0800 From: "Bob Feng" To: devel@edk2.groups.io Cc: Liming Gao , Yuwei Chen Subject: [Patch 1/1] BaseTools: fix the split output files root dir Date: Mon, 1 Feb 2021 09:52:04 +0800 Message-Id: <20210201015204.1008-1-bob.c.feng@intel.com> X-Mailer: git-send-email 2.29.1.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Cc: Liming Gao Cc: Yuwei Chen --- 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