## @file\r
# This file contain unit test for DecParser\r
#\r
-# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>\r
#\r
-# This program and the accompanying materials are licensed and made available \r
-# under the terms and conditions of the BSD License which accompanies this \r
-# distribution. The full text of the license may be found at \r
+# This program and the accompanying materials are licensed and made available\r
+# under the terms and conditions of the BSD License which accompanies this\r
+# distribution. The full text of the license may be found at\r
# http://opensource.org/licenses/bsd-license.php\r
#\r
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
#\r
def TestToolFuncs():\r
assert IsValidCArray('{0x1, 0x23}')\r
- \r
+\r
# Empty after comma\r
assert not IsValidCArray('{0x1, 0x23, }')\r
- \r
+\r
# 0x2345 too long\r
assert not IsValidCArray('{0x1, 0x2345}')\r
- \r
+\r
# Must end with '}'\r
assert not IsValidCArray('{0x1, 0x23, ')\r
- \r
+\r
# Whitespace between numbers\r
assert not IsValidCArray('{0x1, 0x2 3, }')\r
- \r
+\r
assert IsValidPcdDatum('VOID*', '"test"')[0]\r
assert IsValidPcdDatum('VOID*', 'L"test"')[0]\r
assert IsValidPcdDatum('BOOLEAN', 'TRUE')[0]\r
assert IsValidPcdDatum('BOOLEAN', '0')[0]\r
assert IsValidPcdDatum('BOOLEAN', '1')[0]\r
assert IsValidPcdDatum('UINT8', '0xab')[0]\r
- \r
+\r
assert not IsValidPcdDatum('UNKNOWNTYPE', '0xabc')[0]\r
- assert not IsValidPcdDatum('UINT8', 'not number')[0] \r
- \r
+ assert not IsValidPcdDatum('UINT8', 'not number')[0]\r
+\r
assert( IsValidCFormatGuid('{ 0xfa0b1735 , 0x87a0, 0x4193, {0xb2, 0x66 , 0x53, 0x8c , 0x38, 0xaf, 0x48, 0xce }}'))\r
assert( not IsValidCFormatGuid('{ 0xfa0b1735 , 0x87a0, 0x4193, {0xb2, 0x66 , 0x53, 0x8c , 0x38, 0xaf, 0x48, 0xce }} 0xaa'))\r
\r
Path = os.path.normpath(Path)\r
try:\r
f = open(Path, 'w')\r
- \r
+\r
# Write test string to file\r
f.write(TestString)\r
- \r
+\r
# Close file\r
f.close()\r
except:\r
\r
# Call test function to test\r
Ret = TestFunc(Path, TestString)\r
- \r
+\r
# Test done, remove temporary file\r
os.remove(Path)\r
return Ret\r
assert DefObj.GetPackageName() == 'MdePkg'\r
assert DefObj.GetPackageGuid() == '1E73767F-8F52-4603-AEB4-F29B510B6766'\r
assert DefObj.GetPackageVersion() == '1.02'\r
- \r
+\r
TestString = '''\r
[Defines]\r
UNKNOW_KEY = 0x00010005 # A unknown key\r
'''\r
assert TestTemplate(TestString, TestError)\r
- \r
+\r
TestString = '''\r
[Defines]\r
PACKAGE_GUID = F-8F52-4603-AEB4-F29B510B6766 # Error GUID\r
[Includes.IA32]\r
Include/Ia32\r
'''\r
- \r
+\r
# Create directory in current directory\r
try:\r
os.makedirs('Include/Ia32')\r
except:\r
pass\r
Parser = TestTemplate(TestString, TestOK)\r
- \r
+\r
IncObj = Parser.GetIncludeSectionObject()\r
Items = IncObj.GetIncludes()\r
assert len(Items) == 1\r
assert Items[0].File == 'Include'\r
- \r
+\r
Items = IncObj.GetIncludes('IA32')\r
assert len(Items) == 1\r
# normpath is called in DEC parser so '/' is converted to '\'\r
assert Items[0].File == 'Include\\Ia32'\r
- \r
+\r
TestString = '''\r
[Defines]\r
DEC_SPECIFICATION = 0x00010005\r
Include_not_exist # directory does not exist\r
'''\r
assert TestTemplate(TestString, TestError)\r
- \r
+\r
os.removedirs('Include/Ia32')\r
\r
def TestDecGuidPpiProtocol():\r
assert len(Items) == 1\r
assert Items[0].GuidCName == 'gEfiGlobalVariableGuid'\r
assert Items[0].GuidCValue == '{ 0x8BE4DF61, 0x93CA, 0x11D2, { 0xAA, 0x0D, 0x00, 0xE0, 0x98, 0x03, 0x2B, 0x8C }}'\r
- \r
+\r
Obj = Parser.GetProtocolSectionObject()\r
Items = Obj.GetProtocols()\r
assert Obj.GetSectionName() == 'Protocols'.upper()\r
assert len(Items) == 1\r
assert Items[0].GuidCName == 'gEfiBdsArchProtocolGuid'\r
assert Items[0].GuidCValue == '{ 0x665E3FF6, 0x46CC, 0x11D4, { 0x9A, 0x38, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0x4D }}'\r
- \r
+\r
Obj = Parser.GetPpiSectionObject()\r
Items = Obj.GetPpis()\r
assert Obj.GetSectionName() == 'Ppis'.upper()\r
[PcdsFeatureFlag]\r
## If TRUE, the component name protocol will not be installed.\r
gEfiMdePkgTokenSpaceGuid.PcdComponentNameDisable|FALSE|BOOLEAN|0x0000000d\r
- \r
+\r
[PcdsFixedAtBuild]\r
## Indicates the maximum length of unicode string\r
gEfiMdePkgTokenSpaceGuid.PcdMaximumUnicodeStringLength|1000000|UINT32|0x00000001\r
- \r
+\r
[PcdsFixedAtBuild.IPF]\r
## The base address of IO port space for IA64 arch\r
gEfiMdePkgTokenSpaceGuid.PcdIoBlockBaseAddressForIpf|0x0ffffc000000|UINT64|0x0000000f\r
- \r
+\r
[PcdsFixedAtBuild,PcdsPatchableInModule]\r
## This flag is used to control the printout of DebugLib\r
gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x80000000|UINT32|0x00000006\r
- \r
+\r
[PcdsFixedAtBuild,PcdsPatchableInModule,PcdsDynamic]\r
## This value is used to set the base address of pci express hierarchy\r
gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress|0xE0000000|UINT64|0x0000000a\r
assert Items[0].DefaultValue == 'FALSE'\r
assert Items[0].DatumType == 'BOOLEAN'\r
assert Items[0].TokenValue == '0x0000000d'\r
- \r
+\r
Items = Obj.GetPcdsByType('PcdsFixedAtBuild')\r
assert len(Items) == 4\r
assert len(Obj.GetPcdsByType('PcdsPatchableInModule')) == 2\r