OSDN Git Service

bionic test libc: clean up test for pthread_once
[android-x86/system-extras.git] / tests / bionic / libc / Android.mk
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 #
18 ifdef BIONIC_TESTS
19
20 LOCAL_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 #
28 define 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 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)) \
38   ) \
39   $(eval EXTRA_CFLAGS :=) \
40   $(eval EXTRA_LDLIBS :=)
41 endef
42
43 # same as 'device-test' but builds a host executable instead
44 # you can use EXTRA_LDLIBS to indicate additional linker flags
45 #
46 define host-test
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)) \
56   ) \
57   $(eval EXTRA_CFLAGS :=) \
58   $(eval EXTRA_LDLIBS :=)
59 endef
60
61 # First, the tests in 'common'
62
63 sources := \
64     common/test_pthread_mutex.c \
65     common/test_pthread_rwlock.c \
66     common/test_seteuid.c \
67     common/test_udp.c \
68
69 # _XOPEN_SOURCE=600 is needed to get pthread_mutexattr_settype() on GLibc
70 #
71 EXTRA_LDLIBS := -lpthread -lrt
72 EXTRA_CFLAGS := -D_XOPEN_SOURCE=600 -DHOST
73 $(call host-test, $(sources))
74 $(call device-test, $(sources))
75
76 # Second, the Bionic-specific tests
77
78 sources :=  \
79     bionic/test_cond.c \
80     bionic/test_pthread_cond.c \
81     bionic/test_setjmp.c \
82
83 $(call device-test, $(sources))
84
85 # This test tries to see if the static constructors in a
86 # shared library are only called once. We thus need to
87 # build a shared library, then call it from another
88 # program.
89 #
90 include $(CLEAR_VARS)
91 LOCAL_SRC_FILES := bionic/lib_static_init.cpp
92 LOCAL_MODULE    := libtest_static_init
93
94 LOCAL_MODULE_TAGS := tests
95 include $(BUILD_SHARED_LIBRARY)
96
97 include $(CLEAR_VARS)
98 LOCAL_SRC_FILES := bionic/test_static_init.cpp
99 LOCAL_MODULE    := test_static_init
100 LOCAL_SHARED_LIBRARIES := libtest_static_init
101 LOCAL_MODULE_TAGS := tests
102 include $(BUILD_EXECUTABLE)
103
104 # TODO: Add a variety of GLibc test programs too...
105
106 # Hello World to test libstdc++ support
107
108 sources := \
109     common/hello_world.cpp \
110
111 EXTRA_CFLAGS := -mandroid
112 #$(call device-test, $(sources))
113
114 endif  # BIONIC_TESTS