summaryrefslogtreecommitdiffstats
path: root/BaseTools/Source/Python/UPT/UnitTest
diff options
context:
space:
mode:
authorLiming Gao <liming.gao@intel.com>2018-07-05 17:40:04 +0800
committerLiming Gao <liming.gao@intel.com>2018-07-09 10:25:47 +0800
commitf7496d717357b9af78414d19679b073403812340 (patch)
tree67621e65fd181bdf8a12d12e7706579beaaed0fb /BaseTools/Source/Python/UPT/UnitTest
parent39456d00f36e04b7e7efb208f350f4e83b6c3531 (diff)
downloadedk2-f7496d717357b9af78414d19679b073403812340.tar.gz
edk2-f7496d717357b9af78414d19679b073403812340.tar.bz2
edk2-f7496d717357b9af78414d19679b073403812340.zip
BaseTools: Clean up source files
1. Do not use tab characters 2. No trailing white space in one line 3. All files must end with CRLF Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Liming Gao <liming.gao@intel.com> Cc: Yonghong Zhu <yonghong.zhu@intel.com> Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
Diffstat (limited to 'BaseTools/Source/Python/UPT/UnitTest')
-rw-r--r--BaseTools/Source/Python/UPT/UnitTest/CommentGeneratingUnitTest.py464
-rw-r--r--BaseTools/Source/Python/UPT/UnitTest/CommentParsingUnitTest.py310
-rw-r--r--BaseTools/Source/Python/UPT/UnitTest/DecParserTest.py58
-rw-r--r--BaseTools/Source/Python/UPT/UnitTest/DecParserUnitTest.py146
-rw-r--r--BaseTools/Source/Python/UPT/UnitTest/InfBinarySectionTest.py66
5 files changed, 522 insertions, 522 deletions
diff --git a/BaseTools/Source/Python/UPT/UnitTest/CommentGeneratingUnitTest.py b/BaseTools/Source/Python/UPT/UnitTest/CommentGeneratingUnitTest.py
index 9c50d2dc60..3371ec3c2f 100644
--- a/BaseTools/Source/Python/UPT/UnitTest/CommentGeneratingUnitTest.py
+++ b/BaseTools/Source/Python/UPT/UnitTest/CommentGeneratingUnitTest.py
@@ -3,9 +3,9 @@
#
# Copyright (c) 2011 - 2018, 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 which accompanies this
-# distribution. The full text of the license may be found at
+# This program and the accompanying materials are licensed and made available
+# under the terms and conditions of the BSD License which accompanies this
+# distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
@@ -15,19 +15,19 @@ import os
import unittest
import Logger.Log as Logger
-from GenMetaFile.GenInfFile import GenGuidSections
+from GenMetaFile.GenInfFile import GenGuidSections
from GenMetaFile.GenInfFile import GenProtocolPPiSections
from GenMetaFile.GenInfFile import GenPcdSections
from GenMetaFile.GenInfFile import GenSpecialSections
from Library.CommentGenerating import GenGenericCommentF
-from Library.CommentGenerating import _GetHelpStr
+from Library.CommentGenerating import _GetHelpStr
from Object.POM.CommonObject import TextObject
from Object.POM.CommonObject import GuidObject
from Object.POM.CommonObject import ProtocolObject
from Object.POM.CommonObject import PpiObject
from Object.POM.CommonObject import PcdObject
from Object.POM.ModuleObject import HobObject
-
+
from Library.StringUtils import GetSplitValueList
from Library.DataType import TAB_SPACE_SPLIT
from Library.DataType import TAB_LANGUAGE_EN_US
@@ -46,7 +46,7 @@ class _GetHelpStrTest(unittest.TestCase):
def tearDown(self):
pass
-
+
#
# Normal case1: have one help text object with Lang = 'en-US'
#
@@ -55,11 +55,11 @@ class _GetHelpStrTest(unittest.TestCase):
HelpTextObj = TextObject()
HelpTextObj.SetLang(TAB_LANGUAGE_EN_US)
HelpTextObj.SetString(HelpStr)
-
+
HelpTextList = [HelpTextObj]
Result = _GetHelpStr(HelpTextList)
self.assertEqual(Result, HelpStr)
-
+
#
# Normal case2: have two help text object with Lang = 'en-US' and other
#
@@ -68,16 +68,16 @@ class _GetHelpStrTest(unittest.TestCase):
HelpTextObj = TextObject()
HelpTextObj.SetLang(TAB_LANGUAGE_ENG)
HelpTextObj.SetString(HelpStr)
-
+
HelpTextList = [HelpTextObj]
ExpectedStr = 'Hello world1'
HelpTextObj = TextObject()
HelpTextObj.SetLang(TAB_LANGUAGE_EN_US)
- HelpTextObj.SetString(ExpectedStr)
-
+ HelpTextObj.SetString(ExpectedStr)
+
HelpTextList.append(HelpTextObj)
-
+
Result = _GetHelpStr(HelpTextList)
self.assertEqual(Result, ExpectedStr)
@@ -89,16 +89,16 @@ class _GetHelpStrTest(unittest.TestCase):
HelpTextObj = TextObject()
HelpTextObj.SetLang('')
HelpTextObj.SetString(HelpStr)
-
+
HelpTextList = [HelpTextObj]
ExpectedStr = 'Hello world1'
HelpTextObj = TextObject()
HelpTextObj.SetLang(TAB_LANGUAGE_ENG)
- HelpTextObj.SetString(ExpectedStr)
-
+ HelpTextObj.SetString(ExpectedStr)
+
HelpTextList.append(HelpTextObj)
-
+
Result = _GetHelpStr(HelpTextList)
self.assertEqual(Result, ExpectedStr)
@@ -110,15 +110,15 @@ class _GetHelpStrTest(unittest.TestCase):
ExpectedStr = 'Hello world1'
HelpTextObj = TextObject()
HelpTextObj.SetLang(TAB_LANGUAGE_ENG)
- HelpTextObj.SetString(ExpectedStr)
+ HelpTextObj.SetString(ExpectedStr)
HelpTextList = [HelpTextObj]
-
+
HelpStr = 'Hello world'
HelpTextObj = TextObject()
HelpTextObj.SetLang('')
- HelpTextObj.SetString(HelpStr)
+ HelpTextObj.SetString(HelpStr)
HelpTextList.append(HelpTextObj)
-
+
Result = _GetHelpStr(HelpTextList)
self.assertEqual(Result, ExpectedStr)
@@ -130,27 +130,27 @@ class _GetHelpStrTest(unittest.TestCase):
ExpectedStr = 'Hello world1'
HelpTextObj = TextObject()
HelpTextObj.SetLang(TAB_LANGUAGE_EN_US)
- HelpTextObj.SetString(ExpectedStr)
+ HelpTextObj.SetString(ExpectedStr)
HelpTextList = [HelpTextObj]
-
+
HelpStr = 'Hello unknown world'
HelpTextObj = TextObject()
HelpTextObj.SetLang('')
- HelpTextObj.SetString(HelpStr)
+ HelpTextObj.SetString(HelpStr)
HelpTextList.append(HelpTextObj)
HelpStr = 'Hello mysterious world'
HelpTextObj = TextObject()
HelpTextObj.SetLang('')
- HelpTextObj.SetString(HelpStr)
+ HelpTextObj.SetString(HelpStr)
HelpTextList.append(HelpTextObj)
-
+
Result = _GetHelpStr(HelpTextList)
self.assertEqual(Result, ExpectedStr)
-
+
HelpTextList.sort()
self.assertEqual(Result, ExpectedStr)
-
+
HelpTextList.sort(reverse=True)
self.assertEqual(Result, ExpectedStr)
@@ -160,15 +160,15 @@ class _GetHelpStrTest(unittest.TestCase):
#
class GenGuidSectionsTest(unittest.TestCase):
def setUp(self):
- pass
+ pass
def tearDown(self):
pass
-
+
#
# This is the API to generate Guid Object to help UnitTest
#
- def GuidFactory(self, CName, FFE, Usage, GuidType, VariableName, HelpStr):
+ def GuidFactory(self, CName, FFE, Usage, GuidType, VariableName, HelpStr):
Guid = GuidObject()
Guid.SetCName(CName)
Guid.SetFeatureFlag(FFE)
@@ -180,22 +180,22 @@ class GenGuidSectionsTest(unittest.TestCase):
HelpTextObj.SetLang('')
HelpTextObj.SetString(HelpStr)
Guid.SetHelpTextList([HelpTextObj])
-
- return Guid
-
+
+ return Guid
+
#
# Normal case: have two GuidObject
#
def testNormalCase1(self):
GuidList = []
-
+
CName = 'Guid1'
FFE = 'FFE1'
Usage = 'PRODUCES'
GuidType = 'Event'
VariableName = ''
HelpStr = 'Usage comment line 1'
- Guid1 = self.GuidFactory(CName, FFE, Usage, GuidType,
+ Guid1 = self.GuidFactory(CName, FFE, Usage, GuidType,
VariableName, HelpStr)
GuidList.append(Guid1)
@@ -205,10 +205,10 @@ class GenGuidSectionsTest(unittest.TestCase):
GuidType = 'Variable'
VariableName = ''
HelpStr = 'Usage comment line 2'
- Guid1 = self.GuidFactory(CName, FFE, Usage, GuidType,
+ Guid1 = self.GuidFactory(CName, FFE, Usage, GuidType,
VariableName, HelpStr)
- GuidList.append(Guid1)
-
+ GuidList.append(Guid1)
+
Result = GenGuidSections(GuidList)
Expected = '''[Guids]
## PRODUCES ## Event # Usage comment line 1
@@ -221,14 +221,14 @@ Guid1|FFE1'''
#
def testNormalCase2(self):
GuidList = []
-
+
CName = 'Guid1'
FFE = 'FFE1'
Usage = 'PRODUCES'
GuidType = 'Event'
VariableName = ''
HelpStr = 'Usage comment line 1'
- Guid1 = self.GuidFactory(CName, FFE, Usage, GuidType,
+ Guid1 = self.GuidFactory(CName, FFE, Usage, GuidType,
VariableName, HelpStr)
GuidList.append(Guid1)
@@ -238,10 +238,10 @@ Guid1|FFE1'''
GuidType = 'UNDEFINED'
VariableName = ''
HelpStr = 'Generic comment line 1\n Generic comment line 2'
- Guid1 = self.GuidFactory(CName, FFE, Usage, GuidType,
+ Guid1 = self.GuidFactory(CName, FFE, Usage, GuidType,
VariableName, HelpStr)
- GuidList.append(Guid1)
-
+ GuidList.append(Guid1)
+
Result = GenGuidSections(GuidList)
Expected = '''[Guids]
## PRODUCES ## Event # Usage comment line 1
@@ -252,7 +252,7 @@ Guid1|FFE1'''
self.assertEqual(Result.strip(), Expected)
#
- # Normal case: have two GuidObject, one help goes to generic help,
+ # Normal case: have two GuidObject, one help goes to generic help,
# the other go into usage comment
#
def testNormalCase3(self):
@@ -264,20 +264,20 @@ Guid1|FFE1'''
GuidType = 'UNDEFINED'
VariableName = ''
HelpStr = 'Generic comment'
- Guid1 = self.GuidFactory(CName, FFE, Usage, GuidType,
+ Guid1 = self.GuidFactory(CName, FFE, Usage, GuidType,
VariableName, HelpStr)
- GuidList.append(Guid1)
-
+ GuidList.append(Guid1)
+
CName = 'Guid1'
FFE = 'FFE1'
Usage = 'PRODUCES'
GuidType = 'Event'
VariableName = ''
HelpStr = 'Usage comment line 1'
- Guid1 = self.GuidFactory(CName, FFE, Usage, GuidType,
+ Guid1 = self.GuidFactory(CName, FFE, Usage, GuidType,
VariableName, HelpStr)
GuidList.append(Guid1)
-
+
Result = GenGuidSections(GuidList)
Expected = '''[Guids]
# Generic comment
@@ -298,10 +298,10 @@ Guid1|FFE1'''
GuidType = 'UNDEFINED'
VariableName = ''
HelpStr = 'Generic comment line1 \n generic comment line 2'
- Guid1 = self.GuidFactory(CName, FFE, Usage, GuidType,
+ Guid1 = self.GuidFactory(CName, FFE, Usage, GuidType,
VariableName, HelpStr)
- GuidList.append(Guid1)
-
+ GuidList.append(Guid1)
+
Result = GenGuidSections(GuidList)
Expected = '''[Guids]
# Generic comment line1
@@ -315,17 +315,17 @@ Guid1|FFE1'''
#
def testNormalCase6(self):
GuidList = []
-
+
CName = 'Guid1'
FFE = 'FFE1'
Usage = 'PRODUCES'
GuidType = 'Event'
VariableName = ''
HelpStr = 'Usage comment line 1\n Usage comment line 2'
- Guid1 = self.GuidFactory(CName, FFE, Usage, GuidType,
+ Guid1 = self.GuidFactory(CName, FFE, Usage, GuidType,
VariableName, HelpStr)
GuidList.append(Guid1)
-
+
Result = GenGuidSections(GuidList)
Expected = '''[Guids]
Guid1|FFE1 ## PRODUCES ## Event # Usage comment line 1 Usage comment line 2
@@ -337,36 +337,36 @@ Guid1|FFE1 ## PRODUCES ## Event # Usage comment line 1 Usage comment line 2
#
def testNormalCase7(self):
GuidList = []
-
+
CName = 'Guid1'
FFE = 'FFE1'
Usage = 'UNDEFINED'
GuidType = 'UNDEFINED'
VariableName = ''
HelpStr = 'Usage comment line 1'
- Guid1 = self.GuidFactory(CName, FFE, Usage, GuidType,
+ Guid1 = self.GuidFactory(CName, FFE, Usage, GuidType,
VariableName, HelpStr)
GuidList.append(Guid1)
-
+
Result = GenGuidSections(GuidList)
Expected = '''[Guids]
Guid1|FFE1 # Usage comment line 1
'''
self.assertEqual(Result.strip(), Expected.strip())
-
+
#
# Normal case: have two GuidObject
#
def testNormalCase8(self):
GuidList = []
-
+
CName = 'Guid1'
FFE = 'FFE1'
Usage = 'PRODUCES'
GuidType = 'Event'
VariableName = ''
HelpStr = 'Usage comment line 1\n Usage comment line 2'
- Guid1 = self.GuidFactory(CName, FFE, Usage, GuidType,
+ Guid1 = self.GuidFactory(CName, FFE, Usage, GuidType,
VariableName, HelpStr)
GuidList.append(Guid1)
@@ -376,10 +376,10 @@ Guid1|FFE1 # Usage comment line 1
GuidType = 'Event'
VariableName = ''
HelpStr = 'Usage comment line 3'
- Guid1 = self.GuidFactory(CName, FFE, Usage, GuidType,
+ Guid1 = self.GuidFactory(CName, FFE, Usage, GuidType,
VariableName, HelpStr)
GuidList.append(Guid1)
-
+
Result = GenGuidSections(GuidList)
Expected = '''[Guids]
## PRODUCES ## Event # Usage comment line 1 Usage comment line 2
@@ -403,14 +403,14 @@ Guid1|FFE1
#
def testNormalCase10(self):
GuidList = []
-
+
CName = 'Guid1'
FFE = 'FFE1'
Usage = 'UNDEFINED'
GuidType = 'UNDEFINED'
VariableName = ''
HelpStr = ''
- Guid1 = self.GuidFactory(CName, FFE, Usage, GuidType,
+ Guid1 = self.GuidFactory(CName, FFE, Usage, GuidType,
VariableName, HelpStr)
GuidList.append(Guid1)
@@ -425,14 +425,14 @@ Guid1|FFE1
#
def testNormalCase11(self):
GuidList = []
-
+
CName = 'Guid1'
FFE = 'FFE1'
Usage = 'UNDEFINED'
GuidType = 'UNDEFINED'
VariableName = ''
HelpStr = 'general comment line 1'
- Guid1 = self.GuidFactory(CName, FFE, Usage, GuidType,
+ Guid1 = self.GuidFactory(CName, FFE, Usage, GuidType,
VariableName, HelpStr)
GuidList.append(Guid1)
@@ -442,7 +442,7 @@ Guid1|FFE1
GuidType = 'Event'
VariableName = ''
HelpStr = 'Usage comment line 3'
- Guid1 = self.GuidFactory(CName, FFE, Usage, GuidType,
+ Guid1 = self.GuidFactory(CName, FFE, Usage, GuidType,
VariableName, HelpStr)
GuidList.append(Guid1)
@@ -452,10 +452,10 @@ Guid1|FFE1
GuidType = 'UNDEFINED'
VariableName = ''
HelpStr = 'general comment line 2'
- Guid1 = self.GuidFactory(CName, FFE, Usage, GuidType,
+ Guid1 = self.GuidFactory(CName, FFE, Usage, GuidType,
VariableName, HelpStr)
GuidList.append(Guid1)
-
+
Result = GenGuidSections(GuidList)
Expected = '''[Guids]
# general comment line 1
@@ -470,14 +470,14 @@ Guid1|FFE1
#
def testNormalCase12(self):
GuidList = []
-
+
CName = 'Guid1'
FFE = 'FFE1'
Usage = 'PRODUCES'
GuidType = 'GUID'
VariableName = ''
HelpStr = ''
- Guid1 = self.GuidFactory(CName, FFE, Usage, GuidType,
+ Guid1 = self.GuidFactory(CName, FFE, Usage, GuidType,
VariableName, HelpStr)
GuidList.append(Guid1)
@@ -487,7 +487,7 @@ Guid1|FFE1
GuidType = 'Event'
VariableName = ''
HelpStr = ''
- Guid1 = self.GuidFactory(CName, FFE, Usage, GuidType,
+ Guid1 = self.GuidFactory(CName, FFE, Usage, GuidType,
VariableName, HelpStr)
GuidList.append(Guid1)
@@ -497,10 +497,10 @@ Guid1|FFE1
GuidType = 'Event'
VariableName = ''
HelpStr = ''
- Guid1 = self.GuidFactory(CName, FFE, Usage, GuidType,
+ Guid1 = self.GuidFactory(CName, FFE, Usage, GuidType,
VariableName, HelpStr)
GuidList.append(Guid1)
-
+
Result = GenGuidSections(GuidList)
Expected = '''[Guids]
## PRODUCES ## GUID
@@ -509,17 +509,17 @@ Guid1|FFE1
Guid1|FFE1
'''
self.assertEqual(Result.strip(), Expected.strip())
-
+
#
# Test GenProtocolPPiSections
#
class GenProtocolPPiSectionsTest(unittest.TestCase):
def setUp(self):
- pass
+ pass
def tearDown(self):
pass
-
+
#
# This is the API to generate Protocol/Ppi Object to help UnitTest
#
@@ -528,7 +528,7 @@ class GenProtocolPPiSectionsTest(unittest.TestCase):
Object = ProtocolObject()
else:
Object = PpiObject()
-
+
Object.SetCName(CName)
Object.SetFeatureFlag(FFE)
Object.SetUsage(Usage)
@@ -538,8 +538,8 @@ class GenProtocolPPiSectionsTest(unittest.TestCase):
HelpTextObj.SetLang('')
HelpTextObj.SetString(HelpStr)
Object.SetHelpTextList([HelpTextObj])
-
- return Object
+
+ return Object
# Usage Notify Help INF Comment
#1 UNDEFINED true Present ## UNDEFINED ## NOTIFY # Help
@@ -557,19 +557,19 @@ class GenProtocolPPiSectionsTest(unittest.TestCase):
def testNormalCase1(self):
ObjectList = []
-
+
CName = 'Guid1'
FFE = 'FFE1'
-
+
Usage = 'UNDEFINED'
Notify = True
HelpStr = 'Help'
IsProtocol = True
- Object = self.ObjectFactory(CName, FFE, Usage, Notify,
+ Object = self.ObjectFactory(CName, FFE, Usage, Notify,
HelpStr, IsProtocol)
ObjectList.append(Object)
-
-
+
+
Result = GenProtocolPPiSections(ObjectList, IsProtocol)
Expected = '''[Protocols]
Guid1|FFE1 ## UNDEFINED ## NOTIFY # Help'''
@@ -577,11 +577,11 @@ Guid1|FFE1 ## UNDEFINED ## NOTIFY # Help'''
IsProtocol = False
ObjectList = []
- Object = self.ObjectFactory(CName, FFE, Usage, Notify,
+ Object = self.ObjectFactory(CName, FFE, Usage, Notify,
HelpStr, IsProtocol)
ObjectList.append(Object)
-
-
+
+
Result = GenProtocolPPiSections(ObjectList, IsProtocol)
Expected = '''[Ppis]
Guid1|FFE1 ## UNDEFINED ## NOTIFY # Help'''
@@ -589,19 +589,19 @@ Guid1|FFE1 ## UNDEFINED ## NOTIFY # Help'''
def testNormalCase2(self):
ObjectList = []
-
+
CName = 'Guid1'
FFE = 'FFE1'
-
+
Usage = 'UNDEFINED'
Notify = True
HelpStr = ''
IsProtocol = True
- Object = self.ObjectFactory(CName, FFE, Usage, Notify,
+ Object = self.ObjectFactory(CName, FFE, Usage, Notify,
HelpStr, IsProtocol)
ObjectList.append(Object)
-
-
+
+
Result = GenProtocolPPiSections(ObjectList, IsProtocol)
Expected = '''[Protocols]
Guid1|FFE1 ## UNDEFINED ## NOTIFY'''
@@ -609,19 +609,19 @@ Guid1|FFE1 ## UNDEFINED ## NOTIFY'''
def testNormalCase3(self):
ObjectList = []
-
+
CName = 'Guid1'
FFE = 'FFE1'
-
+
Usage = 'UNDEFINED'
Notify = False
HelpStr = 'Help'
IsProtocol = True
- Object = self.ObjectFactory(CName, FFE, Usage, Notify,
+ Object = self.ObjectFactory(CName, FFE, Usage, Notify,
HelpStr, IsProtocol)
ObjectList.append(Object)
-
-
+
+
Result = GenProtocolPPiSections(ObjectList, IsProtocol)
Expected = '''[Protocols]
Guid1|FFE1 ## UNDEFINED # Help'''
@@ -629,19 +629,19 @@ Guid1|FFE1 ## UNDEFINED # Help'''
def testNormalCase4(self):
ObjectList = []
-
+
CName = 'Guid1'
FFE = 'FFE1'
-
+
Usage = 'UNDEFINED'
Notify = False
HelpStr = ''
IsProtocol = True
- Object = self.ObjectFactory(CName, FFE, Usage, Notify,
+ Object = self.ObjectFactory(CName, FFE, Usage, Notify,
HelpStr, IsProtocol)
ObjectList.append(Object)
-
-
+
+
Result = GenProtocolPPiSections(ObjectList, IsProtocol)
Expected = '''[Protocols]
Guid1|FFE1 ## UNDEFINED'''
@@ -649,19 +649,19 @@ Guid1|FFE1 ## UNDEFINED'''
def testNormalCase5(self):
ObjectList = []
-
+
CName = 'Guid1'
FFE = 'FFE1'
-
+
Usage = 'UNDEFINED'
Notify = ''
HelpStr = 'Help'
IsProtocol = True
- Object = self.ObjectFactory(CName, FFE, Usage, Notify,
+ Object = self.ObjectFactory(CName, FFE, Usage, Notify,
HelpStr, IsProtocol)
ObjectList.append(Object)
-
-
+
+
Result = GenProtocolPPiSections(ObjectList, IsProtocol)
Expected = '''[Protocols]
Guid1|FFE1 # Help'''
@@ -669,19 +669,19 @@ Guid1|FFE1 # Help'''
def testNormalCase6(self):
ObjectList = []
-
+
CName = 'Guid1'
FFE = 'FFE1'
-
+
Usage = 'UNDEFINED'
Notify = ''
HelpStr = ''
IsProtocol = True
- Object = self.ObjectFactory(CName, FFE, Usage, Notify,
+ Object = self.ObjectFactory(CName, FFE, Usage, Notify,
HelpStr, IsProtocol)
ObjectList.append(Object)
-
-
+
+
Result = GenProtocolPPiSections(ObjectList, IsProtocol)
Expected = '''[Protocols]
Guid1|FFE1'''
@@ -689,19 +689,19 @@ Guid1|FFE1'''
def testNormalCase7(self):
ObjectList = []
-
+
CName = 'Guid1'
FFE = 'FFE1'
-
+
Usage = 'PRODUCES'
Notify = True
HelpStr = 'Help'
IsProtocol = True
- Object = self.ObjectFactory(CName, FFE, Usage, Notify,
+ Object = self.ObjectFactory(CName, FFE, Usage, Notify,
HelpStr, IsProtocol)
ObjectList.append(Object)
-
-
+
+
Result = GenProtocolPPiSections(ObjectList, IsProtocol)
Expected = '''[Protocols]
Guid1|FFE1 ## PRODUCES ## NOTIFY # Help'''
@@ -709,19 +709,19 @@ Guid1|FFE1 ## PRODUCES ## NOTIFY # Help'''
def testNormalCase8(self):
ObjectList = []
-
+
CName = 'Guid1'
FFE = 'FFE1'
-
+
Usage = 'PRODUCES'
Notify = True
HelpStr = ''
IsProtocol = True
- Object = self.ObjectFactory(CName, FFE, Usage, Notify,
+ Object = self.ObjectFactory(CName, FFE, Usage, Notify,
HelpStr, IsProtocol)
ObjectList.append(Object)
-
-
+
+
Result = GenProtocolPPiSections(ObjectList, IsProtocol)
Expected = '''[Protocols]
Guid1|FFE1 ## PRODUCES ## NOTIFY'''
@@ -729,19 +729,19 @@ Guid1|FFE1 ## PRODUCES ## NOTIFY'''
def testNormalCase9(self):
ObjectList = []
-
+
CName = 'Guid1'
FFE = 'FFE1'
-
+
Usage = 'PRODUCES'
Notify = False
HelpStr = 'Help'
IsProtocol = True
- Object = self.ObjectFactory(CName, FFE, Usage, Notify,
+ Object = self.ObjectFactory(CName, FFE, Usage, Notify,
HelpStr, IsProtocol)
ObjectList.append(Object)
-
-
+
+
Result = GenProtocolPPiSections(ObjectList, IsProtocol)
Expected = '''[Protocols]
Guid1|FFE1 ## PRODUCES # Help'''
@@ -749,19 +749,19 @@ Guid1|FFE1 ## PRODUCES # Help'''
def testNormalCaseA(self):
ObjectList = []
-
+
CName = 'Guid1'
FFE = 'FFE1'
-
+
Usage = 'PRODUCES'
Notify = False
HelpStr = ''
IsProtocol = True
- Object = self.ObjectFactory(CName, FFE, Usage, Notify,
+ Object = self.ObjectFactory(CName, FFE, Usage, Notify,
HelpStr, IsProtocol)
ObjectList.append(Object)
-
-
+
+
Result = GenProtocolPPiSections(ObjectList, IsProtocol)
Expected = '''[Protocols]
Guid1|FFE1 ## PRODUCES'''
@@ -769,19 +769,19 @@ Guid1|FFE1 ## PRODUCES'''
def testNormalCaseB(self):
ObjectList = []
-
+
CName = 'Guid1'
FFE = 'FFE1'
-
+
Usage = 'PRODUCES'
Notify = ''
HelpStr = 'Help'
IsProtocol = True
- Object = self.ObjectFactory(CName, FFE, Usage, Notify,
+ Object = self.ObjectFactory(CName, FFE, Usage, Notify,
HelpStr, IsProtocol)
ObjectList.append(Object)
-
-
+
+
Result = GenProtocolPPiSections(ObjectList, IsProtocol)
Expected = '''[Protocols]
Guid1|FFE1 ## PRODUCES # Help'''
@@ -789,19 +789,19 @@ Guid1|FFE1 ## PRODUCES # Help'''
def testNormalCaseC(self):
ObjectList = []
-
+
CName = 'Guid1'
FFE = 'FFE1'
-
+
Usage = 'PRODUCES'
Notify = ''
HelpStr = ''
IsProtocol = True
- Object = self.ObjectFactory(CName, FFE, Usage, Notify,
+ Object = self.ObjectFactory(CName, FFE, Usage, Notify,
HelpStr, IsProtocol)
ObjectList.append(Object)
-
-
+
+
Result = GenProtocolPPiSections(ObjectList, IsProtocol)
Expected = '''[Protocols]
Guid1|FFE1 ## PRODUCES'''
@@ -812,18 +812,18 @@ Guid1|FFE1 ## PRODUCES'''
#
class GenPcdSectionsTest(unittest.TestCase):
def setUp(self):
- pass
+ pass
def tearDown(self):
pass
-
+
#
# This is the API to generate Pcd Object to help UnitTest
#
def ObjectFactory(self, ItemType, TSCName, CName, DValue, FFE, Usage, Str):
Object = PcdObject()
HelpStr = Str
-
+
Object.SetItemType(ItemType)
Object.SetTokenSpaceGuidCName(TSCName)
Object.SetCName(CName)
@@ -835,8 +835,8 @@ class GenPcdSectionsTest(unittest.TestCase):
HelpTextObj.SetLang('')
HelpTextObj.SetString(HelpStr)
Object.SetHelpTextList([HelpTextObj])
-
- return Object
+
+ return Object
# Usage Help INF Comment
@@ -852,14 +852,14 @@ class GenPcdSectionsTest(unittest.TestCase):
CName = 'CName'
DValue = 'DValue'
FFE = 'FFE'
-
+
Usage = 'UNDEFINED'
Str = 'Help'
-
- Object = self.ObjectFactory(ItemType, TSCName, CName, DValue, FFE,
+
+ Object = self.ObjectFactory(ItemType, TSCName, CName, DValue, FFE,
Usage, Str)
ObjectList.append(Object)
-
+
Result = GenPcdSections(ObjectList)
Expected = \
'[Pcd]\n' + \
@@ -873,14 +873,14 @@ class GenPcdSectionsTest(unittest.TestCase):
CName = 'CName'
DValue = 'DValue'
FFE = 'FFE'
-
+
Usage = 'UNDEFINED'
Str = ''
-
- Object = self.ObjectFactory(ItemType, TSCName, CName, DValue, FFE,
+
+ Object = self.ObjectFactory(ItemType, TSCName, CName, DValue, FFE,
Usage, Str)
ObjectList.append(Object)
-
+
Result = GenPcdSections(ObjectList)
Expected = '[Pcd]\nTSCName.CName|DValue|FFE'
self.assertEqual(Result.strip(), Expected)
@@ -892,14 +892,14 @@ class GenPcdSectionsTest(unittest.TestCase):
CName = 'CName'
DValue = 'DValue'
FFE = 'FFE'
-
+
Usage = 'CONSUMES'
Str = 'Help'
-
- Object = self.ObjectFactory(ItemType, TSCName, CName, DValue, FFE,
+
+ Object = self.ObjectFactory(ItemType, TSCName, CName, DValue, FFE,
Usage, Str)
ObjectList.append(Object)
-
+
Result = GenPcdSections(ObjectList)
Expected = '[Pcd]\nTSCName.CName|DValue|FFE ## CONSUMES # Help'
self.assertEqual(Result.strip(), Expected)
@@ -911,14 +911,14 @@ class GenPcdSectionsTest(unittest.TestCase):
CName = 'CName'
DValue = 'DValue'
FFE = 'FFE'
-
+
Usage = 'CONSUMES'
Str = ''
-
- Object = self.ObjectFactory(ItemType, TSCName, CName, DValue, FFE,
+
+ Object = self.ObjectFactory(ItemType, TSCName, CName, DValue, FFE,
Usage, Str)
ObjectList.append(Object)
-
+
Result = GenPcdSections(ObjectList)
Expected = '[Pcd]\nTSCName.CName|DValue|FFE ## CONSUMES'
self.assertEqual(Result.strip(), Expected)
@@ -933,13 +933,13 @@ class GenPcdSectionsTest(unittest.TestCase):
CName = 'CName'
DValue = 'DValue'
FFE = 'FFE'
-
+
Usage = 'CONSUMES'
Str = 'commment line 1\ncomment line 2'
- Object = self.ObjectFactory(ItemType, TSCName, CName, DValue, FFE,
+ Object = self.ObjectFactory(ItemType, TSCName, CName, DValue, FFE,
Usage, Str)
ObjectList.append(Object)
-
+
Result = GenPcdSections(ObjectList)
Expected = '''[Pcd]
TSCName.CName|DValue|FFE ## CONSUMES # commment line 1 comment line 2'''
@@ -955,19 +955,19 @@ TSCName.CName|DValue|FFE ## CONSUMES # commment line 1 comment line 2'''
CName = 'CName'
DValue = 'DValue'
FFE = 'FFE'
-
+
Usage = 'UNDEFINED'
Str = 'commment line 1\ncomment line 2'
- Object = self.ObjectFactory(ItemType, TSCName, CName, DValue, FFE,
+ Object = self.ObjectFactory(ItemType, TSCName, CName, DValue, FFE,
Usage, Str)
ObjectList.append(Object)
Usage = 'UNDEFINED'
Str = 'commment line 3'
- Object = self.ObjectFactory(ItemType, TSCName, CName, DValue, FFE,
+ Object = self.ObjectFactory(ItemType, TSCName, CName, DValue, FFE,
Usage, Str)
ObjectList.append(Object)
-
+
Result = GenPcdSections(ObjectList)
Expected = '''[Pcd]
# commment line 1
@@ -986,25 +986,25 @@ TSCName.CName|DValue|FFE'''
CName = 'CName'
DValue = 'DValue'
FFE = 'FFE'
-
+
Usage = 'UNDEFINED'
Str = 'commment line 1\ncomment line 2'
- Object = self.ObjectFactory(ItemType, TSCName, CName, DValue, FFE,
+ Object = self.ObjectFactory(ItemType, TSCName, CName, DValue, FFE,
Usage, Str)
ObjectList.append(Object)
Usage = 'CONSUMES'
Str = 'Foo'
- Object = self.ObjectFactory(ItemType, TSCName, CName, DValue, FFE,
+ Object = self.ObjectFactory(ItemType, TSCName, CName, DValue, FFE,
Usage, Str)
ObjectList.append(Object)
-
+
Usage = 'UNDEFINED'
Str = 'commment line 3'
- Object = self.ObjectFactory(ItemType, TSCName, CName, DValue, FFE,
+ Object = self.ObjectFactory(ItemType, TSCName, CName, DValue, FFE,
Usage, Str)
ObjectList.append(Object)
-
+
Result = GenPcdSections(ObjectList)
Expected = '''[Pcd]
# commment line 1
@@ -1028,13 +1028,13 @@ TSCName.CName|DValue|FFE'''
CName = 'CName'
DValue = 'DValue'
FFE = 'FFE'
-
+
Usage = 'CONSUMES'
Str = 'commment line 1\ncomment line 2'
- Object = self.ObjectFactory(ItemType, TSCName, CName, DValue, FFE,
+ Object = self.ObjectFactory(ItemType, TSCName, CName, DValue, FFE,
Usage, Str)
ObjectList.append(Object)
-
+
Result = GenPcdSections(ObjectList)
Expected = '''[FeaturePcd]
# commment line 1
@@ -1052,13 +1052,13 @@ TSCName.CName|DValue|FFE'''
CName = 'CName'
DValue = 'DValue'
FFE = 'FFE'
-
+
Usage = 'CONSUMES'
Str = ''
- Object = self.ObjectFactory(ItemType, TSCName, CName, DValue, FFE,
+ Object = self.ObjectFactory(ItemType, TSCName, CName, DValue, FFE,
Usage, Str)
ObjectList.append(Object)
-
+
Result = GenPcdSections(ObjectList)
Expected = '''[FeaturePcd]
TSCName.CName|DValue|FFE'''
@@ -1074,13 +1074,13 @@ TSCName.CName|DValue|FFE'''
CName = 'CName'
DValue = 'DValue'
FFE = 'FFE'
-
+
Usage = 'PRODUCES'
Str = 'commment line 1\ncomment line 2'
- Object = self.ObjectFactory(ItemType, TSCName, CName, DValue, FFE,
+ Object = self.ObjectFactory(ItemType, TSCName, CName, DValue, FFE,
Usage, Str)
ObjectList.append(Object)
-
+
Result = GenPcdSections(ObjectList)
Expected = '''
@@ -1097,28 +1097,28 @@ TSCName.CName|DValue|FFE
#
class GenHobSectionsTest(unittest.TestCase):
def setUp(self):
- pass
+ pass
def tearDown(self):
pass
-
+
#
# This is the API to generate Event Object to help UnitTest
#
def ObjectFactory(self, SupArchList, Type, Usage, Str):
Object = HobObject()
HelpStr = Str
-
+
Object.SetHobType(Type)
Object.SetUsage(Usage)
Object.SetSupArchList(SupArchList)
-
+
HelpTextObj = TextObject()
HelpTextObj.SetLang('')
HelpTextObj.SetString(HelpStr)
Object.SetHelpTextList([HelpTextObj])
-
- return Object
+
+ return Object
def testNormalCase1(self):
ObjectList = []
@@ -1126,10 +1126,10 @@ class GenHobSectionsTest(unittest.TestCase):
Type = 'Foo'
Usage = 'UNDEFINED'
Str = 'Help'
-
+
Object = self.ObjectFactory(SupArchList, Type, Usage, Str)
ObjectList.append(Object)
-
+
Result = GenSpecialSections(ObjectList, 'Hob')
Expected = '''# [Hob.X64]
# ##
@@ -1147,10 +1147,10 @@ class GenHobSectionsTest(unittest.TestCase):
Type = 'Foo'
Usage = 'UNDEFINED'
Str = 'Help'
-
+
Object = self.ObjectFactory(SupArchList, Type, Usage, Str)
ObjectList.append(Object)
-
+
Result = GenSpecialSections(ObjectList, 'Hob')
Expected = '''# [Hob]
# ##
@@ -1161,17 +1161,17 @@ class GenHobSectionsTest(unittest.TestCase):
#
'''
self.assertEqual(Result, Expected)
-
+
def testNormalCase3(self):
ObjectList = []
SupArchList = ['X64']
Type = 'Foo'
Usage = 'UNDEFINED'
Str = '\nComment Line 1\n\n'
-
+
Object = self.ObjectFactory(SupArchList, Type, Usage, Str)
ObjectList.append(Object)
-
+
Result = GenSpecialSections(ObjectList, 'Hob')
Expected = '''# [Hob.X64]
# ##
@@ -1189,10 +1189,10 @@ class GenHobSectionsTest(unittest.TestCase):
Type = 'Foo'
Usage = 'UNDEFINED'
Str = '\nComment Line 1\n'
-
+
Object = self.ObjectFactory(SupArchList, Type, Usage, Str)
ObjectList.append(Object)
-
+
Result = GenSpecialSections(ObjectList, 'Hob')
Expected = '''# [Hob.X64]
# ##
@@ -1210,10 +1210,10 @@ class GenHobSectionsTest(unittest.TestCase):
Type = 'Foo'
Usage = 'UNDEFINED'
Str = 'Comment Line 1\n\n'
-
+
Object = self.ObjectFactory(SupArchList, Type, Usage, Str)
ObjectList.append(Object)
-
+
Result = GenSpecialSections(ObjectList, 'Hob')
Expected = '''# [Hob.X64]
# ##
@@ -1231,17 +1231,17 @@ class GenHobSectionsTest(unittest.TestCase):
Type = 'Foo'
Usage = 'UNDEFINED'
Str = ''
-
+
Object = self.ObjectFactory(SupArchList, Type, Usage, Str)
ObjectList.append(Object)
-
+
Result = GenSpecialSections(ObjectList, 'Hob')
Expected = '''# [Hob.X64]
# Foo ## UNDEFINED
#
#
'''
- self.assertEqual(Result, Expected)
+ self.assertEqual(Result, Expected)
def testNormalCase7(self):
ObjectList = []
@@ -1250,10 +1250,10 @@ class GenHobSectionsTest(unittest.TestCase):
Usage = 'UNDEFINED'
Str = '\nNew Stack HoB'
-
+
Object = self.ObjectFactory(SupArchList, Type, Usage, Str)
ObjectList.append(Object)
-
+
Result = GenSpecialSections(ObjectList, 'Hob')
Expected = '''# [Hob.X64]
# ##
@@ -1272,10 +1272,10 @@ class GenHobSectionsTest(unittest.TestCase):
Usage = 'UNDEFINED'
Str = '\nNew Stack HoB\n\nTail Comment'
-
+
Object = self.ObjectFactory(SupArchList, Type, Usage, Str)
ObjectList.append(Object)
-
+
Result = GenSpecialSections(ObjectList, 'Hob')
Expected = '''# [Hob.X64]
# ##
@@ -1287,7 +1287,7 @@ class GenHobSectionsTest(unittest.TestCase):
#
#
'''
- self.assertEqual(Result, Expected)
+ self.assertEqual(Result, Expected)
def testNormalCase9(self):
ObjectList = []
@@ -1296,10 +1296,10 @@ class GenHobSectionsTest(unittest.TestCase):
Usage = 'UNDEFINED'
Str = '\n\n'
-
+
Object = self.ObjectFactory(SupArchList, Type, Usage, Str)
ObjectList.append(Object)
-
+
Result = GenSpecialSections(ObjectList, 'Hob')
Expected = '''# [Hob.X64]
# ##
@@ -1309,7 +1309,7 @@ class GenHobSectionsTest(unittest.TestCase):
#
#
'''
- self.assertEqual(Result, Expected)
+ self.assertEqual(Result, Expected)
def testNormalCase10(self):
ObjectList = []
@@ -1320,7 +1320,7 @@ class GenHobSectionsTest(unittest.TestCase):
Object = self.ObjectFactory(SupArchList, Type, Usage, Str)
ObjectList.append(Object)
-
+
Result = GenSpecialSections(ObjectList, 'Hob')
Expected = '''# [Hob.X64]
# ##
@@ -1330,7 +1330,7 @@ class GenHobSectionsTest(unittest.TestCase):
#
#
'''
- self.assertEqual(Result, Expected)
+ self.assertEqual(Result, Expected)
def testNormalCase11(self):
ObjectList = []
@@ -1341,7 +1341,7 @@ class GenHobSectionsTest(unittest.TestCase):
Object = self.ObjectFactory(SupArchList, Type, Usage, Str)
ObjectList.append(Object)
-
+
Result = GenSpecialSections(ObjectList, 'Hob')
Expected = '''# [Hob.X64]
# ##
@@ -1351,7 +1351,7 @@ class GenHobSectionsTest(unittest.TestCase):
#
#
'''
- self.assertEqual(Result, Expected)
+ self.assertEqual(Result, Expected)
def testNormalCase12(self):
ObjectList = []
@@ -1362,7 +1362,7 @@ class GenHobSectionsTest(unittest.TestCase):
Object = self.ObjectFactory(SupArchList, Type, Usage, Str)
ObjectList.append(Object)
-
+
Result = GenSpecialSections(ObjectList, 'Hob')
Expected = '''# [Hob.X64]
# ##
@@ -1373,18 +1373,18 @@ class GenHobSectionsTest(unittest.TestCase):
#
#
'''
- self.assertEqual(Result, Expected)
-
+ self.assertEqual(Result, Expected)
+
#
# Test GenGenericCommentF
#
class GenGenericCommentFTest(unittest.TestCase):
def setUp(self):
- pass
+ pass
def tearDown(self):
pass
-
+
def testNormalCase1(self):
CommentLines = 'Comment Line 1'
Result = GenGenericCommentF(CommentLines)
@@ -1395,26 +1395,26 @@ class GenGenericCommentFTest(unittest.TestCase):
CommentLines = '\n'
Result = GenGenericCommentF(CommentLines)
Expected = '#\n'
- self.assertEqual(Result, Expected)
+ self.assertEqual(Result, Expected)
def testNormalCase3(self):
CommentLines = '\n\n\n'
Result = GenGenericCommentF(CommentLines)
Expected = '#\n#\n#\n'
- self.assertEqual(Result, Expected)
+ self.assertEqual(Result, Expected)
def testNormalCase4(self):
CommentLines = 'coment line 1\n'
Result = GenGenericCommentF(CommentLines)
Expected = '# coment line 1\n'
- self.assertEqual(Result, Expected)
-
+ self.assertEqual(Result, Expected)
+
def testNormalCase5(self):
CommentLines = 'coment line 1\n coment line 2\n'
Result = GenGenericCommentF(CommentLines)
Expected = '# coment line 1\n# coment line 2\n'
- self.assertEqual(Result, Expected)
-
+ self.assertEqual(Result, Expected)
+
if __name__ == '__main__':
Logger.Initialize()
- unittest.main() \ No newline at end of file
+ unittest.main()
diff --git a/BaseTools/Source/Python/UPT/UnitTest/CommentParsingUnitTest.py b/BaseTools/Source/Python/UPT/UnitTest/CommentParsingUnitTest.py
index 4593506e58..e719567f99 100644
--- a/BaseTools/Source/Python/UPT/UnitTest/CommentParsingUnitTest.py
+++ b/BaseTools/Source/Python/UPT/UnitTest/CommentParsingUnitTest.py
@@ -3,9 +3,9 @@
#
# Copyright (c) 2011 - 2018, 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 which accompanies this
-# distribution. The full text of the license may be found at
+# This program and the accompanying materials are licensed and made available
+# under the terms and conditions of the BSD License which accompanies this
+# distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
@@ -32,7 +32,7 @@ class ParseHeaderCommentSectionTest(unittest.TestCase):
def tearDown(self):
pass
-
+
#
# Normal case1: have license/copyright/license above @file
#
@@ -42,36 +42,36 @@ class ParseHeaderCommentSectionTest(unittest.TestCase):
# License2
#
## @file
- # example abstract
- #
+ # example abstract
+ #
# example description
- #
- # Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
- #
- # License3
+ #
+ # Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
+ #
+ # License3
#'''
-
+
CommentList = GetSplitValueList(TestCommentLines1, "\n")
LineNum = 0
TestCommentLinesList = []
for Comment in CommentList:
LineNum += 1
TestCommentLinesList.append((Comment, LineNum))
-
+
Abstract, Description, Copyright, License = \
ParseHeaderCommentSection(TestCommentLinesList, "PhonyFile")
-
+
ExpectedAbstract = 'example abstract'
self.assertEqual(Abstract, ExpectedAbstract)
-
+
ExpectedDescription = 'example description'
self.assertEqual(Description, ExpectedDescription)
-
+
ExpectedCopyright = \
'Copyright (c) 2007 - 2010,'\
' Intel Corporation. All rights reserved.<BR>'
self.assertEqual(Copyright, ExpectedCopyright)
-
+
ExpectedLicense = 'License1\nLicense2\n\nLicense3'
self.assertEqual(License, ExpectedLicense)
@@ -84,41 +84,41 @@ class ParseHeaderCommentSectionTest(unittest.TestCase):
# License2
#
## @file
- # example abstract
- #
+ # example abstract
+ #
# example description
#
- #Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
+ #Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
#
##'''
-
+
CommentList = GetSplitValueList(TestCommentLines2, "\n")
LineNum = 0
TestCommentLinesList = []
for Comment in CommentList:
LineNum += 1
TestCommentLinesList.append((Comment, LineNum))
-
+
Abstract, Description, Copyright, License = \
ParseHeaderCommentSection(TestCommentLinesList, "PhonyFile")
-
+
ExpectedAbstract = 'example abstract'
self.assertEqual(Abstract, ExpectedAbstract)
-
+
ExpectedDescription = 'example description'
self.assertEqual(Description, ExpectedDescription)
-
+
ExpectedCopyright = \
- 'Copyright (c) 2007 - 2010, Intel Corporation.'\
+ 'Copyright (c) 2007 - 2018, Intel Corporation.'\
' All rights reserved.<BR>'
self.assertEqual(Copyright, ExpectedCopyright)
-
+
ExpectedLicense = 'License1\nLicense2'
self.assertEqual(License, ExpectedLicense)
-
+
#
- # Normal case2: have license/copyright/license above @file,
+ # Normal case2: have license/copyright/license above @file,
# but no abstract/description
#
def testNormalCase3(self):
@@ -126,41 +126,41 @@ class ParseHeaderCommentSectionTest(unittest.TestCase):
''' # License1
# License2
#
- ## @file
- # Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
+ ## @file
+ # Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
#
# License3 Line1
# License3 Line2
##'''
-
+
CommentList = GetSplitValueList(TestCommentLines3, "\n")
LineNum = 0
TestCommentLinesList = []
for Comment in CommentList:
LineNum += 1
TestCommentLinesList.append((Comment, LineNum))
-
+
Abstract, Description, Copyright, License = \
ParseHeaderCommentSection(TestCommentLinesList, "PhonyFile")
-
+
ExpectedAbstract = ''
self.assertEqual(Abstract, ExpectedAbstract)
-
+
ExpectedDescription = ''
self.assertEqual(Description, ExpectedDescription)
-
+
ExpectedCopyright = \
'Copyright (c) 2007 - 2010,'\
' Intel Corporation. All rights reserved.<BR>'
self.assertEqual(Copyright, ExpectedCopyright)
-
+
ExpectedLicense = \
'License1\n' \
'License2\n\n' \
'License3 Line1\n' \
'License3 Line2'
- self.assertEqual(License, ExpectedLicense)
-
+ self.assertEqual(License, ExpectedLicense)
+
#
# Normal case4: format example in spec
#
@@ -172,33 +172,33 @@ class ParseHeaderCommentSectionTest(unittest.TestCase):
#
# Description
#
- # Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
+ # Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
#
# License
#
##'''
-
+
CommentList = GetSplitValueList(TestCommentLines, "\n")
LineNum = 0
TestCommentLinesList = []
for Comment in CommentList:
LineNum += 1
TestCommentLinesList.append((Comment, LineNum))
-
+
Abstract, Description, Copyright, License = \
ParseHeaderCommentSection(TestCommentLinesList, "PhonyFile")
-
+
ExpectedAbstract = 'Abstract'
self.assertEqual(Abstract, ExpectedAbstract)
-
+
ExpectedDescription = 'Description'
self.assertEqual(Description, ExpectedDescription)
-
+
ExpectedCopyright = \
- 'Copyright (c) 2007 - 2010, Intel Corporation.'\
+ 'Copyright (c) 2007 - 2018, Intel Corporation.'\
' All rights reserved.<BR>'
self.assertEqual(Copyright, ExpectedCopyright)
-
+
ExpectedLicense = \
'License'
self.assertEqual(License, ExpectedLicense)
@@ -214,37 +214,37 @@ class ParseHeaderCommentSectionTest(unittest.TestCase):
#
# Description
#
- # Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
- # other line
- # Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
+ # Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
+ # other line
+ # Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
#
# License
#
##'''
-
+
CommentList = GetSplitValueList(TestCommentLines, "\n")
LineNum = 0
TestCommentLinesList = []
for Comment in CommentList:
LineNum += 1
TestCommentLinesList.append((Comment, LineNum))
-
+
Abstract, Description, Copyright, License = \
ParseHeaderCommentSection(TestCommentLinesList, "PhonyFile")
-
+
ExpectedAbstract = 'Abstract'
self.assertEqual(Abstract, ExpectedAbstract)
-
+
ExpectedDescription = 'Description'
self.assertEqual(Description, ExpectedDescription)
-
+
ExpectedCopyright = \
- 'Copyright (c) 2007 - 2010, Intel Corporation.'\
+ 'Copyright (c) 2007 - 2018, Intel Corporation.'\
' All rights reserved.<BR>\n'\
- 'Copyright (c) 2007 - 2010, Intel Corporation.'\
+ 'Copyright (c) 2007 - 2018, Intel Corporation.'\
' All rights reserved.<BR>'
self.assertEqual(Copyright, ExpectedCopyright)
-
+
ExpectedLicense = \
'License'
self.assertEqual(License, ExpectedLicense)
@@ -260,39 +260,39 @@ class ParseHeaderCommentSectionTest(unittest.TestCase):
#
# Description
#
- # Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
- # Copyright (c) 2007 - 2010, FOO1 Corporation. All rights reserved.<BR>
+ # Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
+ # Copyright (c) 2007 - 2010, FOO1 Corporation. All rights reserved.<BR>
# Copyright (c) 2007 - 2010, FOO2 Corporation. All rights reserved.<BR>
#
# License
#
##'''
-
+
CommentList = GetSplitValueList(TestCommentLines, "\n")
LineNum = 0
TestCommentLinesList = []
for Comment in CommentList:
LineNum += 1
TestCommentLinesList.append((Comment, LineNum))
-
+
Abstract, Description, Copyright, License = \
ParseHeaderCommentSection(TestCommentLinesList, "PhonyFile")
-
+
ExpectedAbstract = 'Abstract'
self.assertEqual(Abstract, ExpectedAbstract)
-
+
ExpectedDescription = 'Description'
self.assertEqual(Description, ExpectedDescription)
-
+
ExpectedCopyright = \
- 'Copyright (c) 2007 - 2010, Intel Corporation.'\
+ 'Copyright (c) 2007 - 2018, Intel Corporation.'\
' All rights reserved.<BR>\n'\
'Copyright (c) 2007 - 2010, FOO1 Corporation.'\
' All rights reserved.<BR>\n'\
'Copyright (c) 2007 - 2010, FOO2 Corporation.'\
' All rights reserved.<BR>'
self.assertEqual(Copyright, ExpectedCopyright)
-
+
ExpectedLicense = \
'License'
self.assertEqual(License, ExpectedLicense)
@@ -307,39 +307,39 @@ class ParseHeaderCommentSectionTest(unittest.TestCase):
#
# Description
#
- # Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
- # Copyright (c) 2007 - 2010, FOO1 Corporation. All rights reserved.<BR>
+ # Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
+ # Copyright (c) 2007 - 2010, FOO1 Corporation. All rights reserved.<BR>
# Copyright (c) 2007 - 2010, FOO2 Corporation. All rights reserved.<BR>
#
# License
#
##'''
-
+
CommentList = GetSplitValueList(TestCommentLines, "\n")
LineNum = 0
TestCommentLinesList = []
for Comment in CommentList:
LineNum += 1
TestCommentLinesList.append((Comment, LineNum))
-
+
Abstract, Description, Copyright, License = \
ParseHeaderCommentSection(TestCommentLinesList, "PhonyFile")
-
+
ExpectedAbstract = ''
self.assertEqual(Abstract, ExpectedAbstract)
-
+
ExpectedDescription = 'Description'
self.assertEqual(Description, ExpectedDescription)
-
+
ExpectedCopyright = \
- 'Copyright (c) 2007 - 2010, Intel Corporation.'\
+ 'Copyright (c) 2007 - 2018, Intel Corporation.'\
' All rights reserved.<BR>\n'\
'Copyright (c) 2007 - 2010, FOO1 Corporation.'\
' All rights reserved.<BR>\n'\
'Copyright (c) 2007 - 2010, FOO2 Corporation.'\
' All rights reserved.<BR>'
self.assertEqual(Copyright, ExpectedCopyright)
-
+
ExpectedLicense = \
'License'
self.assertEqual(License, ExpectedLicense)
@@ -353,37 +353,37 @@ class ParseHeaderCommentSectionTest(unittest.TestCase):
## @file
# Abstact
#
- # Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
+ # Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
#
# License
#
##'''
-
+
CommentList = GetSplitValueList(TestCommentLines, "\n")
LineNum = 0
TestCommentLinesList = []
for Comment in CommentList:
LineNum += 1
TestCommentLinesList.append((Comment, LineNum))
-
+
Abstract, Description, Copyright, License = \
ParseHeaderCommentSection(TestCommentLinesList, "PhonyFile")
-
+
ExpectedAbstract = 'Abstact'
self.assertEqual(Abstract, ExpectedAbstract)
-
+
ExpectedDescription = ''
self.assertEqual(Description, ExpectedDescription)
-
+
ExpectedCopyright = \
- 'Copyright (c) 2007 - 2010, Intel Corporation.'\
+ 'Copyright (c) 2007 - 2018, Intel Corporation.'\
' All rights reserved.<BR>'
self.assertEqual(Copyright, ExpectedCopyright)
-
+
ExpectedLicense = \
'License'
self.assertEqual(License, ExpectedLicense)
-
+
#
# Error case1: No copyright found
#
@@ -398,18 +398,18 @@ class ParseHeaderCommentSectionTest(unittest.TestCase):
# License
#
##'''
-
+
CommentList = GetSplitValueList(TestCommentLines, "\n")
LineNum = 0
TestCommentLinesList = []
for Comment in CommentList:
LineNum += 1
TestCommentLinesList.append((Comment, LineNum))
-
- self.assertRaises(Logger.FatalError,
- ParseHeaderCommentSection,
+
+ self.assertRaises(Logger.FatalError,
+ ParseHeaderCommentSection,
TestCommentLinesList,
- "PhonyFile")
+ "PhonyFile")
#
# Error case2: non-empty non-comment lines passed in
@@ -423,22 +423,22 @@ class ParseHeaderCommentSectionTest(unittest.TestCase):
this is invalid line
# Description
#
- # Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
+ # Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
# License
#
##'''
-
+
CommentList = GetSplitValueList(TestCommentLines, "\n")
LineNum = 0
TestCommentLinesList = []
for Comment in CommentList:
LineNum += 1
TestCommentLinesList.append((Comment, LineNum))
-
- self.assertRaises(Logger.FatalError,
- ParseHeaderCommentSection,
+
+ self.assertRaises(Logger.FatalError,
+ ParseHeaderCommentSection,
TestCommentLinesList,
- "PhonyFile")
+ "PhonyFile")
#
# Test ParseGenericComment
@@ -449,14 +449,14 @@ class ParseGenericCommentTest(unittest.TestCase):
def tearDown(self):
pass
-
+
#
# Normal case1: one line of comment
#
def testNormalCase1(self):
TestCommentLines = \
'''# hello world'''
-
+
CommentList = GetSplitValueList(TestCommentLines, "\n")
LineNum = 0
TestCommentLinesList = []
@@ -476,17 +476,17 @@ class ParseGenericCommentTest(unittest.TestCase):
TestCommentLines = \
'''## hello world
# second line'''
-
+
CommentList = GetSplitValueList(TestCommentLines, "\n")
LineNum = 0
TestCommentLinesList = []
for Comment in CommentList:
LineNum += 1
TestCommentLinesList.append((Comment, LineNum))
-
+
HelptxtObj = ParseGenericComment(TestCommentLinesList, 'testNormalCase2')
self.failIf(not HelptxtObj)
- self.assertEqual(HelptxtObj.GetString(),
+ self.assertEqual(HelptxtObj.GetString(),
'hello world\n' + 'second line')
self.assertEqual(HelptxtObj.GetLang(), TAB_LANGUAGE_EN_US)
@@ -497,17 +497,17 @@ class ParseGenericCommentTest(unittest.TestCase):
TestCommentLines = \
'''## hello world
This is not comment line'''
-
+
CommentList = GetSplitValueList(TestCommentLines, "\n")
LineNum = 0
TestCommentLinesList = []
for Comment in CommentList:
LineNum += 1
TestCommentLinesList.append((Comment, LineNum))
-
+
HelptxtObj = ParseGenericComment(TestCommentLinesList, 'testNormalCase3')
self.failIf(not HelptxtObj)
- self.assertEqual(HelptxtObj.GetString(),
+ self.assertEqual(HelptxtObj.GetString(),
'hello world\n\n')
self.assertEqual(HelptxtObj.GetLang(), TAB_LANGUAGE_EN_US)
@@ -520,7 +520,7 @@ class ParseDecPcdGenericCommentTest(unittest.TestCase):
def tearDown(self):
pass
-
+
#
# Normal case1: comments with no special comment
#
@@ -528,22 +528,22 @@ class ParseDecPcdGenericCommentTest(unittest.TestCase):
TestCommentLines = \
'''## hello world
# second line'''
-
+
CommentList = GetSplitValueList(TestCommentLines, "\n")
LineNum = 0
TestCommentLinesList = []
for Comment in CommentList:
LineNum += 1
TestCommentLinesList.append((Comment, LineNum))
-
+
(HelpTxt, PcdErr) = \
ParseDecPcdGenericComment(TestCommentLinesList, 'testNormalCase1')
self.failIf(not HelpTxt)
self.failIf(PcdErr)
- self.assertEqual(HelpTxt,
+ self.assertEqual(HelpTxt,
'hello world\n' + 'second line')
-
-
+
+
#
# Normal case2: comments with valid list
#
@@ -553,19 +553,19 @@ class ParseDecPcdGenericCommentTest(unittest.TestCase):
# second line
# @ValidList 1, 2, 3
# other line'''
-
+
CommentList = GetSplitValueList(TestCommentLines, "\n")
LineNum = 0
TestCommentLinesList = []
for Comment in CommentList:
LineNum += 1
TestCommentLinesList.append((Comment, LineNum))
-
+
(HelpTxt, PcdErr) = \
ParseDecPcdGenericComment(TestCommentLinesList, 'UnitTest')
self.failIf(not HelpTxt)
self.failIf(not PcdErr)
- self.assertEqual(HelpTxt,
+ self.assertEqual(HelpTxt,
'hello world\n' + 'second line\n' + 'other line')
ExpectedList = GetSplitValueList('1 2 3', TAB_SPACE_SPLIT)
ActualList = [item for item in \
@@ -583,19 +583,19 @@ class ParseDecPcdGenericCommentTest(unittest.TestCase):
# second line
# @ValidRange LT 1 AND GT 2
# other line'''
-
+
CommentList = GetSplitValueList(TestCommentLines, "\n")
LineNum = 0
TestCommentLinesList = []
for Comment in CommentList:
LineNum += 1
TestCommentLinesList.append((Comment, LineNum))
-
+
(HelpTxt, PcdErr) = \
ParseDecPcdGenericComment(TestCommentLinesList, 'UnitTest')
self.failIf(not HelpTxt)
self.failIf(not PcdErr)
- self.assertEqual(HelpTxt,
+ self.assertEqual(HelpTxt,
'hello world\n' + 'second line\n' + 'other line')
self.assertEqual(PcdErr.GetValidValueRange().strip(), 'LT 1 AND GT 2')
self.failIf(PcdErr.GetExpression())
@@ -610,19 +610,19 @@ class ParseDecPcdGenericCommentTest(unittest.TestCase):
# second line
# @Expression LT 1 AND GT 2
# other line'''
-
+
CommentList = GetSplitValueList(TestCommentLines, "\n")
LineNum = 0
TestCommentLinesList = []
for Comment in CommentList:
LineNum += 1
TestCommentLinesList.append((Comment, LineNum))
-
+
(HelpTxt, PcdErr) = \
ParseDecPcdGenericComment(TestCommentLinesList, 'UnitTest')
self.failIf(not HelpTxt)
self.failIf(not PcdErr)
- self.assertEqual(HelpTxt,
+ self.assertEqual(HelpTxt,
'hello world\n' + 'second line\n' + 'other line')
self.assertEqual(PcdErr.GetExpression().strip(), 'LT 1 AND GT 2')
self.failIf(PcdErr.GetValidValueRange())
@@ -634,14 +634,14 @@ class ParseDecPcdGenericCommentTest(unittest.TestCase):
def testNormalCase5(self):
TestCommentLines = \
'''# @Expression LT 1 AND GT 2'''
-
+
CommentList = GetSplitValueList(TestCommentLines, "\n")
LineNum = 0
TestCommentLinesList = []
for Comment in CommentList:
LineNum += 1
TestCommentLinesList.append((Comment, LineNum))
-
+
(HelpTxt, PcdErr) = \
ParseDecPcdGenericComment(TestCommentLinesList, 'UnitTest')
self.failIf(HelpTxt)
@@ -649,28 +649,28 @@ class ParseDecPcdGenericCommentTest(unittest.TestCase):
self.assertEqual(PcdErr.GetExpression().strip(), 'LT 1 AND GT 2')
self.failIf(PcdErr.GetValidValueRange())
self.failIf(PcdErr.GetValidValue())
-
+
#
# Normal case6: comments with only generic help text
#
def testNormalCase6(self):
TestCommentLines = \
'''#'''
-
+
CommentList = GetSplitValueList(TestCommentLines, "\n")
LineNum = 0
TestCommentLinesList = []
for Comment in CommentList:
LineNum += 1
TestCommentLinesList.append((Comment, LineNum))
-
+
(HelpTxt, PcdErr) = \
ParseDecPcdGenericComment(TestCommentLinesList, 'UnitTest')
self.assertEqual(HelpTxt, '\n')
self.failIf(PcdErr)
-
-
+
+
#
# Error case1: comments with both expression and valid list, use later
# ignore the former and with a warning message
@@ -679,17 +679,17 @@ class ParseDecPcdGenericCommentTest(unittest.TestCase):
TestCommentLines = \
'''## hello world
# second line
- # @ValidList 1, 2, 3
+ # @ValidList 1, 2, 3
# @Expression LT 1 AND GT 2
# other line'''
-
+
CommentList = GetSplitValueList(TestCommentLines, "\n")
LineNum = 0
TestCommentLinesList = []
for Comment in CommentList:
LineNum += 1
TestCommentLinesList.append((Comment, LineNum))
-
+
try:
ParseDecPcdGenericComment(TestCommentLinesList, 'UnitTest')
except Logger.FatalError:
@@ -704,26 +704,26 @@ class ParseDecPcdTailCommentTest(unittest.TestCase):
def tearDown(self):
pass
-
+
#
# Normal case1: comments with no SupModeList
#
def testNormalCase1(self):
TestCommentLines = \
'''## #hello world'''
-
+
CommentList = GetSplitValueList(TestCommentLines, "\n")
LineNum = 0
TestCommentLinesList = []
for Comment in CommentList:
LineNum += 1
TestCommentLinesList.append((Comment, LineNum))
-
+
(SupModeList, HelpStr) = \
ParseDecPcdTailComment(TestCommentLinesList, 'UnitTest')
self.failIf(not HelpStr)
self.failIf(SupModeList)
- self.assertEqual(HelpStr,
+ self.assertEqual(HelpStr,
'hello world')
#
@@ -732,44 +732,44 @@ class ParseDecPcdTailCommentTest(unittest.TestCase):
def testNormalCase2(self):
TestCommentLines = \
'''## BASE #hello world'''
-
+
CommentList = GetSplitValueList(TestCommentLines, "\n")
LineNum = 0
TestCommentLinesList = []
for Comment in CommentList:
LineNum += 1
TestCommentLinesList.append((Comment, LineNum))
-
+
(SupModeList, HelpStr) = \
ParseDecPcdTailComment(TestCommentLinesList, 'UnitTest')
self.failIf(not HelpStr)
self.failIf(not SupModeList)
- self.assertEqual(HelpStr,
+ self.assertEqual(HelpStr,
'hello world')
- self.assertEqual(SupModeList,
+ self.assertEqual(SupModeList,
['BASE'])
-
+
#
# Normal case3: comments with more than one SupMode
#
def testNormalCase3(self):
TestCommentLines = \
'''## BASE UEFI_APPLICATION #hello world'''
-
+
CommentList = GetSplitValueList(TestCommentLines, "\n")
LineNum = 0
TestCommentLinesList = []
for Comment in CommentList:
LineNum += 1
TestCommentLinesList.append((Comment, LineNum))
-
+
(SupModeList, HelpStr) = \
ParseDecPcdTailComment(TestCommentLinesList, 'UnitTest')
self.failIf(not HelpStr)
self.failIf(not SupModeList)
- self.assertEqual(HelpStr,
+ self.assertEqual(HelpStr,
'hello world')
- self.assertEqual(SupModeList,
+ self.assertEqual(SupModeList,
['BASE', 'UEFI_APPLICATION'])
#
@@ -778,58 +778,58 @@ class ParseDecPcdTailCommentTest(unittest.TestCase):
def testNormalCase4(self):
TestCommentLines = \
'''## BASE UEFI_APPLICATION'''
-
+
CommentList = GetSplitValueList(TestCommentLines, "\n")
LineNum = 0
TestCommentLinesList = []
for Comment in CommentList:
LineNum += 1
TestCommentLinesList.append((Comment, LineNum))
-
+
(SupModeList, HelpStr) = \
ParseDecPcdTailComment(TestCommentLinesList, 'UnitTest')
self.failIf(HelpStr)
self.failIf(not SupModeList)
- self.assertEqual(SupModeList,
+ self.assertEqual(SupModeList,
['BASE', 'UEFI_APPLICATION'])
#
- # Normal case5: general comments with no supModList, extract from real case
+ # Normal case5: general comments with no supModList, extract from real case
#
def testNormalCase5(self):
TestCommentLines = \
''' # 1 = 128MB, 2 = 256MB, 3 = MAX'''
-
+
CommentList = GetSplitValueList(TestCommentLines, "\n")
LineNum = 0
TestCommentLinesList = []
for Comment in CommentList:
LineNum += 1
TestCommentLinesList.append((Comment, LineNum))
-
+
(SupModeList, HelpStr) = \
ParseDecPcdTailComment(TestCommentLinesList, 'UnitTest')
self.failIf(not HelpStr)
- self.assertEqual(HelpStr,
+ self.assertEqual(HelpStr,
'1 = 128MB, 2 = 256MB, 3 = MAX')
self.failIf(SupModeList)
-
+
#
- # Error case2: comments with supModList contains valid and invalid
+ # Error case2: comments with supModList contains valid and invalid
# module type
#
def testErrorCase2(self):
TestCommentLines = \
'''## BASE INVALID_MODULE_TYPE #hello world'''
-
+
CommentList = GetSplitValueList(TestCommentLines, "\n")
LineNum = 0
TestCommentLinesList = []
for Comment in CommentList:
LineNum += 1
TestCommentLinesList.append((Comment, LineNum))
-
+
try:
ParseDecPcdTailComment(TestCommentLinesList, 'UnitTest')
except Logger.FatalError:
@@ -869,7 +869,7 @@ class _IsCopyrightLineTest(unittest.TestCase):
Line = 'this is not aCopyright ( line'
Result = _IsCopyrightLine(Line)
self.failIf(Result)
-
+
#
# Normal case
#
@@ -917,7 +917,7 @@ class _IsCopyrightLineTest(unittest.TestCase):
Line = 'not a Copyright '
Result = _IsCopyrightLine(Line)
self.failIf(Result)
-
+
if __name__ == '__main__':
Logger.Initialize()
- unittest.main() \ No newline at end of file
+ unittest.main()
diff --git a/BaseTools/Source/Python/UPT/UnitTest/DecParserTest.py b/BaseTools/Source/Python/UPT/UnitTest/DecParserTest.py
index 5f0abcafef..0ea5ea1e0f 100644
--- a/BaseTools/Source/Python/UPT/UnitTest/DecParserTest.py
+++ b/BaseTools/Source/Python/UPT/UnitTest/DecParserTest.py
@@ -1,11 +1,11 @@
## @file
# This file contain unit test for DecParser
#
-# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2011 - 2018, 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 which accompanies this
-# distribution. The full text of the license may be found at
+# This program and the accompanying materials are licensed and made available
+# under the terms and conditions of the BSD License which accompanies this
+# distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
@@ -28,19 +28,19 @@ from Library.ParserValidate import IsValidCFormatGuid
#
def TestToolFuncs():
assert IsValidCArray('{0x1, 0x23}')
-
+
# Empty after comma
assert not IsValidCArray('{0x1, 0x23, }')
-
+
# 0x2345 too long
assert not IsValidCArray('{0x1, 0x2345}')
-
+
# Must end with '}'
assert not IsValidCArray('{0x1, 0x23, ')
-
+
# Whitespace between numbers
assert not IsValidCArray('{0x1, 0x2 3, }')
-
+
assert IsValidPcdDatum('VOID*', '"test"')[0]
assert IsValidPcdDatum('VOID*', 'L"test"')[0]
assert IsValidPcdDatum('BOOLEAN', 'TRUE')[0]
@@ -48,10 +48,10 @@ def TestToolFuncs():
assert IsValidPcdDatum('BOOLEAN', '0')[0]
assert IsValidPcdDatum('BOOLEAN', '1')[0]
assert IsValidPcdDatum('UINT8', '0xab')[0]
-
+
assert not IsValidPcdDatum('UNKNOWNTYPE', '0xabc')[0]
- assert not IsValidPcdDatum('UINT8', 'not number')[0]
-
+ assert not IsValidPcdDatum('UINT8', 'not number')[0]
+
assert( IsValidCFormatGuid('{ 0xfa0b1735 , 0x87a0, 0x4193, {0xb2, 0x66 , 0x53, 0x8c , 0x38, 0xaf, 0x48, 0xce }}'))
assert( not IsValidCFormatGuid('{ 0xfa0b1735 , 0x87a0, 0x4193, {0xb2, 0x66 , 0x53, 0x8c , 0x38, 0xaf, 0x48, 0xce }} 0xaa'))
@@ -60,10 +60,10 @@ def TestTemplate(TestString, TestFunc):
Path = os.path.normpath(Path)
try:
f = open(Path, 'w')
-
+
# Write test string to file
f.write(TestString)
-
+
# Close file
f.close()
except:
@@ -72,7 +72,7 @@ def TestTemplate(TestString, TestFunc):
# Call test function to test
Ret = TestFunc(Path, TestString)
-
+
# Test done, remove temporary file
os.remove(Path)
return Ret
@@ -112,13 +112,13 @@ def TestDecDefine():
assert DefObj.GetPackageName() == 'MdePkg'
assert DefObj.GetPackageGuid() == '1E73767F-8F52-4603-AEB4-F29B510B6766'
assert DefObj.GetPackageVersion() == '1.02'
-
+
TestString = '''
[Defines]
UNKNOW_KEY = 0x00010005 # A unknown key
'''
assert TestTemplate(TestString, TestError)
-
+
TestString = '''
[Defines]
PACKAGE_GUID = F-8F52-4603-AEB4-F29B510B6766 # Error GUID
@@ -138,24 +138,24 @@ def TestDecInclude():
[Includes.IA32]
Include/Ia32
'''
-
+
# Create directory in current directory
try:
os.makedirs('Include/Ia32')
except:
pass
Parser = TestTemplate(TestString, TestOK)
-
+
IncObj = Parser.GetIncludeSectionObject()
Items = IncObj.GetIncludes()
assert len(Items) == 1
assert Items[0].File == 'Include'
-
+
Items = IncObj.GetIncludes('IA32')
assert len(Items) == 1
# normpath is called in DEC parser so '/' is converted to '\'
assert Items[0].File == 'Include\\Ia32'
-
+
TestString = '''
[Defines]
DEC_SPECIFICATION = 0x00010005
@@ -166,7 +166,7 @@ def TestDecInclude():
Include_not_exist # directory does not exist
'''
assert TestTemplate(TestString, TestError)
-
+
os.removedirs('Include/Ia32')
def TestDecGuidPpiProtocol():
@@ -196,14 +196,14 @@ def TestDecGuidPpiProtocol():
assert len(Items) == 1
assert Items[0].GuidCName == 'gEfiGlobalVariableGuid'
assert Items[0].GuidCValue == '{ 0x8BE4DF61, 0x93CA, 0x11D2, { 0xAA, 0x0D, 0x00, 0xE0, 0x98, 0x03, 0x2B, 0x8C }}'
-
+
Obj = Parser.GetProtocolSectionObject()
Items = Obj.GetProtocols()
assert Obj.GetSectionName() == 'Protocols'.upper()
assert len(Items) == 1
assert Items[0].GuidCName == 'gEfiBdsArchProtocolGuid'
assert Items[0].GuidCValue == '{ 0x665E3FF6, 0x46CC, 0x11D4, { 0x9A, 0x38, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0x4D }}'
-
+
Obj = Parser.GetPpiSectionObject()
Items = Obj.GetPpis()
assert Obj.GetSectionName() == 'Ppis'.upper()
@@ -221,19 +221,19 @@ def TestDecPcd():
[PcdsFeatureFlag]
## If TRUE, the component name protocol will not be installed.
gEfiMdePkgTokenSpaceGuid.PcdComponentNameDisable|FALSE|BOOLEAN|0x0000000d
-
+
[PcdsFixedAtBuild]
## Indicates the maximum length of unicode string
gEfiMdePkgTokenSpaceGuid.PcdMaximumUnicodeStringLength|1000000|UINT32|0x00000001
-
+
[PcdsFixedAtBuild.IPF]
## The base address of IO port space for IA64 arch
gEfiMdePkgTokenSpaceGuid.PcdIoBlockBaseAddressForIpf|0x0ffffc000000|UINT64|0x0000000f
-
+
[PcdsFixedAtBuild,PcdsPatchableInModule]
## This flag is used to control the printout of DebugLib
gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x80000000|UINT32|0x00000006
-
+
[PcdsFixedAtBuild,PcdsPatchableInModule,PcdsDynamic]
## This value is used to set the base address of pci express hierarchy
gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress|0xE0000000|UINT64|0x0000000a
@@ -247,7 +247,7 @@ def TestDecPcd():
assert Items[0].DefaultValue == 'FALSE'
assert Items[0].DatumType == 'BOOLEAN'
assert Items[0].TokenValue == '0x0000000d'
-
+
Items = Obj.GetPcdsByType('PcdsFixedAtBuild')
assert len(Items) == 4
assert len(Obj.GetPcdsByType('PcdsPatchableInModule')) == 2
diff --git a/BaseTools/Source/Python/UPT/UnitTest/DecParserUnitTest.py b/BaseTools/Source/Python/UPT/UnitTest/DecParserUnitTest.py
index 2f4917525b..afea4a438b 100644
--- a/BaseTools/Source/Python/UPT/UnitTest/DecParserUnitTest.py
+++ b/BaseTools/Source/Python/UPT/UnitTest/DecParserUnitTest.py
@@ -1,11 +1,11 @@
## @file
# This file contain unit test for DecParser
#
-# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2011 - 2018, 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 which accompanies this
-# distribution. The full text of the license may be found at
+# This program and the accompanying materials are licensed and made available
+# under the terms and conditions of the BSD License which accompanies this
+# distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
@@ -24,7 +24,7 @@ from Parser.DecParser import \
FileContent, \
_DecBase, \
CleanString
-
+
from Object.Parser.DecObject import _DecComments
#
@@ -35,19 +35,19 @@ class CleanStringTestCase(unittest.TestCase):
Line, Comment = CleanString('')
self.assertEqual(Line, '')
self.assertEqual(Comment, '')
-
+
Line, Comment = CleanString('line without comment')
self.assertEqual(Line, 'line without comment')
self.assertEqual(Comment, '')
-
+
Line, Comment = CleanString('# pure comment')
self.assertEqual(Line, '')
self.assertEqual(Comment, '# pure comment')
-
+
Line, Comment = CleanString('line # and comment')
self.assertEqual(Line, 'line')
self.assertEqual(Comment, '# and comment')
-
+
def testCleanStringCpp(self):
Line, Comment = CleanString('line // and comment', AllowCppStyleComment = True)
self.assertEqual(Line, 'line')
@@ -59,16 +59,16 @@ class CleanStringTestCase(unittest.TestCase):
class MacroParserTestCase(unittest.TestCase):
def setUp(self):
self.dec = _DecBase(FileContent('dummy', []))
-
+
def testCorrectMacro(self):
self.dec._MacroParser('DEFINE MARCRO1 = test1')
self.failIf('MARCRO1' not in self.dec._LocalMacro)
self.assertEqual(self.dec._LocalMacro['MARCRO1'], 'test1')
-
+
def testErrorMacro1(self):
# Raise fatal error, macro name must be upper case letter
self.assertRaises(FatalError, self.dec._MacroParser, 'DEFINE not_upper_case = test2')
-
+
def testErrorMacro2(self):
# No macro name given
self.assertRaises(FatalError, self.dec._MacroParser, 'DEFINE ')
@@ -81,19 +81,19 @@ class TryBackSlashTestCase(unittest.TestCase):
Content = [
# Right case
'test no backslash',
-
+
'test with backslash \\',
'continue second line',
-
+
# Do not precede with whitespace
'\\',
-
+
# Empty line after backlash is not allowed
'line with backslash \\',
''
]
self.dec = _DecBase(FileContent('dummy', Content))
-
+
def testBackSlash(self):
#
# Right case, assert return values
@@ -101,11 +101,11 @@ class TryBackSlashTestCase(unittest.TestCase):
ConcatLine, CommentList = self.dec._TryBackSlash(self.dec._RawData.GetNextLine(), [])
self.assertEqual(ConcatLine, 'test no backslash')
self.assertEqual(CommentList, [])
-
+
ConcatLine, CommentList = self.dec._TryBackSlash(self.dec._RawData.GetNextLine(), [])
self.assertEqual(CommentList, [])
self.assertEqual(ConcatLine, 'test with backslash continue second line')
-
+
#
# Error cases, assert raise exception
#
@@ -130,16 +130,16 @@ class TestInner(_DecBase):
def __init__(self, RawData):
_DecBase.__init__(self, RawData)
self.ItemObject = Data()
-
+
def _StopCurrentParsing(self, Line):
return Line == '[TOP]'
-
+
def _ParseItem(self):
Item = DataItem()
Item.String = self._RawData.CurrentLine
self.ItemObject.ItemList.append(Item)
return Item
-
+
def _TailCommentStrategy(self, Comment):
return Comment.find('@comment') != -1
@@ -148,7 +148,7 @@ class TestTop(_DecBase):
_DecBase.__init__(self, RawData)
# List of Data
self.ItemObject = []
-
+
# Top parser
def _StopCurrentParsing(self, Line):
return False
@@ -159,10 +159,10 @@ class TestTop(_DecBase):
self.ItemObject.append(TestParser.ItemObject)
return TestParser.ItemObject
-class ParseTestCase(unittest.TestCase):
+class ParseTestCase(unittest.TestCase):
def setUp(self):
pass
-
+
def testParse(self):
Content = \
'''# Top comment
@@ -172,26 +172,26 @@ class ParseTestCase(unittest.TestCase):
# sub2 head comment
(test item has head and special tail comment)
# @comment test TailCommentStrategy branch
-
+
(test item has no comment)
-
+
# test NextLine branch
[TOP]
sub-item
'''
dec = TestTop(FileContent('dummy', Content.splitlines()))
dec.Parse()
-
+
# Two sections
self.assertEqual(len(dec.ItemObject), 2)
-
+
data = dec.ItemObject[0]
self.assertEqual(data._HeadComment[0][0], '# Top comment')
self.assertEqual(data._HeadComment[0][1], 1)
-
+
# 3 subitems
self.assertEqual(len(data.ItemList), 3)
-
+
dataitem = data.ItemList[0]
self.assertEqual(dataitem.String, '(test item has both head and tail comment)')
# Comment content
@@ -200,7 +200,7 @@ class ParseTestCase(unittest.TestCase):
# Comment line number
self.assertEqual(dataitem._HeadComment[0][1], 3)
self.assertEqual(dataitem._TailComment[0][1], 4)
-
+
dataitem = data.ItemList[1]
self.assertEqual(dataitem.String, '(test item has head and special tail comment)')
# Comment content
@@ -209,20 +209,20 @@ class ParseTestCase(unittest.TestCase):
# Comment line number
self.assertEqual(dataitem._HeadComment[0][1], 5)
self.assertEqual(dataitem._TailComment[0][1], 7)
-
+
dataitem = data.ItemList[2]
self.assertEqual(dataitem.String, '(test item has no comment)')
# Comment content
self.assertEqual(dataitem._HeadComment, [])
self.assertEqual(dataitem._TailComment, [])
-
+
data = dec.ItemObject[1]
self.assertEqual(data._HeadComment[0][0], '# test NextLine branch')
self.assertEqual(data._HeadComment[0][1], 11)
-
+
# 1 subitems
self.assertEqual(len(data.ItemList), 1)
-
+
dataitem = data.ItemList[0]
self.assertEqual(dataitem.String, 'sub-item')
self.assertEqual(dataitem._HeadComment, [])
@@ -241,15 +241,15 @@ class DecDefineTestCase(unittest.TestCase):
item = self.GetObj('PACKAGE_NAME = MdePkg')._ParseItem()
self.assertEqual(item.Key, 'PACKAGE_NAME')
self.assertEqual(item.Value, 'MdePkg')
-
+
def testDecDefine1(self):
obj = self.GetObj('PACKAGE_NAME')
self.assertRaises(FatalError, obj._ParseItem)
-
+
def testDecDefine2(self):
obj = self.GetObj('unknown_key = ')
self.assertRaises(FatalError, obj._ParseItem)
-
+
def testDecDefine3(self):
obj = self.GetObj('PACKAGE_NAME = ')
self.assertRaises(FatalError, obj._ParseItem)
@@ -262,23 +262,23 @@ class DecLibraryTestCase(unittest.TestCase):
Obj = _DecLibraryclass(FileContent('dummy', Content.splitlines()))
Obj._RawData.CurrentLine = Obj._RawData.GetNextLine()
return Obj
-
+
def testNoInc(self):
obj = self.GetObj('UefiRuntimeLib')
self.assertRaises(FatalError, obj._ParseItem)
-
+
def testEmpty(self):
obj = self.GetObj(' | ')
self.assertRaises(FatalError, obj._ParseItem)
-
+
def testLibclassNaming(self):
obj = self.GetObj('lowercase_efiRuntimeLib|Include/Library/UefiRuntimeLib.h')
self.assertRaises(FatalError, obj._ParseItem)
-
+
def testLibclassExt(self):
obj = self.GetObj('RuntimeLib|Include/Library/UefiRuntimeLib.no_h')
self.assertRaises(FatalError, obj._ParseItem)
-
+
def testLibclassRelative(self):
obj = self.GetObj('RuntimeLib|Include/../UefiRuntimeLib.h')
self.assertRaises(FatalError, obj._ParseItem)
@@ -292,7 +292,7 @@ class DecPcdTestCase(unittest.TestCase):
Obj._RawData.CurrentLine = Obj._RawData.GetNextLine()
Obj._RawData.CurrentScope = [('PcdsFeatureFlag'.upper(), 'COMMON')]
return Obj
-
+
def testOK(self):
item = self.GetObj('gEfiMdePkgTokenSpaceGuid.PcdComponentNameDisable|FALSE|BOOLEAN|0x0000000d')._ParseItem()
self.assertEqual(item.TokenSpaceGuidCName, 'gEfiMdePkgTokenSpaceGuid')
@@ -300,26 +300,26 @@ class DecPcdTestCase(unittest.TestCase):
self.assertEqual(item.DefaultValue, 'FALSE')
self.assertEqual(item.DatumType, 'BOOLEAN')
self.assertEqual(item.TokenValue, '0x0000000d')
-
+
def testNoCvar(self):
obj = self.GetObj('123ai.PcdComponentNameDisable|FALSE|BOOLEAN|0x0000000d')
self.assertRaises(FatalError, obj._ParseItem)
-
+
def testSplit(self):
obj = self.GetObj('gEfiMdePkgTokenSpaceGuid.PcdComponentNameDisable FALSE|BOOLEAN|0x0000000d')
self.assertRaises(FatalError, obj._ParseItem)
-
+
obj = self.GetObj('gEfiMdePkgTokenSpaceGuid.PcdComponentNameDisable|FALSE|BOOLEAN|0x0000000d | abc')
self.assertRaises(FatalError, obj._ParseItem)
-
+
def testUnknownType(self):
obj = self.GetObj('gEfiMdePkgTokenSpaceGuid.PcdComponentNameDisable|FALSE|unknown|0x0000000d')
self.assertRaises(FatalError, obj._ParseItem)
-
+
def testVoid(self):
obj = self.GetObj('gEfiMdePkgTokenSpaceGuid.PcdComponentNameDisable|abc|VOID*|0x0000000d')
self.assertRaises(FatalError, obj._ParseItem)
-
+
def testUINT(self):
obj = self.GetObj('gEfiMdePkgTokenSpaceGuid.PcdComponentNameDisable|0xabc|UINT8|0x0000000d')
self.assertRaises(FatalError, obj._ParseItem)
@@ -342,26 +342,26 @@ class DecGuidTestCase(unittest.TestCase):
Obj._RawData.CurrentLine = Obj._RawData.GetNextLine()
Obj._RawData.CurrentScope = [('guids'.upper(), 'COMMON')]
return Obj
-
+
def testCValue(self):
item = self.GetObj('gEfiIpSecProtocolGuid={ 0xdfb386f7, 0xe100, 0x43ad,'
' {0x9c, 0x9a, 0xed, 0x90, 0xd0, 0x8a, 0x5e, 0x12 }}')._ParseItem()
self.assertEqual(item.GuidCName, 'gEfiIpSecProtocolGuid')
self.assertEqual(item.GuidCValue, '{ 0xdfb386f7, 0xe100, 0x43ad, {0x9c, 0x9a, 0xed, 0x90, 0xd0, 0x8a, 0x5e, 0x12 }}')
-
+
def testGuidString(self):
item = self.GetObj('gEfiIpSecProtocolGuid=1E73767F-8F52-4603-AEB4-F29B510B6766')._ParseItem()
self.assertEqual(item.GuidCName, 'gEfiIpSecProtocolGuid')
self.assertEqual(item.GuidCValue, '1E73767F-8F52-4603-AEB4-F29B510B6766')
-
+
def testNoValue1(self):
obj = self.GetObj('gEfiIpSecProtocolGuid')
self.assertRaises(FatalError, obj._ParseItem)
-
+
def testNoValue2(self):
obj = self.GetObj('gEfiIpSecProtocolGuid=')
self.assertRaises(FatalError, obj._ParseItem)
-
+
def testNoName(self):
obj = self.GetObj('=')
self.assertRaises(FatalError, obj._ParseItem)
@@ -376,7 +376,7 @@ class DecDecInitTestCase(unittest.TestCase):
class TmpFile:
def __init__(self, File):
self.File = File
-
+
def Write(self, Content):
try:
FileObj = open(self.File, 'w')
@@ -384,7 +384,7 @@ class TmpFile:
FileObj.close()
except:
pass
-
+
def Remove(self):
try:
os.remove(self.File)
@@ -404,13 +404,13 @@ class DecUESectionTestCase(unittest.TestCase):
[userextensions.intel."myid]
'''
)
-
+
def tearDown(self):
self.File.Remove()
-
+
def testUserExtentionHeader(self):
dec = Dec('test.dec', False)
-
+
# OK: [userextensions.intel."myid"]
dec._RawData.CurrentLine = CleanString(dec._RawData.GetNextLine())[0]
dec._UserExtentionSectionParser()
@@ -419,7 +419,7 @@ class DecUESectionTestCase(unittest.TestCase):
self.assertEqual(dec._RawData.CurrentScope[0][1], 'intel')
self.assertEqual(dec._RawData.CurrentScope[0][2], '"myid"')
self.assertEqual(dec._RawData.CurrentScope[0][3], 'COMMON')
-
+
# OK: [userextensions.intel."myid".IA32]
dec._RawData.CurrentLine = CleanString(dec._RawData.GetNextLine())[0]
dec._UserExtentionSectionParser()
@@ -428,11 +428,11 @@ class DecUESectionTestCase(unittest.TestCase):
self.assertEqual(dec._RawData.CurrentScope[0][1], 'intel')
self.assertEqual(dec._RawData.CurrentScope[0][2], '"myid"')
self.assertEqual(dec._RawData.CurrentScope[0][3], 'IA32')
-
+
# Fail: [userextensions.intel."myid".IA32,]
dec._RawData.CurrentLine = CleanString(dec._RawData.GetNextLine())[0]
self.assertRaises(FatalError, dec._UserExtentionSectionParser)
-
+
# Fail: [userextensions.intel."myid]
dec._RawData.CurrentLine = CleanString(dec._RawData.GetNextLine())[0]
self.assertRaises(FatalError, dec._UserExtentionSectionParser)
@@ -453,43 +453,43 @@ class DecSectionTestCase(unittest.TestCase):
[Includes, Includes.IA32] # common cannot be with other arch
[Includes.IA32, PcdsFeatureFlag] # different section name
''' )
-
+
def tearDown(self):
self.File.Remove()
-
+
def testSectionHeader(self):
dec = Dec('test.dec', False)
# [no section start or end
dec._RawData.CurrentLine = CleanString(dec._RawData.GetNextLine())[0]
self.assertRaises(FatalError, dec._SectionHeaderParser)
-
+
#[,] # empty sub-section
dec._RawData.CurrentLine = CleanString(dec._RawData.GetNextLine())[0]
self.assertRaises(FatalError, dec._SectionHeaderParser)
-
+
# [unknow_section_name]
dec._RawData.CurrentLine = CleanString(dec._RawData.GetNextLine())[0]
self.assertRaises(FatalError, dec._SectionHeaderParser)
-
+
# [Includes.IA32.other] # no third one
dec._RawData.CurrentLine = CleanString(dec._RawData.GetNextLine())[0]
self.assertRaises(FatalError, dec._SectionHeaderParser)
-
+
# [PcdsFeatureFlag, PcdsFixedAtBuild]
dec._RawData.CurrentLine = CleanString(dec._RawData.GetNextLine())[0]
self.assertRaises(FatalError, dec._SectionHeaderParser)
-
+
# [Includes.IA32, Includes.IA32]
dec._RawData.CurrentLine = CleanString(dec._RawData.GetNextLine())[0]
dec._SectionHeaderParser()
self.assertEqual(len(dec._RawData.CurrentScope), 1)
self.assertEqual(dec._RawData.CurrentScope[0][0], 'Includes'.upper())
self.assertEqual(dec._RawData.CurrentScope[0][1], 'IA32')
-
+
# [Includes, Includes.IA32] # common cannot be with other arch
dec._RawData.CurrentLine = CleanString(dec._RawData.GetNextLine())[0]
self.assertRaises(FatalError, dec._SectionHeaderParser)
-
+
# [Includes.IA32, PcdsFeatureFlag] # different section name not allowed
dec._RawData.CurrentLine = CleanString(dec._RawData.GetNextLine())[0]
self.assertRaises(FatalError, dec._SectionHeaderParser)
@@ -511,7 +511,7 @@ class DecDecCommentTestCase(unittest.TestCase):
self.assertEqual(dec._HeadComment[1][0], '##')
self.assertEqual(dec._HeadComment[1][1], 2)
File.Remove()
-
+
def testNoDoubleComment(self):
File = TmpFile('test.dec')
File.Write(
diff --git a/BaseTools/Source/Python/UPT/UnitTest/InfBinarySectionTest.py b/BaseTools/Source/Python/UPT/UnitTest/InfBinarySectionTest.py
index 626f17426d..9a10ec15c4 100644
--- a/BaseTools/Source/Python/UPT/UnitTest/InfBinarySectionTest.py
+++ b/BaseTools/Source/Python/UPT/UnitTest/InfBinarySectionTest.py
@@ -1,11 +1,11 @@
## @file
-# This file contain unit test for Test [Binary] section part of InfParser
+# This file contain unit test for Test [Binary] section part of InfParser
#
-# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2011 - 2018, 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 which accompanies this
-# distribution. The full text of the license may be found at
+# This program and the accompanying materials are licensed and made available
+# under the terms and conditions of the BSD License which accompanies this
+# distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
@@ -49,7 +49,7 @@ GUID | Test/Test.guid | DEBUG
"""
#
-# Have 3 elements, Type | FileName | Target
+# Have 3 elements, Type | FileName | Target
# Target with MACRO defined in [Define] section
#
SectionStringsCommonItem4 = \
@@ -58,7 +58,7 @@ GUID | Test/Test.guid | $(TARGET)
"""
#
-# Have 3 elements, Type | FileName | Target
+# Have 3 elements, Type | FileName | Target
# FileName with MACRO defined in [Binary] section
#
SectionStringsCommonItem5 = \
@@ -115,7 +115,7 @@ GUID | Test/Test.guid | DEBUG | MSFT | TEST | TRUE | OVERFLOW
#-------------start of VER type binary item test input------------------------#
#
-# Has 1 element, error format
+# Has 1 element, error format
#
SectionStringsVerItem1 = \
"""
@@ -199,7 +199,7 @@ UI | Test/Test2.ui | * | FALSE
"""
#
-# Has 1 element, error format
+# Has 1 element, error format
#
SectionStringsUiItem4 = \
"""
@@ -253,7 +253,7 @@ def StringToSectionString(String):
continue
SectionString.append((Line, LineNo, ''))
LineNo = LineNo + 1
-
+
return SectionString
def PrepareTest(String):
@@ -269,7 +269,7 @@ def PrepareTest(String):
#
FileName = os.path.normpath(os.path.realpath(ValueList[1].strip()))
try:
- TempFile = open (FileName, "w")
+ TempFile = open (FileName, "w")
TempFile.close()
except:
print("File Create Error")
@@ -278,24 +278,24 @@ def PrepareTest(String):
CurrentLine.SetLineString(Item[0])
CurrentLine.SetLineNo(Item[1])
InfLineCommentObject = InfLineCommentObject()
-
+
ItemList.append((ValueList, InfLineCommentObject, CurrentLine))
-
+
return ItemList
if __name__ == '__main__':
Logger.Initialize()
-
+
InfBinariesInstance = InfBinariesObject()
ArchList = ['COMMON']
Global.gINF_MODULE_DIR = os.getcwd()
-
+
AllPassedFlag = True
-
+
#
# For All Ui test
#
- UiStringList = [
+ UiStringList = [
SectionStringsUiItem1,
SectionStringsUiItem2,
SectionStringsUiItem3,
@@ -303,10 +303,10 @@ if __name__ == '__main__':
SectionStringsUiItem5,
SectionStringsUiItem6,
SectionStringsUiItem7,
- SectionStringsUiItem8
+ SectionStringsUiItem8
]
-
- for Item in UiStringList:
+
+ for Item in UiStringList:
Ui = PrepareTest(Item)
if Item == SectionStringsUiItem4 or Item == SectionStringsUiItem5:
try:
@@ -314,11 +314,11 @@ if __name__ == '__main__':
except Logger.FatalError:
pass
else:
- try:
+ try:
InfBinariesInstance.SetBinary(Ui = Ui, ArchList = ArchList)
except:
- AllPassedFlag = False
-
+ AllPassedFlag = False
+
#
# For All Ver Test
#
@@ -331,25 +331,25 @@ if __name__ == '__main__':
SectionStringsVerItem6,
SectionStringsVerItem7
]
- for Item in VerStringList:
+ for Item in VerStringList:
Ver = PrepareTest(Item)
if Item == SectionStringsVerItem1 or \
Item == SectionStringsVerItem2:
-
+
try:
InfBinariesInstance.SetBinary(Ver = Ver, ArchList = ArchList)
except:
pass
-
+
else:
try:
InfBinariesInstance.SetBinary(Ver = Ver, ArchList = ArchList)
except:
- AllPassedFlag = False
-
+ AllPassedFlag = False
+
#
# For All Common Test
- #
+ #
CommonStringList = [
SectionStringsCommonItem1,
SectionStringsCommonItem2,
@@ -363,23 +363,23 @@ if __name__ == '__main__':
SectionStringsCommonItem10
]
- for Item in CommonStringList:
+ for Item in CommonStringList:
CommonBin = PrepareTest(Item)
if Item == SectionStringsCommonItem10 or \
Item == SectionStringsCommonItem1:
-
+
try:
InfBinariesInstance.SetBinary(CommonBinary = CommonBin, ArchList = ArchList)
except:
pass
-
+
else:
try:
InfBinariesInstance.SetBinary(Ver = Ver, ArchList = ArchList)
except:
print("Test Failed!")
AllPassedFlag = False
-
+
if AllPassedFlag :
print('All tests passed...')
else: