From 15c3a04cd0fafd598c4c413d7d32d9827ee7b794 Mon Sep 17 00:00:00 2001 From: Jordan Justen Date: Tue, 23 Jun 2015 23:34:33 +0000 Subject: BaseTools/Tests: Verify 32-bit UTF-8 chars are rejected Since UTF-8 .uni unicode files might contain strings with unicode code points larger than 16-bits, and UEFI only supports UCS-2 characters, we need to make sure that BaseTools rejects these characters in UTF-8 .uni source files. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jordan Justen Reviewed-by: Michael D Kinney Reviewed-by: Yingke Liu git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17697 6f19259b-4bc3-4df7-8a09-765794883524 --- BaseTools/Tests/CheckUnicodeSourceFiles.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/BaseTools/Tests/CheckUnicodeSourceFiles.py b/BaseTools/Tests/CheckUnicodeSourceFiles.py index ad5fd18963..102dc3c1f9 100644 --- a/BaseTools/Tests/CheckUnicodeSourceFiles.py +++ b/BaseTools/Tests/CheckUnicodeSourceFiles.py @@ -114,6 +114,31 @@ class Tests(TestTools.BaseToolsTest): self.CheckFile(encoding=None, shouldPass=False, string=data) + def test32bitUnicodeCharInUtf8File(self): + data = u''' + #langdef en-US "English" + #string STR_A #language en-US "CodePoint (\U00010300) > 0xFFFF" + ''' + + self.CheckFile('utf_16', shouldPass=False, string=data) + + def test32bitUnicodeCharInUtf8File(self): + data = u''' + #langdef en-US "English" + #string STR_A #language en-US "CodePoint (\U00010300) > 0xFFFF" + ''' + + self.CheckFile('utf_8', shouldPass=False, string=data) + + def test32bitUnicodeCharInUtf8Comment(self): + data = u''' + // Even in comments, we reject non-UCS-2 chars: \U00010300 + #langdef en-US "English" + #string STR_A #language en-US "A" + ''' + + self.CheckFile('utf_8', shouldPass=False, string=data) + TheTestSuite = TestTools.MakeTheTestSuite(locals()) if __name__ == '__main__': -- cgit v1.2.3