1 # Copyright (C) 2009 The Android Open Source Project 2 # 3 # Licensed under the Apache License, Version 2.0 (the "License"); 4 # you may not use this file except in compliance with the License. 5 # You may obtain a copy of the License at 6 # 7 # http://www.apache.org/licenses/LICENSE-2.0 8 # 9 # Unless required by applicable law or agreed to in writing, software 10 # distributed under the License is distributed on an "AS IS" BASIS, 11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 # See the License for the specific language governing permissions and 13 # limitations under the License. 14 # 15 # 16 17 # Test for gtest. Run using 'runtest'. 18 # The linux build and tests are run under valgrind by 'runtest'. 19 20 LOCAL_PATH := $(call my-dir) 21 include $(CLEAR_VARS) 22 23 # TODO: Refactor these as 1st class build templates as suggested in 24 # review of the original import. 25 26 libgtest_test_common_includes := \ 27 $(LOCAL_PATH)/../include \ 28 $(LOCAL_PATH)/.. 29 30 libgtest_test_includes := $(libgtest_test_common_includes) bionic external/stlport/stlport 31 libgtest_test_static_lib := libgtest_main libgtest 32 libgtest_test_shared_lib := libstlport 33 libgtest_test_ldflags := 34 35 libgtest_test_host_includes := $(libgtest_test_common_includes) 36 libgtest_test_host_static_lib := libgtest_main_host libgtest_host 37 libgtest_test_host_shared_lib := 38 libgtest_test_host_ldflags := -lpthread 39 40 # $(2) and $(4) must be set or cleared in sync. $(2) is used to 41 # generate the right make target (host vs device). $(4) is used in the 42 # module's name and to have different module names for the host vs 43 # device builds. Finally $(4) is used to pick up the right set of 44 # libraries, typically the host libs have a _host suffix in their 45 # names. 46 # $(1): source list 47 # $(2): "HOST_" or empty 48 # $(3): extra CFLAGS or empty 49 # $(4): "_host" or empty 50 # $(5): "TARGET_OUT_DATA_NATIVE_TESTS" or empty (where to install) 51 define _define-test 52 $(foreach file,$(1), \ 53 $(eval include $(CLEAR_VARS)) \ 54 $(eval LOCAL_CPP_EXTENSION := .cc) \ 55 $(eval LOCAL_SRC_FILES := $(file)) \ 56 $(eval LOCAL_C_INCLUDES := $(libgtest_test$(4)_includes)) \ 57 $(eval LOCAL_MODULE := $(notdir $(file:%.cc=%))$(4)) \ 58 $(eval LOCAL_CFLAGS += $(3) -Wno-empty-body) \ 59 $(eval LOCAL_LDFLAGS += $(libgtest_test$(4)_ldflags)) \ 60 $(eval LOCAL_STATIC_LIBRARIES := $(libgtest_test$(4)_static_lib)) \ 61 $(eval LOCAL_SHARED_LIBRARIES := $(libgtest_test$(4)_shared_lib)) \ 62 $(if $(2),,$(eval LOCAL_MODULE_TAGS := tests)) \ 63 $(eval LOCAL_MODULE_PATH := $($(5))) \ 64 $(eval include $(BUILD_$(2)EXECUTABLE)) \ 65 ) 66 endef 67 68 define host-test 69 $(call _define-test,$(1),HOST_,-O0,_host,) 70 endef 71 72 define target-test 73 $(call _define-test,$(1),,,,TARGET_OUT_DATA_NATIVE_TESTS) 74 endef 75 76 sources := \ 77 gtest_all_test.cc \ 78 gtest-death-test_test.cc \ 79 gtest_environment_test.cc \ 80 gtest-listener_test.cc \ 81 gtest_main_unittest.cc \ 82 gtest_no_test_unittest.cc \ 83 gtest-param-test2_test.cc \ 84 gtest_premature_exit_test.cc \ 85 gtest_repeat_test.cc \ 86 gtest_sole_header_test.cc \ 87 gtest_stress_test.cc \ 88 gtest-unittest-api_test.cc \ 89 90 # We don't have exceptions. 91 # gtest-death-test_ex_test.cc \ 92 # gtest_throw_on_failure_ex_test.cc \ 93 # We don't have tr1::tuple. 94 # gtest-tuple_test.cc \ 95 # These don't build. 96 # gtest-param-test_test.cc \ 97 # gtest-printers_test.cc \ 98 99 $(call host-test, $(sources)) 100 $(call target-test, $(sources)) 101