Add INTxx_MAX checks into check_all.py
authorBoris Zanin <boris.zanin@mobica.com>
Wed, 10 Jan 2018 12:15:36 +0000 (13:15 +0100)
committerAlexander Galazin <Alexander.Galazin@arm.com>
Mon, 15 Jan 2018 12:21:49 +0000 (07:21 -0500)
The mentioned consts are not defined in Windows, but are defined in linux.
Presence of this consts breaks Windows builds. To make it easyily detectable
under linux additional check for [U]INT[8,16,32,64]_MAX consts is added
into check_all.py script.

Components: Framework

VK-GL-CTS Issue: 934

Change-Id: I1882c0cd283a63a623972cb69ffb292531e37d10

scripts/src_util/check_all.py
scripts/src_util/check_invalid_literals.py [moved from scripts/src_util/check_invalid_types.py with 84% similarity]

index b8378a5..4fc2abc 100644 (file)
@@ -26,7 +26,7 @@ from common import getChangedFiles, getAllProjectFiles
 from check_include_guards import checkIncludeGuards
 from check_whitespace import checkWhitespace
 from check_license import checkLicense
-from check_invalid_types import checkInvalidTypes
+from check_invalid_literals import checkInvalidLiterals
 
 if __name__ == "__main__":
     parser = ArgumentParser()
@@ -44,7 +44,7 @@ if __name__ == "__main__":
         checkWhitespace(files),
         checkIncludeGuards(files),
         checkLicense(files),
-        checkInvalidTypes(files),
+        checkInvalidLiterals(files),
         #todo checkRedundantIncludeGuards(files),
         ])
 
similarity index 84%
rename from scripts/src_util/check_invalid_types.py
rename to scripts/src_util/check_invalid_literals.py
index a4f10a2..8f7f79e 100644 (file)
@@ -26,6 +26,11 @@ import sys
 from argparse import ArgumentParser
 from common import getChangedFiles, getAllProjectFiles, isTextFile
 
+CHECK_LITERAL_PATTERNS = [
+       r'\b[us]*int[0-9]+_t\b',
+       r'\b[U]*INT(_LEAST|_FAST|)[0-9]+_MAX\b',
+]
+
 CHECK_LIST = [
        ".cpp",
        ".hpp",
@@ -46,7 +51,7 @@ EXCLUSION_LIST = [
 def checkEnds(line, ends):
        return any(line.endswith(end) for end in ends)
 
-def checkFileInvalidTypes (file):
+def checkFileInvalidLiterals (file):
        error = False
 
        if checkEnds(file.replace("\\", "/"), CHECK_LIST) and not checkEnds(file.replace("\\", "/"), EXCLUSION_LIST):
@@ -62,19 +67,20 @@ def checkFileInvalidTypes (file):
                                del list[1::2]
                                line = ' '
                                line = line.join(list)
-                       found = re.search(r'\b[us]*int[0-9]+_t\b', line)
-                       if found is not None:
-                               error = True
-                               print "%s:%i Unacceptable type found" % (file, lineNum+1)
+                       for pattern in CHECK_LITERAL_PATTERNS:
+                               found = re.search(pattern, line)
+                               if found is not None:
+                                       error = True
+                                       print "%s:%i Unacceptable type found (pattern:%s)" % (file, lineNum+1, pattern)
                f.close()
 
        return not error
 
-def checkInvalidTypes (files):
+def checkInvalidLiterals (files):
        error = False
        for file in files:
                if isTextFile(file):
-                       if not checkFileInvalidTypes(file):
+                       if not checkFileInvalidLiterals(file):
                                error = True
 
        return not error
@@ -91,7 +97,7 @@ if __name__ == "__main__":
        else:
                files = getAllProjectFiles()
 
-       error = not checkInvalidTypes(files)
+       error = not checkInvalidLiterals(files)
 
        if error:
                print "One or more checks failed"