Upgrade googletest to 011959aafddcd30611003de96cfd8d7a7685c700
Test: None
Change-Id: If8abc786d1f7a868efa9ee69bcf05be3ed4aa7be
diff --git a/METADATA b/METADATA
new file mode 100644
index 0000000..f6320aa
--- /dev/null
+++ b/METADATA
@@ -0,0 +1,19 @@
+name: "googletest"
+description: "Google\'s C++ test framework!"
+third_party {
+ url {
+ type: HOMEPAGE
+ value: "https://github.com/google/googletest"
+ }
+ url {
+ type: GIT
+ value: "https://github.com/google/googletest.git"
+ }
+ version: "011959aafddcd30611003de96cfd8d7a7685c700"
+ license_type: NOTICE
+ last_upgrade_date {
+ year: 2020
+ month: 5
+ day: 13
+ }
+}
diff --git a/OWNERS b/OWNERS
new file mode 100644
index 0000000..7529cb9
--- /dev/null
+++ b/OWNERS
@@ -0,0 +1 @@
+include platform/system/core:/janitors/OWNERS
diff --git a/TEST_MAPPING b/TEST_MAPPING
new file mode 100644
index 0000000..c4002f2
--- /dev/null
+++ b/TEST_MAPPING
@@ -0,0 +1,7 @@
+{
+ "presubmit": [
+ {
+ "name": "gtest_isolated_tests"
+ }
+ ]
+}
diff --git a/googlemock/Android.bp b/googlemock/Android.bp
new file mode 100644
index 0000000..d86410d
--- /dev/null
+++ b/googlemock/Android.bp
@@ -0,0 +1,113 @@
+// Copyright (C) 2016 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+cc_defaults {
+ name: "gmock_flags",
+
+ local_include_dirs: ["include"],
+ export_include_dirs: ["include"],
+
+ cflags: [
+ "-Wall",
+ "-Werror",
+ "-Wno-missing-field-initializers",
+ "-Wno-sign-compare",
+ "-Wno-unused-parameter",
+ ],
+}
+
+cc_defaults {
+ name: "gmock_ndk",
+ sdk_version: "9",
+ stl: "c++_static",
+ cppflags: ["-std=c++11"],
+}
+
+cc_defaults {
+ name: "gmock_defaults",
+ host_supported: true,
+ sanitize: {
+ never: true,
+ },
+ target: {
+ linux_bionic: {
+ enabled: true,
+ },
+ windows: {
+ enabled: true,
+ },
+ },
+}
+
+cc_library_static {
+ name: "libgmock_ndk",
+ defaults: [
+ "gmock_ndk",
+ "gmock_flags",
+ ],
+ srcs: ["src/gmock-all.cc"],
+ static_libs: ["libgtest_ndk_c++"],
+}
+
+cc_library_static {
+ name: "libgmock_main_ndk",
+ defaults: [
+ "gmock_ndk",
+ "gmock_flags",
+ ],
+ srcs: ["src/gmock_main.cc"],
+ static_libs: ["libgtest_ndk_c++"],
+}
+
+cc_library_static {
+ name: "libgmock",
+ defaults: [
+ "gmock_defaults",
+ "gmock_flags",
+ ],
+ srcs: ["src/gmock-all.cc"],
+ rtti: true,
+ static_libs: ["libgtest"],
+ vendor_available: true,
+}
+
+cc_library_static {
+ name: "libgmock_main",
+ defaults: [
+ "gmock_defaults",
+ "gmock_flags",
+ ],
+ srcs: ["src/gmock_main.cc"],
+ static_libs: ["libgtest"],
+ vendor_available: true,
+}
+
+// Deprecated: use libgmock instead
+cc_library_host_static {
+ name: "libgmock_host",
+ defaults: [
+ "gmock_defaults",
+ "gmock_flags",
+ ],
+ whole_static_libs: ["libgmock"],
+}
+
+cc_library_host_static {
+ name: "libgmock_main_host",
+ defaults: [
+ "gmock_defaults",
+ "gmock_flags",
+ ],
+ whole_static_libs: ["libgmock_main"],
+}
diff --git a/googlemock/MODULE_LICENSE_BSD_LIKE b/googlemock/MODULE_LICENSE_BSD_LIKE
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/googlemock/MODULE_LICENSE_BSD_LIKE
diff --git a/googlemock/NOTICE b/googlemock/NOTICE
new file mode 120000
index 0000000..7a694c9
--- /dev/null
+++ b/googlemock/NOTICE
@@ -0,0 +1 @@
+LICENSE
\ No newline at end of file
diff --git a/googlemock/include/gmock/gmock-matchers.h b/googlemock/include/gmock/gmock-matchers.h
index 08fd6d1..0403d14 100644
--- a/googlemock/include/gmock/gmock-matchers.h
+++ b/googlemock/include/gmock/gmock-matchers.h
@@ -285,6 +285,8 @@
clients of class B */
/* Symbol involving type with internal linkage not defined */)
+#pragma GCC system_header
+
namespace testing {
// To implement a matcher Foo for type T, define:
diff --git a/googlemock/test/Android.bp b/googlemock/test/Android.bp
new file mode 100644
index 0000000..84e3184
--- /dev/null
+++ b/googlemock/test/Android.bp
@@ -0,0 +1,69 @@
+// Copyright (C) 2016 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+cc_defaults {
+ name: "gmock_test_defaults",
+ host_supported: true,
+ gtest: false,
+ cflags: [
+ "-Wall",
+ "-Werror",
+ "-Wno-sign-compare",
+ "-Wno-unused-parameter",
+ "-Wno-unused-private-field",
+ ],
+ include_dirs: [
+ "external/googletest/googlemock",
+ "external/googletest/googletest",
+ ],
+ static_libs: [
+ "libgmock_main",
+ "libgmock",
+ "libgtest",
+ ],
+}
+
+cc_test {
+ name: "gmock_tests",
+ defaults: ["gmock_test_defaults"],
+ test_per_src: true,
+ srcs: [
+ "gmock-actions_test.cc",
+ "gmock-cardinalities_test.cc",
+
+ // Test is disabled because Android doesn't build gmock with exceptions.
+ //"gmock_ex_test.cc",
+
+ "gmock-generated-actions_test.cc",
+ "gmock-generated-matchers_test.cc",
+ "gmock-internal-utils_test.cc",
+ "gmock-matchers_test.cc",
+ "gmock-more-actions_test.cc",
+ "gmock-nice-strict_test.cc",
+ "gmock-port_test.cc",
+ "gmock-spec-builders_test.cc",
+ "gmock_test.cc",
+ ],
+}
+
+cc_test {
+ name: "gmock_link_test",
+ defaults: ["gmock_test_defaults"],
+ relative_install_path: "gmock_tests",
+ no_named_install_directory: true,
+ srcs: [
+ "gmock_link_test.cc",
+ "gmock_link2_test.cc",
+ ],
+}
diff --git a/googletest/Android.bp b/googletest/Android.bp
new file mode 100644
index 0000000..d93fcec
--- /dev/null
+++ b/googletest/Android.bp
@@ -0,0 +1,102 @@
+// Copyright (C) 2016 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+cc_defaults {
+ name: "libgtest_defaults",
+ export_include_dirs: ["include"],
+ cflags: ["-Wall", "-Werror", "-Wno-unused-private-field"],
+}
+
+cc_defaults {
+ name: "libgtest_host_defaults",
+ target: {
+ linux_bionic: {
+ enabled: true,
+ },
+ windows: {
+ enabled: true,
+ },
+ },
+}
+
+// NDK libraries.
+// We need to build one pair of (libgtest, libgtest_main) for each of the three
+// STLs we support in the NDK since the user's app might use any of them.
+
+// libc++
+cc_library_static {
+ name: "libgtest_ndk_c++",
+ defaults: ["libgtest_defaults"],
+ sdk_version: "9",
+ stl: "c++_static",
+ srcs: ["src/gtest-all.cc"],
+}
+
+cc_library_static {
+ name: "libgtest_main_ndk_c++",
+ defaults: ["libgtest_defaults"],
+ sdk_version: "9",
+ stl: "c++_static",
+ srcs: ["src/gtest_main.cc"],
+}
+
+// Platform and host libraries.
+cc_library_static {
+ name: "libgtest",
+ defaults: ["libgtest_defaults", "libgtest_host_defaults"],
+ host_supported: true,
+ vendor_available: true,
+ native_bridge_supported: true,
+ srcs: ["src/gtest-all.cc"],
+ rtti: true,
+}
+
+cc_library_static {
+ name: "libgtest_main",
+ defaults: ["libgtest_defaults", "libgtest_host_defaults"],
+ host_supported: true,
+ vendor_available: true,
+ native_bridge_supported: true,
+ srcs: ["src/gtest_main.cc"],
+}
+
+// Legacy libraries for makefiles that refer to libgtest_host
+cc_library_host_static {
+ name: "libgtest_host",
+ whole_static_libs: ["libgtest"],
+ defaults: ["libgtest_host_defaults"],
+}
+
+cc_library_host_static {
+ name: "libgtest_main_host",
+ whole_static_libs: ["libgtest_main"],
+ defaults: ["libgtest_host_defaults"],
+}
+
+cc_library { // TODO: make this a cc_library_headers module
+ name: "libgtest_prod",
+ defaults: ["libgtest_defaults", "libgtest_host_defaults"],
+ host_supported: true,
+ native_bridge_supported: true,
+ recovery_available: true,
+ vendor_available: true,
+ export_include_dirs: ["include"],
+ apex_available: [
+ "//apex_available:anyapex",
+ "//apex_available:platform",
+ ],
+ min_sdk_version: "apex_inherit",
+}
+
+// Tests are in the Android.mk. Run with external/googletest/run_tests.py.
diff --git a/googletest/Android.mk b/googletest/Android.mk
new file mode 100644
index 0000000..38a44db
--- /dev/null
+++ b/googletest/Android.mk
@@ -0,0 +1,150 @@
+#
+# Copyright (C) 2016 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# Note that the platform modules are defined in the Android.bp. This file is
+# used for the NDK.
+
+# If we're being invoked from ndk-build, we'll have NDK_ROOT defined.
+ifdef NDK_ROOT
+
+LOCAL_PATH := $(call my-dir)
+
+# Defines a test module.
+#
+# The upstream gtest configuration builds each of these as separate executables.
+# It's a pain for how we run tests in the platform, but we can handle that with
+# a test running script.
+#
+# $(1): Test name. test/$(1).cc will automatically be added to sources.
+# $(2): Additional source files.
+# $(3): "libgtest_main" or empty.
+#
+# Use -Wno-unnamed-type-template-args because gtest_unittest.cc wants anonymous enum type.
+define gtest-unit-test
+ $(eval include $(CLEAR_VARS)) \
+ $(eval LOCAL_MODULE := $(1)) \
+ $(eval LOCAL_CPP_EXTENSION := .cc) \
+ $(eval LOCAL_SRC_FILES := test/$(strip $(1)).cc $(2)) \
+ $(eval LOCAL_C_INCLUDES := $(LOCAL_PATH)/include) \
+ $(eval LOCAL_CPP_FEATURES := rtti) \
+ $(eval LOCAL_CFLAGS := -Wall -Werror -Wno-sign-compare -Wno-unnamed-type-template-args) \
+ $(eval LOCAL_CFLAGS += -Wno-unused-private-field) \
+ $(eval LOCAL_STATIC_LIBRARIES := $(3) libgtest) \
+ $(eval include $(BUILD_EXECUTABLE))
+endef
+
+# Create modules for each test in the suite.
+#
+# The NDK variant of gtest-death-test_test is disabled because we don't have
+# pthread_atfork on android-9.
+define gtest-test-suite
+ $(eval $(call gtest-unit-test,googletest-death-test-test,,libgtest_main)) \
+ $(eval $(call gtest-unit-test,googletest-filepath-test,,libgtest_main)) \
+ $(eval $(call gtest-unit-test,googletest-listener-test,,libgtest_main)) \
+ $(eval $(call gtest-unit-test,googletest-message-test,,libgtest_main)) \
+ $(eval $(call gtest-unit-test,googletest-options-test,,libgtest_main)) \
+ $(eval $(call gtest-unit-test,googletest-param-test-test, \
+ test/googletest-param-test2-test.cc,)) \
+ $(eval $(call gtest-unit-test,googletest-port-test,,libgtest_main)) \
+ $(eval $(call gtest-unit-test,googletest-printers-test,,libgtest_main)) \
+ $(eval $(call gtest-unit-test,googletest-test-part-test,,libgtest_main)) \
+ $(eval $(call gtest-unit-test, \
+ gtest-typed-test_test,test/gtest-typed-test2_test.cc, \
+ libgtest_main)) \
+ $(eval $(call gtest-unit-test,gtest-unittest-api_test,,)) \
+ $(eval $(call gtest-unit-test,gtest_environment_test,,)) \
+ $(eval $(call gtest-unit-test,gtest_main_unittest,,libgtest_main)) \
+ $(eval $(call gtest-unit-test,gtest_no_test_unittest,,)) \
+ $(eval $(call gtest-unit-test,gtest_pred_impl_unittest,,libgtest_main)) \
+ $(eval $(call gtest-unit-test,gtest_premature_exit_test,,)) \
+ $(eval $(call gtest-unit-test,gtest_prod_test,test/production.cc, \
+ libgtest_main)) \
+ $(eval $(call gtest-unit-test,gtest_repeat_test,,)) \
+ $(eval $(call gtest-unit-test,gtest_skip_test,,libgtest_main)) \
+ $(eval $(call gtest-unit-test,gtest_sole_header_test,,libgtest_main)) \
+ $(eval $(call gtest-unit-test,gtest_stress_test,,)) \
+ $(eval $(call gtest-unit-test,gtest_unittest,,libgtest_main))
+endef
+
+# Test is disabled because Android doesn't build gtest with exceptions.
+# $(eval $(call gtest-unit-test,gtest_throw_on_failure_ex_test,,))
+# $(eval $(call gtest-unit-test,gtest_assert_by_exception_test,,))
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := libgtest
+LOCAL_SRC_FILES := src/gtest-all.cc
+LOCAL_C_INCLUDES := $(LOCAL_PATH)/src $(LOCAL_PATH)/include
+LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include
+LOCAL_CPP_FEATURES := rtti
+include $(BUILD_STATIC_LIBRARY)
+
+# Note: Unlike the platform, libgtest_main carries a dependency on libgtest.
+# Users don't need to manually depend on both.
+include $(CLEAR_VARS)
+LOCAL_MODULE := libgtest_main
+LOCAL_SRC_FILES := src/gtest_main.cc
+LOCAL_C_INCLUDES := $(LOCAL_PATH)/src $(LOCAL_PATH)/include
+LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
+LOCAL_CPP_FEATURES := rtti
+LOCAL_STATIC_LIBRARIES := libgtest
+include $(BUILD_STATIC_LIBRARY)
+
+# These are the old names of these libraries. They don't match the platform or
+# the upstream build, but we've been requiring that people put them in their NDK
+# makefiles for years.
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := googletest_static
+LOCAL_SRC_FILES := src/gtest-all.cc
+LOCAL_C_INCLUDES := $(LOCAL_PATH)/src $(LOCAL_PATH)/include
+LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
+LOCAL_CPP_FEATURES := rtti
+include $(BUILD_STATIC_LIBRARY)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := libgoogletest_main
+LOCAL_CPP_EXTENSION := .cc
+LOCAL_SRC_FILES := src/gtest_main.cc
+LOCAL_C_INCLUDES := $(LOCAL_PATH)/src $(LOCAL_PATH)/include
+LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
+LOCAL_CPP_FEATURES := rtti
+LOCAL_STATIC_LIBRARIES := libgtest
+include $(BUILD_STATIC_LIBRARY)
+
+# The NDK used to include shared versions of these libraries, for some reason.
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := googletest_shared
+LOCAL_SRC_FILES := src/gtest-all.cc
+LOCAL_C_INCLUDES := $(LOCAL_PATH)/src $(LOCAL_PATH)/include
+LOCAL_CFLAGS := -DGTEST_CREATE_SHARED_LIBRARY
+LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
+LOCAL_CPP_FEATURES := rtti
+include $(BUILD_SHARED_LIBRARY)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := googletest_main_shared
+LOCAL_SRC_FILES := src/gtest_main.cc
+LOCAL_C_INCLUDES := $(LOCAL_PATH)/src $(LOCAL_PATH)/include
+LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
+LOCAL_CPP_FEATURES := rtti
+LOCAL_SHARED_LIBRARIES := googletest_shared
+include $(BUILD_STATIC_LIBRARY)
+
+# Tests for use in the NDK itself.
+$(call gtest-test-suite)
+
+endif
diff --git a/googletest/MODULE_LICENSE_BSD_LIKE b/googletest/MODULE_LICENSE_BSD_LIKE
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/googletest/MODULE_LICENSE_BSD_LIKE
diff --git a/googletest/NOTICE b/googletest/NOTICE
new file mode 120000
index 0000000..7a694c9
--- /dev/null
+++ b/googletest/NOTICE
@@ -0,0 +1 @@
+LICENSE
\ No newline at end of file
diff --git a/googletest/include/gtest/internal/custom/gtest-port.h b/googletest/include/gtest/internal/custom/gtest-port.h
index cd85d95..d941209 100644
--- a/googletest/include/gtest/internal/custom/gtest-port.h
+++ b/googletest/include/gtest/internal/custom/gtest-port.h
@@ -34,4 +34,7 @@
#ifndef GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PORT_H_
#define GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PORT_H_
+// Suppress warnings for deprecated *_TEST_CASE_* macros.
+#define GTEST_INTERNAL_DEPRECATED(message)
+
#endif // GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_PORT_H_
diff --git a/googletest/include/gtest/internal/custom/gtest.h b/googletest/include/gtest/internal/custom/gtest.h
index 4c8e07b..b134fc7 100644
--- a/googletest/include/gtest/internal/custom/gtest.h
+++ b/googletest/include/gtest/internal/custom/gtest.h
@@ -34,4 +34,26 @@
#ifndef GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_H_
#define GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_H_
+#if !GTEST_OS_WINDOWS
+# define GTEST_CUSTOM_TEMPDIR_FUNCTION_ GetAndroidTempDir
+# include <unistd.h>
+static inline std::string GetAndroidTempDir() {
+ // Android doesn't have /tmp, and /sdcard is no longer accessible from
+ // an app context starting from Android O. On Android, /data/local/tmp
+ // is usually used as the temporary directory, so try that first...
+ if (access("/data/local/tmp", R_OK | W_OK | X_OK) == 0) return "/data/local/tmp/";
+
+ // Processes running in an app context can't write to /data/local/tmp,
+ // so fall back to the current directory...
+ std::string result = "./";
+ char* cwd = getcwd(NULL, 0);
+ if (cwd != NULL) {
+ result = cwd;
+ result += "/";
+ free(cwd);
+ }
+ return result;
+}
+#endif //GTEST_OS_WINDOWS
+
#endif // GTEST_INCLUDE_GTEST_INTERNAL_CUSTOM_GTEST_H_
diff --git a/googletest/src/gtest-port.cc b/googletest/src/gtest-port.cc
index c180233..60f105a 100644
--- a/googletest/src/gtest-port.cc
+++ b/googletest/src/gtest-port.cc
@@ -1095,8 +1095,7 @@
# else
// There's no guarantee that a test has write access to the current
// directory, so we create the temporary file in the /tmp directory
- // instead. We use /tmp on most systems, and /sdcard on Android.
- // That's because Android doesn't have /tmp.
+ // instead.
# if GTEST_OS_LINUX_ANDROID
// Note: Android applications are expected to call the framework's
// Context.getExternalStorageDirectory() method through JNI to get
@@ -1109,7 +1108,8 @@
// The location /data/local/tmp is directly accessible from native code.
// '/sdcard' and other variants cannot be relied on, as they are not
// guaranteed to be mounted, or may have a delay in mounting.
- char name_template[] = "/data/local/tmp/gtest_captured_stream.XXXXXX";
+ ::std::string name_template_buf = TempDir() + "gtest_captured_stream.XXXXXX";
+ char* name_template = &name_template_buf[0];
# else
char name_template[] = "/tmp/captured_stream.XXXXXX";
# endif // GTEST_OS_LINUX_ANDROID
diff --git a/googletest/test/Android.bp b/googletest/test/Android.bp
new file mode 100644
index 0000000..6a36a06
--- /dev/null
+++ b/googletest/test/Android.bp
@@ -0,0 +1,187 @@
+// Copyright (C) 2016 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+cc_defaults {
+ name: "gtest_test_defaults",
+ host_supported: true,
+ gtest: false,
+ cflags: [
+ "-Wall",
+ "-Werror",
+ "-Wno-sign-compare",
+ // because gtest_unittest.cc wants anonymous enum type.
+ "-Wno-unnamed-type-template-args",
+ "-Wno-unused-private-field",
+ ],
+ include_dirs: ["external/googletest/googletest"],
+ static_libs: ["libgtest"],
+ relative_install_path: "gtest_tests",
+ no_named_install_directory: true,
+}
+
+cc_defaults {
+ name: "gtest_ndk_test_defaults",
+ gtest: false,
+ cflags: [
+ "-Wall",
+ "-Werror",
+ "-Wno-sign-compare",
+ "-Wno-unnamed-type-template-args",
+ "-Wno-unused-private-field",
+ ],
+ include_dirs: ["external/googletest/googletest"],
+ static_libs: ["libgtest_ndk_c++"],
+ relative_install_path: "gtest_ndk_tests",
+ no_named_install_directory: true,
+ sdk_version: "9",
+ stl: "c++_static",
+}
+
+cc_test {
+ name: "gtest_tests",
+ defaults: ["gtest_test_defaults"],
+ test_per_src: true,
+ srcs: [
+ "googletest-death-test-test.cc",
+ "googletest-filepath-test.cc",
+ "googletest-listener-test.cc",
+ "googletest-message-test.cc",
+ "googletest-options-test.cc",
+ "googletest-port-test.cc",
+ "googletest-printers-test.cc",
+ "googletest-test-part-test.cc",
+ "gtest-unittest-api_test.cc",
+ "gtest_main_unittest.cc",
+ "gtest_pred_impl_unittest.cc",
+ "gtest_skip_test.cc",
+ "gtest_sole_header_test.cc",
+ "gtest_unittest.cc",
+ ],
+ static_libs: ["libgtest_main"],
+}
+
+cc_test {
+ name: "gtest_tests_no_main",
+ defaults: ["gtest_test_defaults"],
+ test_per_src: true,
+ srcs: [
+ "gtest_environment_test.cc",
+ "gtest_no_test_unittest.cc",
+ "gtest_premature_exit_test.cc",
+ "gtest_repeat_test.cc",
+ "gtest_stress_test.cc",
+
+ // Tests are disabled because Android doesn't build gtest with exceptions
+ // "gtest_throw_on_failure_ex_test.cc",
+ // "gtest_assert_by_exception_test.cc",
+ ],
+}
+
+cc_test {
+ name: "googletest-param-test-test",
+ defaults: ["gtest_test_defaults"],
+ srcs: [
+ "googletest-param-test-test.cc",
+ "googletest-param-test2-test.cc",
+ ],
+}
+
+cc_test {
+ name: "gtest-typed-test_test",
+ defaults: ["gtest_test_defaults"],
+ srcs: [
+ "gtest-typed-test_test.cc",
+ "gtest-typed-test2_test.cc",
+ ],
+ static_libs: ["libgtest_main"],
+}
+
+cc_test {
+ name: "gtest_prod_test",
+ defaults: ["gtest_test_defaults"],
+ srcs: [
+ "gtest_prod_test.cc",
+ "production.cc",
+ ],
+ static_libs: ["libgtest_main"],
+}
+
+cc_test {
+ name: "gtest_ndk_tests",
+ defaults: ["gtest_ndk_test_defaults"],
+ test_per_src: true,
+ srcs: [
+ "googletest-death-test-test.cc",
+ "googletest-filepath-test.cc",
+ "googletest-listener-test.cc",
+ "googletest-message-test.cc",
+ "googletest-options-test.cc",
+ "googletest-port-test.cc",
+ "googletest-printers-test.cc",
+ "googletest-test-part-test.cc",
+ "gtest-unittest-api_test.cc",
+ "gtest_main_unittest.cc",
+ "gtest_pred_impl_unittest.cc",
+ "gtest_skip_test.cc",
+ "gtest_sole_header_test.cc",
+ "gtest_unittest.cc",
+ ],
+ static_libs: ["libgtest_main_ndk_c++"],
+}
+
+cc_test {
+ name: "gtest_ndk_tests_no_main",
+ defaults: ["gtest_ndk_test_defaults"],
+ test_per_src: true,
+ srcs: [
+ "gtest_environment_test.cc",
+ "gtest_no_test_unittest.cc",
+ "gtest_premature_exit_test.cc",
+ "gtest_repeat_test.cc",
+ "gtest_stress_test.cc",
+
+ // Tests are disabled because Android doesn't build gtest with exceptions
+ // "gtest_throw_on_failure_ex_test.cc",
+ // "gtest_assert_by_exception_test.cc",
+ ],
+}
+
+cc_test {
+ name: "googletest-param-test-test_ndk",
+ defaults: ["gtest_ndk_test_defaults"],
+ srcs: [
+ "googletest-param-test-test.cc",
+ "googletest-param-test2-test.cc",
+ ],
+}
+
+cc_test {
+ name: "gtest-typed-test_test_ndk",
+ defaults: ["gtest_ndk_test_defaults"],
+ srcs: [
+ "gtest-typed-test_test.cc",
+ "gtest-typed-test2_test.cc",
+ ],
+ static_libs: ["libgtest_main_ndk_c++"],
+}
+
+cc_test {
+ name: "gtest_prod_test_ndk",
+ defaults: ["gtest_ndk_test_defaults"],
+ srcs: [
+ "gtest_prod_test.cc",
+ "production.cc",
+ ],
+ static_libs: ["libgtest_main_ndk_c++"],
+}
diff --git a/googletest/test/googletest-options-test.cc b/googletest/test/googletest-options-test.cc
index f07b316..2b959c2 100644
--- a/googletest/test/googletest-options-test.cc
+++ b/googletest/test/googletest-options-test.cc
@@ -115,7 +115,13 @@
exe_str == "googletest-options-test" ||
exe_str == "gtest_all_test" ||
exe_str == "lt-gtest_all_test" ||
- exe_str == "gtest_dll_test";
+ exe_str == "gtest_dll_test"
+#ifdef __ANDROID__
+ || exe_str == "gtest-options_test_ndk_c++" ||
+ exe_str == "gtest-options_test_ndk_gnustl" ||
+ exe_str == "gtest-options_test_ndk_stlport"
+#endif
+ ;
#endif // GTEST_OS_WINDOWS
if (!success)
FAIL() << "GetCurrentExecutableName() returns " << exe_str;
diff --git a/run_tests.py b/run_tests.py
new file mode 100755
index 0000000..bc6221e
--- /dev/null
+++ b/run_tests.py
@@ -0,0 +1,103 @@
+#!/usr/bin/env python
+#
+# Copyright (C) 2016 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+"""Runs all tests for gtest/gmock."""
+import argparse
+import logging
+import os
+import sys
+
+
+# pylint: disable=design
+
+
+def logger():
+ """Return the default logger for the module."""
+ return logging.getLogger(__name__)
+
+
+def call(cmd, *args, **kwargs):
+ """Proxy for subprocess.call with logging."""
+ import subprocess
+ logger().info('call `%s`', ' '.join(cmd))
+ return subprocess.call(cmd, *args, **kwargs)
+
+
+def parse_args():
+ "Parse and return command line arguments."""
+ parser = argparse.ArgumentParser()
+ parser.add_argument('--host', action='store_true')
+ parser.add_argument('-v', '--verbose', action='store_true')
+ return parser.parse_args()
+
+
+def main():
+ "Program entry point."""
+ args = parse_args()
+ log_level = logging.INFO
+ if args.verbose:
+ log_level = logging.DEBUG
+ logging.basicConfig(level=log_level)
+
+ if args.host:
+ test_location = os.path.join(os.environ['ANDROID_HOST_OUT'], 'nativetest64')
+ else:
+ data_dir = os.path.join(os.environ['OUT'], 'data')
+ test_location = os.path.join(data_dir, 'nativetest64')
+ if not os.path.exists(test_location):
+ test_location = os.path.join(data_dir, 'nativetest')
+
+ num_tests = 0
+ failures = []
+ for test_dir in ['gtest_tests', 'gtest_ndk_tests', 'gmock_tests']:
+ test_dir = os.path.join(test_location, test_dir)
+ if not os.path.isdir(test_dir):
+ logger().debug('Skipping %s', test_dir)
+ continue
+
+ logger().debug('Scanning %s for tests', test_dir)
+ for test in os.listdir(test_dir):
+ if not test.startswith('gtest') and not test.startswith('gmock'):
+ logger().debug('Skipping %s', test)
+ continue
+ num_tests += 1
+
+ if args.host:
+ cmd = [os.path.join(test_dir, test)]
+ if call(cmd) != 0:
+ failures.append(test)
+ else:
+ device_dir = test_dir.replace(os.environ['OUT'], '')
+ cmd = ['adb', 'shell', 'cd {} && ./{}'.format(device_dir, test)]
+ if call(cmd) != 0:
+ failures.append(test)
+
+ if num_tests == 0:
+ logger().error('No tests found!')
+ sys.exit(1)
+
+ num_failures = len(failures)
+ num_passes = num_tests - num_failures
+ logger().info('%d/%d tests passed', num_passes, num_tests)
+ if len(failures) > 0:
+ logger().error('Failures:\n%s', '\n'.join(failures))
+ else:
+ logger().info('All tests passed!')
+ sys.exit(num_failures)
+
+
+if __name__ == '__main__':
+ main()