Home | History | Annotate | Download | only in googlemock
      1 # Copyright (C) 2016 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 LOCAL_PATH := $(call my-dir)
     18 
     19 # Defines a test module.
     20 #
     21 # The upstream gmock configuration builds each of these as separate executables.
     22 # It's a pain for how we run tests in the platform, but we can handle that with
     23 # a test running script.
     24 #
     25 # $(1): Test name. test/$(1).cc will automatically be added to sources.
     26 # $(2): Additional source files.
     27 # $(3): "libgmock_main" or empty.
     28 # $(4): Variant. Can be "_host", "_ndk", or empty.
     29 define gmock-unit-test
     30     $(eval include $(CLEAR_VARS)) \
     31     $(eval LOCAL_MODULE := $(1)$(4)) \
     32     $(eval LOCAL_CPP_EXTENSION := .cc) \
     33     $(eval LOCAL_SRC_FILES := test/$(strip $(1)).cc $(2)) \
     34     $(eval LOCAL_C_INCLUDES := $(LOCAL_PATH)/include) \
     35     $(eval LOCAL_C_INCLUDES += $(LOCAL_PATH)/../googletest) \
     36     $(eval LOCAL_CPP_FEATURES := rtti) \
     37     $(eval LOCAL_STATIC_LIBRARIES := $(if $(3),$(3)$(4)) libgmock$(4)) \
     38     $(eval LOCAL_STATIC_LIBRARIES += libgtest$(4)) \
     39     $(if $(findstring _ndk,$(4)),$(eval LOCAL_SDK_VERSION := 9)) \
     40     $(eval LOCAL_NDK_STL_VARIANT := stlport_static) \
     41     $(if $(findstring _host,$(4)),,\
     42         $(eval LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_NATIVE_TESTS))) \
     43     $(eval $(if $(findstring _host,$(4)), \
     44         include $(BUILD_HOST_EXECUTABLE), \
     45         include $(BUILD_EXECUTABLE)))
     46 endef
     47 
     48 # Create modules for each test in the suite.
     49 #
     50 # $(1): Variant. Can be "_host", "_ndk", or empty.
     51 define gmock-test-suite
     52     $(eval $(call gmock-unit-test,gmock-actions_test,,libgmock_main,$(1))) \
     53     $(eval $(call gmock-unit-test,gmock-cardinalities_test,,libgmock_main,$(1))) \
     54     $(eval $(call gmock-unit-test,gmock-generated-actions_test,,libgmock_main,$(1))) \
     55     $(eval $(call gmock-unit-test,gmock-generated-function-mockers_test,,libgmock_main,$(1))) \
     56     $(eval $(call gmock-unit-test,gmock-generated-internal-utils_test,,libgmock_main,$(1))) \
     57     $(eval $(call gmock-unit-test,gmock-generated-matchers_test,,libgmock_main,$(1))) \
     58     $(eval $(call gmock-unit-test,gmock-internal-utils_test,,libgmock_main,$(1))) \
     59     $(eval $(call gmock-unit-test,gmock-matchers_test,,libgmock_main,$(1))) \
     60     $(eval $(call gmock-unit-test,gmock-more-actions_test,,libgmock_main,$(1))) \
     61     $(eval $(call gmock-unit-test,gmock-nice-strict_test,,libgmock_main,$(1))) \
     62     $(eval $(call gmock-unit-test,gmock-port_test,,libgmock_main,$(1))) \
     63     $(eval $(call gmock-unit-test,gmock-spec-builders_test,,libgmock_main,$(1))) \
     64     $(eval $(call gmock-unit-test,gmock_link_test,test/gmock_link2_test.cc,libgmock_main,$(1))) \
     65     $(eval $(call gmock-unit-test,gmock_test,,libgmock_main,$(1)))
     66 endef
     67 
     68 # Test is disabled because Android doesn't build gmock with exceptions.
     69 # $(eval $(call gmock-unit-test,gmock_ex_test,,libgmock_main,$(1)))
     70 
     71 $(call gmock-test-suite,)
     72 $(call gmock-test-suite,_host)
     73