Android.mk revision d6dd2fcf84a73288fbdc5c207ec28ee877a19c9b
1# Copyright (C) 2008 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# Build control file for Bionic's test programs
16# define the BIONIC_TESTS environment variable to build the test programs
17#
18ifdef BIONIC_TESTS
19
20LOCAL_PATH:= $(call my-dir)
21
22# used to define a simple test program and build it as a standalone
23# device executable.
24#
25# you can use EXTRA_CFLAGS to indicate additional CFLAGS to use
26# in the build. the variable will be cleaned on exit
27#
28define device-test
29  $(foreach file,$(1), \
30    $(eval include $(CLEAR_VARS)) \
31    $(eval LOCAL_SRC_FILES := $(file)) \
32    $(eval LOCAL_MODULE := $(notdir $(file:%.c=%))) \
33    $(eval $(info LOCAL_MODULE=$(LOCAL_MODULE))) \
34    $(eval LOCAL_CFLAGS += $(EXTRA_CFLAGS)) \
35    $(eval LOCAL_MODULE_TAGS := tests) \
36    $(eval include $(BUILD_EXECUTABLE)) \
37  ) \
38  $(eval EXTRA_CFLAGS :=)
39endef
40
41# same as 'device-test' but builds a host executable instead
42# you can use EXTRA_LDLIBS to indicate additional linker flags
43#
44define host-test
45  $(foreach file,$(1), \
46    $(eval include $(CLEAR_VARS)) \
47    $(eval LOCAL_SRC_FILES := $(file)) \
48    $(eval LOCAL_MODULE := $(notdir $(file:%.c=%))) \
49    $(eval $(info LOCAL_MODULE=$(LOCAL_MODULE) file=$(file))) \
50    $(eval LOCAL_CFLAGS += $(EXTRA_CFLAGS)) \
51    $(eval LOCAL_LDLIBS += $(EXTRA_LDLIBS)) \
52    $(eval LOCAL_MODULE_TAGS := tests) \
53    $(eval include $(BUILD_HOST_EXECUTABLE)) \
54  ) \
55  $(eval EXTRA_CFLAGS :=) \
56  $(eval EXTRA_LDLIBS :=)
57endef
58
59# First, the tests in 'common'
60
61sources := \
62    common/test_gethostbyname.c \
63    common/test_gethostname.c \
64    common/test_pthread_cleanup_push.c \
65    common/test_pthread_getcpuclockid.c \
66    common/test_pthread_join.c \
67    common/test_pthread_once.c \
68    common/test_semaphore.c \
69    common/test_seteuid.c \
70    common/test_static_cpp_mutex.cpp \
71    common/test_tm_zone.c \
72    common/test_udp.c \
73
74EXTRA_LDLIBS := -lpthread -lrt
75$(call host-test, $(sources))
76$(call device-test, $(sources))
77
78sources := \
79    common/test_libgen.c \
80
81EXTRA_CFLAGS := -DHOST
82$(call host-test, $(sources))
83$(call device-test, $(sources))
84
85# Second, the Bionic-specific tests
86
87sources :=  \
88    bionic/test_mutex.c \
89    bionic/test_cond.c \
90    bionic/test_getgrouplist.c \
91    bionic/test_netinet_icmp.c \
92    bionic/test_pthread_cond.c \
93    bionic/test_pthread_create.c \
94
95$(call device-test, $(sources))
96
97# Third, the other tests
98
99sources := \
100    other/bench_locks.c \
101    other/test_aligned.c \
102    other/test_arc4random.c \
103    other/test_atomics.c \
104    other/test_sysconf.c \
105    other/test_system.c \
106    other/test_thread_max.c \
107    other/test_timer_create.c \
108    other/test_timer_create2.c \
109    other/test_vfprintf_leak.c \
110
111$(call device-test, $(sources))
112
113# The relocations test is a bit special, since we need
114# to build one shared object and one executable that depends
115# on it.
116
117include $(CLEAR_VARS)
118LOCAL_SRC_FILES := bionic/lib_relocs.c
119LOCAL_MODULE    := libtest_relocs
120LOCAL_PRELINK_MODULE := false
121include $(BUILD_SHARED_LIBRARY)
122
123include $(CLEAR_VARS)
124LOCAL_SRC_FILES := bionic/test_relocs.c
125LOCAL_MODULE    := test_relocs
126LOCAL_SHARED_LIBRARIES := libtest_relocs
127include $(BUILD_EXECUTABLE)
128
129# TODO: Add a variety of GLibc test programs too...
130
131# Hello World to test libstdc++ support
132
133sources := \
134    common/hello_world.cpp \
135
136EXTRA_CFLAGS := -mandroid
137#$(call device-test, $(sources))
138
139endif  # BIONIC_TESTS
140