1 # Copyright (C) 2008 The Android Open Source Project
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
7 # http://www.apache.org/licenses/LICENSE-2.0
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.
15 # Build control file for Bionic's test programs
16 # define the BIONIC_TESTS environment variable to build the test programs
20 LOCAL_PATH:= $(call my-dir)
22 # used to define a simple test program and build it as a standalone
25 # you can use EXTRA_CFLAGS to indicate additional CFLAGS to use
26 # in the build. the variable will be cleaned on exit
29 $(foreach file,$(1), \
30 $(eval include $(CLEAR_VARS)) \
31 $(eval LOCAL_SRC_FILES := $(file)) \
32 $(eval LOCAL_MODULE := $(notdir $(file:%.c=%))) \
33 $(eval LOCAL_MODULE := $(LOCAL_MODULE:%.cpp=%)) \
34 $(eval LOCAL_CFLAGS += $(EXTRA_CFLAGS)) \
35 $(eval LOCAL_LDFLAGS += $(EXTRA_LDLIBS)) \
36 $(eval LOCAL_MODULE_TAGS := tests) \
37 $(eval include $(BUILD_EXECUTABLE)) \
39 $(eval EXTRA_CFLAGS :=) \
40 $(eval EXTRA_LDLIBS :=)
43 # same as 'device-test' but builds a host executable instead
44 # you can use EXTRA_LDLIBS to indicate additional linker flags
47 $(foreach file,$(1), \
48 $(eval include $(CLEAR_VARS)) \
49 $(eval LOCAL_SRC_FILES := $(file)) \
50 $(eval LOCAL_MODULE := $(notdir $(file:%.c=%))) \
51 $(eval LOCAL_MODULE := $(LOCAL_MODULE:%.cpp=%)) \
52 $(eval LOCAL_CFLAGS += $(EXTRA_CFLAGS)) \
53 $(eval LOCAL_LDLIBS += $(EXTRA_LDLIBS)) \
54 $(eval LOCAL_MODULE_TAGS := tests) \
55 $(eval include $(BUILD_HOST_EXECUTABLE)) \
57 $(eval EXTRA_CFLAGS :=) \
58 $(eval EXTRA_LDLIBS :=)
61 # First, the tests in 'common'
64 common/test_executable_destructor.c \
65 common/test_gethostbyname.c \
66 common/test_gethostname.c \
67 common/test_pthread_mutex.c \
68 common/test_pthread_rwlock.c \
69 common/test_pthread_once.c \
70 common/test_seteuid.c \
71 common/test_static_cpp_mutex.cpp \
74 # _XOPEN_SOURCE=600 is needed to get pthread_mutexattr_settype() on GLibc
76 EXTRA_LDLIBS := -lpthread -lrt
77 EXTRA_CFLAGS := -D_XOPEN_SOURCE=600 -DHOST
78 $(call host-test, $(sources))
79 $(call device-test, $(sources))
81 # The 'test_static_executable_destructor is the same than
82 # test_executable_destructor except that the generated program
83 # is statically linked instead.
85 LOCAL_MODULE := test_static_executable_destructor
86 LOCAL_SRC_FILES := common/test_executable_destructor.c
87 LOCAL_MODULE_TAGS := tests
88 LOCAL_STATIC_LIBRARIES := libc
89 LOCAL_FORCE_STATIC_EXECUTABLE := true
90 include $(BUILD_EXECUTABLE)
93 LOCAL_MODULE := test_static_executable_destructor
94 LOCAL_SRC_FILES := common/test_executable_destructor.c
95 LOCAL_MODULE_TAGS := tests
96 LOCAL_LDFLAGS := -static
97 include $(BUILD_HOST_EXECUTABLE)
99 # Second, the Bionic-specific tests
102 bionic/test_mutex.c \
104 bionic/test_getgrouplist.c \
105 bionic/test_netinet_icmp.c \
106 bionic/test_pthread_cond.c \
107 bionic/test_setjmp.c \
109 $(call device-test, $(sources))
111 # Third, the other tests
114 other/test_sysconf.c \
116 $(call device-test, $(sources))
118 # This test tries to see if the static constructors in a
119 # shared library are only called once. We thus need to
120 # build a shared library, then call it from another
123 include $(CLEAR_VARS)
124 LOCAL_SRC_FILES := bionic/lib_static_init.cpp
125 LOCAL_MODULE := libtest_static_init
127 LOCAL_MODULE_TAGS := tests
128 include $(BUILD_SHARED_LIBRARY)
130 include $(CLEAR_VARS)
131 LOCAL_SRC_FILES := bionic/test_static_init.cpp
132 LOCAL_MODULE := test_static_init
133 LOCAL_SHARED_LIBRARIES := libtest_static_init
134 LOCAL_MODULE_TAGS := tests
135 include $(BUILD_EXECUTABLE)
137 # TODO: Add a variety of GLibc test programs too...
139 # Hello World to test libstdc++ support
142 common/hello_world.cpp \
144 EXTRA_CFLAGS := -mandroid
145 #$(call device-test, $(sources))