summaryrefslogtreecommitdiffstats
path: root/ppapi/generate_ppapi_include_tests.py
diff options
context:
space:
mode:
authordmichael@google.com <dmichael@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-13 20:04:31 +0000
committerdmichael@google.com <dmichael@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-13 20:04:31 +0000
commit1ad2a1dbcde42412bb92c83fe5e0d6999ed00311 (patch)
treebec94376d42b1943e2830e695956252232283b4d /ppapi/generate_ppapi_include_tests.py
parentf68fbd1b300401c79df8df9773bbe7aa36ff6062 (diff)
downloadchromium_src-1ad2a1dbcde42412bb92c83fe5e0d6999ed00311.zip
chromium_src-1ad2a1dbcde42412bb92c83fe5e0d6999ed00311.tar.gz
chromium_src-1ad2a1dbcde42412bb92c83fe5e0d6999ed00311.tar.bz2
Add compile assertions to enforce the sizes of all structs and enums in the C API. Adjust some structs to make their sizes consistent across architectures. Note that some structs contain pointers, so are difficult to make consistent between 32-bit and 64-bit. Those types are in test_struct_sizes.c. Other types have a compile assertion immediately after their definition.
This was broken off from a bigger CL: http://codereview.chromium.org/5340003/ BUG=61004,92983 TEST=test_struct_sizes.c, compile assertions throughout See this CL for the code that helped generate the static assertions and find affected interfaces: http://codereview.chromium.org/5730003 Review URL: http://codereview.chromium.org/5674004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@69038 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/generate_ppapi_include_tests.py')
-rw-r--r--ppapi/generate_ppapi_include_tests.py31
1 files changed, 19 insertions, 12 deletions
diff --git a/ppapi/generate_ppapi_include_tests.py b/ppapi/generate_ppapi_include_tests.py
index 0668a68..01711ba 100644
--- a/ppapi/generate_ppapi_include_tests.py
+++ b/ppapi/generate_ppapi_include_tests.py
@@ -10,7 +10,7 @@
# - Verifies that all source code is in ppapi.gyp
# - Verifies that all sources in ppapi.gyp really do exist
# - Generates tests/test_c_includes.c
-# - Generates tests/test_cc_includes.cc
+# - Generates tests/test_cpp_includes.cc
# These tests are checked in to SVN.
# TODO(dmichael): Make this script execute as a gyp action, move the include
# tests to some 'generated' area, and remove them from version
@@ -29,7 +29,7 @@ SOURCE_FILE_RE = re.compile('.+\.(cc|c|h)$')
# not check whether source files under these directories are in the gyp file.
# TODO(dmichael): Put examples back in the build.
# TODO(brettw): Put proxy in the build when it's ready.
-IGNORE_RE = re.compile('^(examples|GLES2|proxy).*')
+IGNORE_RE = re.compile('^(examples|GLES2|proxy|tests\/clang).*')
GYP_TARGETS_KEY = 'targets'
GYP_SOURCES_KEY = 'sources'
@@ -92,8 +92,7 @@ def WriteLines(filename, lines):
COPYRIGHT_STRING_C = \
-"""
-/* Copyright (c) 2010 The Chromium Authors. All rights reserved.
+"""/* Copyright (c) 2010 The Chromium Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*
@@ -103,8 +102,7 @@ COPYRIGHT_STRING_C = \
"""
COPYRIGHT_STRING_CC = \
-"""
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+"""// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
@@ -127,26 +125,35 @@ def GetSourcesForTarget(target_name, gyp_file_data):
return []
-# Generate test_c_includes.c, which is a test to ensure that all the headers in
-# ppapi/c can be compiled with a C compiler.
+# Generate all_c_includes.h, which includes all C headers. This is part of
+# tests/test_c_sizes.c, which includes all C API files to ensure that all
+# the headers in ppapi/c can be compiled with a C compiler, and also asserts
+# (with compile-time assertions) that all structs and enums are a particular
+# size.
def GenerateCIncludeTest(gyp_file_data):
c_sources = GetSourcesForTarget('ppapi_c', gyp_file_data)
lines = [COPYRIGHT_STRING_C]
+ lines.append('#ifndef PPAPI_TESTS_ALL_C_INCLUDES_H_\n')
+ lines.append('#define PPAPI_TESTS_ALL_C_INCLUDES_H_\n\n')
for source in c_sources:
lines.append('#include "ppapi/' + source + '"\n')
- WriteLines('tests/test_c_includes.c', lines)
+ lines.append('\n#endif /* PPAPI_TESTS_ALL_C_INCLUDES_H_ */\n')
+ WriteLines('tests/all_c_includes.h', lines)
-# Generate test_cc_includes.cc, which is a test to ensure that all the headers
-# in ppapi/cpp can be compiled with a C++ compiler.
+# Generate all_cpp_includes.h, which is used by test_cpp_includes.cc to ensure
+# that all the headers in ppapi/cpp can be compiled with a C++ compiler.
def GenerateCCIncludeTest(gyp_file_data):
cc_sources = GetSourcesForTarget('ppapi_cpp_objects', gyp_file_data)
header_re = re.compile('.+\.h$')
lines = [COPYRIGHT_STRING_CC]
+ lines.append('#ifndef PPAPI_TESTS_ALL_CPP_INCLUDES_H_\n')
+ lines.append('#define PPAPI_TESTS_ALL_CPP_INCLUDES_H_\n\n')
for source in cc_sources:
if header_re.match(source):
lines.append('#include "ppapi/' + source + '"\n')
- WriteLines('tests/test_cc_includes.cc', lines)
+ lines.append('\n#endif // PPAPI_TESTS_ALL_CPP_INCLUDES_H_\n')
+ WriteLines('tests/all_cpp_includes.h', lines)
def main():