Home | History | Annotate | Download | only in test
      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 
     34 libgtest_test_host_includes := $(libgtest_test_common_includes)
     35 libgtest_test_host_static_lib := libgtest_main_host libgtest_host
     36 libgtest_test_host_shared_lib :=
     37 
     38 # $(2) and $(4) must be set or cleared in sync. $(2) is used to
     39 # generate the right make target (host vs device). $(4) is used in the
     40 # module's name and to have different module names for the host vs
     41 # device builds. Finally $(4) is used to pick up the right set of
     42 # libraries, typically the host libs have a _host suffix in their
     43 # names.
     44 # $(1): source list
     45 # $(2): "HOST_" or empty
     46 # $(3): extra CFLAGS or empty
     47 # $(4): "_host" or empty
     48 # $(5): "TARGET_OUT_DATA_NATIVE_TESTS" or empty (where to install)
     49 define _define-test
     50 $(foreach file,$(1), \
     51   $(eval include $(CLEAR_VARS)) \
     52   $(eval LOCAL_CPP_EXTENSION := .cc) \
     53   $(eval LOCAL_SRC_FILES := $(file)) \
     54   $(eval LOCAL_C_INCLUDES := $(libgtest_test$(4)_includes)) \
     55   $(eval LOCAL_MODULE := $(notdir $(file:%.cc=%))$(4)) \
     56   $(eval LOCAL_CFLAGS += $(3)) \
     57   $(eval LOCAL_STATIC_LIBRARIES := $(libgtest_test$(4)_static_lib)) \
     58   $(eval LOCAL_SHARED_LIBRARIES := $(libgtest_test$(4)_shared_lib)) \
     59   $(if $(2),,$(eval LOCAL_MODULE_TAGS := tests)) \
     60   $(eval LOCAL_MODULE_PATH := $($(5))) \
     61   $(eval include $(BUILD_$(2)EXECUTABLE)) \
     62 )
     63 endef
     64 
     65 define host-test
     66 $(call _define-test,$(1),HOST_,-O0,_host,)
     67 endef
     68 
     69 define target-test
     70 $(call _define-test,$(1),,,,TARGET_OUT_DATA_NATIVE_TESTS)
     71 endef
     72 
     73 sources := \
     74   gtest-death-test_test.cc \
     75   gtest-filepath_test.cc \
     76   gtest-linked_ptr_test.cc \
     77   gtest-message_test.cc \
     78   gtest-options_test.cc \
     79   gtest-port_test.cc \
     80   gtest_environment_test.cc \
     81   gtest_no_test_unittest.cc \
     82   gtest_pred_impl_unittest.cc \
     83   gtest_repeat_test.cc \
     84   gtest-test-part_test.cc \
     85   gtest-typed-test_test.cc \
     86   gtest-typed-test2_test.cc \
     87   gtest_stress_test.cc \
     88   gtest_unittest.cc \
     89   gtest_prod_test.cc
     90 
     91 $(call host-test, $(sources))
     92 $(call target-test, $(sources))
     93