Elliott Hughes | cc213f8 | 2012-08-14 15:32:42 -0700 | [diff] [blame] | 1 | # |
| 2 | # Copyright (C) 2012 The Android Open Source Project |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
Benoit Goby | 5ac9eee | 2012-08-31 19:52:15 -0700 | [diff] [blame] | 15 | # |
| 16 | |
| 17 | ifneq ($(BUILD_TINY_ANDROID), true) |
Elliott Hughes | cc213f8 | 2012-08-14 15:32:42 -0700 | [diff] [blame] | 18 | |
| 19 | LOCAL_PATH := $(call my-dir) |
| 20 | |
Elliott Hughes | 7be369d | 2012-11-08 15:37:43 -0800 | [diff] [blame] | 21 | # ----------------------------------------------------------------------------- |
| 22 | # Benchmarks. |
| 23 | # ----------------------------------------------------------------------------- |
| 24 | |
| 25 | benchmark_c_flags = \ |
| 26 | -O2 \ |
| 27 | -Wall -Wextra \ |
| 28 | -Werror \ |
Elliott Hughes | 9edb3e0 | 2013-02-06 15:47:09 -0800 | [diff] [blame] | 29 | -fno-builtin \ |
Elliott Hughes | 7be369d | 2012-11-08 15:37:43 -0800 | [diff] [blame] | 30 | |
| 31 | benchmark_src_files = \ |
| 32 | benchmark_main.cpp \ |
Elliott Hughes | 9edb3e0 | 2013-02-06 15:47:09 -0800 | [diff] [blame] | 33 | math_benchmark.cpp \ |
Colin Cross | b27e200 | 2013-01-28 17:19:43 -0800 | [diff] [blame] | 34 | property_benchmark.cpp \ |
Elliott Hughes | 7be369d | 2012-11-08 15:37:43 -0800 | [diff] [blame] | 35 | string_benchmark.cpp \ |
Elliott Hughes | 4a05bef | 2013-03-11 17:17:02 -0700 | [diff] [blame] | 36 | time_benchmark.cpp \ |
Elliott Hughes | 7be369d | 2012-11-08 15:37:43 -0800 | [diff] [blame] | 37 | |
| 38 | # Build benchmarks for the device (with bionic's .so). Run with: |
| 39 | # adb shell bionic-benchmarks |
| 40 | include $(CLEAR_VARS) |
| 41 | LOCAL_MODULE := bionic-benchmarks |
| 42 | LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk |
| 43 | LOCAL_CFLAGS += $(benchmark_c_flags) |
| 44 | LOCAL_C_INCLUDES += external/stlport/stlport bionic/ bionic/libstdc++/include |
| 45 | LOCAL_SHARED_LIBRARIES += libstlport |
| 46 | LOCAL_SRC_FILES := $(benchmark_src_files) |
| 47 | include $(BUILD_EXECUTABLE) |
| 48 | |
| 49 | # ----------------------------------------------------------------------------- |
| 50 | # Unit tests. |
| 51 | # ----------------------------------------------------------------------------- |
| 52 | |
Elliott Hughes | ad88a08 | 2012-10-24 18:37:21 -0700 | [diff] [blame] | 53 | test_c_flags = \ |
Nick Kralevich | dcab1b2 | 2013-01-10 17:12:29 -0800 | [diff] [blame] | 54 | -fstack-protector-all \ |
Elliott Hughes | ad88a08 | 2012-10-24 18:37:21 -0700 | [diff] [blame] | 55 | -g \ |
| 56 | -Wall -Wextra \ |
| 57 | -Werror \ |
Elliott Hughes | a0ee078 | 2013-01-30 19:06:37 -0800 | [diff] [blame] | 58 | -fno-builtin \ |
Elliott Hughes | ad88a08 | 2012-10-24 18:37:21 -0700 | [diff] [blame] | 59 | |
Elliott Hughes | cc213f8 | 2012-08-14 15:32:42 -0700 | [diff] [blame] | 60 | test_src_files = \ |
Elliott Hughes | 063cfb2 | 2012-10-25 20:55:23 -0700 | [diff] [blame] | 61 | dirent_test.cpp \ |
Kito Cheng | 8baa929 | 2013-04-03 11:29:40 +0800 | [diff] [blame] | 62 | eventfd_test.cpp \ |
Elliott Hughes | 90e10d4 | 2012-11-02 17:05:20 -0700 | [diff] [blame] | 63 | fenv_test.cpp \ |
Nick Kralevich | 2c5153b | 2013-01-11 14:43:05 -0800 | [diff] [blame] | 64 | getauxval_test.cpp \ |
Elliott Hughes | 04a83a4 | 2012-08-16 15:59:12 -0700 | [diff] [blame] | 65 | getcwd_test.cpp \ |
Elliott Hughes | 74f0833 | 2013-07-02 15:23:38 -0700 | [diff] [blame] | 66 | inttypes_test.cpp \ |
Elliott Hughes | 8f2a5a0 | 2013-03-15 15:30:25 -0700 | [diff] [blame] | 67 | libc_logging_test.cpp \ |
Elliott Hughes | 58b5754 | 2012-10-29 14:27:10 -0700 | [diff] [blame] | 68 | libgen_test.cpp \ |
Christopher Ferris | 885f3b9 | 2013-05-21 17:48:01 -0700 | [diff] [blame] | 69 | malloc_test.cpp \ |
Elliott Hughes | a0ee078 | 2013-01-30 19:06:37 -0800 | [diff] [blame] | 70 | math_test.cpp \ |
Elliott Hughes | d3b9d11 | 2013-02-13 08:22:07 -0800 | [diff] [blame] | 71 | netdb_test.cpp \ |
Elliott Hughes | bfeab1b | 2012-09-05 17:47:37 -0700 | [diff] [blame] | 72 | pthread_test.cpp \ |
Elliott Hughes | cc213f8 | 2012-08-14 15:32:42 -0700 | [diff] [blame] | 73 | regex_test.cpp \ |
Elliott Hughes | da73f65 | 2012-11-30 16:40:55 -0800 | [diff] [blame] | 74 | signal_test.cpp \ |
Elliott Hughes | ad88a08 | 2012-10-24 18:37:21 -0700 | [diff] [blame] | 75 | stack_protector_test.cpp \ |
Sergey Melnikov | c45087b | 2013-01-25 16:40:13 +0400 | [diff] [blame] | 76 | stack_unwinding_test.cpp \ |
Elliott Hughes | 06040fd | 2013-07-09 13:25:03 -0700 | [diff] [blame] | 77 | statvfs_test.cpp \ |
Elliott Hughes | 91875dc | 2012-09-24 17:55:15 -0700 | [diff] [blame] | 78 | stdio_test.cpp \ |
Elliott Hughes | 774c7f5 | 2012-10-01 13:11:03 -0700 | [diff] [blame] | 79 | stdlib_test.cpp \ |
Irina Tirdea | b5f053b | 2012-09-08 09:17:54 +0300 | [diff] [blame] | 80 | string_test.cpp \ |
Elliott Hughes | 73964c5 | 2013-02-13 14:35:14 -0800 | [diff] [blame] | 81 | strings_test.cpp \ |
Kenny Root | 2a54e5e | 2012-09-13 10:52:52 -0700 | [diff] [blame] | 82 | stubs_test.cpp \ |
Elliott Hughes | d0be7c8 | 2013-08-08 17:13:33 -0700 | [diff] [blame] | 83 | sys_stat_test.cpp \ |
Colin Cross | b27e200 | 2013-01-28 17:19:43 -0800 | [diff] [blame] | 84 | system_properties_test.cpp \ |
Elliott Hughes | e0175ca | 2013-03-14 14:38:08 -0700 | [diff] [blame] | 85 | time_test.cpp \ |
Elliott Hughes | a55f630 | 2013-01-02 14:23:43 -0800 | [diff] [blame] | 86 | unistd_test.cpp \ |
Elliott Hughes | cc213f8 | 2012-08-14 15:32:42 -0700 | [diff] [blame] | 87 | |
jeffhao | acf5aa7 | 2012-09-12 17:25:30 -0700 | [diff] [blame] | 88 | test_dynamic_ldflags = -Wl,--export-dynamic -Wl,-u,DlSymTestFunction |
| 89 | test_dynamic_src_files = \ |
Elliott Hughes | e66190d | 2012-12-18 15:57:55 -0800 | [diff] [blame] | 90 | dlfcn_test.cpp \ |
jeffhao | acf5aa7 | 2012-09-12 17:25:30 -0700 | [diff] [blame] | 91 | |
Nick Kralevich | 5bcf398 | 2013-06-28 10:34:09 -0700 | [diff] [blame] | 92 | test_fortify_static_libraries = \ |
| 93 | fortify1-tests-gcc fortify2-tests-gcc fortify1-tests-clang fortify2-tests-clang |
| 94 | |
Sergey Melnikov | c45087b | 2013-01-25 16:40:13 +0400 | [diff] [blame] | 95 | include $(CLEAR_VARS) |
| 96 | LOCAL_MODULE := bionic-unit-tests-unwind-test-impl |
| 97 | LOCAL_CFLAGS += $(test_c_flags) -fexceptions -fnon-call-exceptions |
| 98 | LOCAL_SRC_FILES := stack_unwinding_test_impl.c |
| 99 | include $(BUILD_STATIC_LIBRARY) |
| 100 | |
| 101 | include $(CLEAR_VARS) |
| 102 | LOCAL_MODULE := bionic-unit-tests-unwind-test-impl-host |
| 103 | LOCAL_CFLAGS += $(test_c_flags) -fexceptions -fnon-call-exceptions |
| 104 | LOCAL_SRC_FILES := stack_unwinding_test_impl.c |
| 105 | include $(BUILD_HOST_STATIC_LIBRARY) |
| 106 | |
Elliott Hughes | 7be369d | 2012-11-08 15:37:43 -0800 | [diff] [blame] | 107 | # Build tests for the device (with bionic's .so). Run with: |
Elliott Hughes | cc213f8 | 2012-08-14 15:32:42 -0700 | [diff] [blame] | 108 | # adb shell /data/nativetest/bionic-unit-tests/bionic-unit-tests |
| 109 | include $(CLEAR_VARS) |
Joe Onorato | 7b841f3 | 2012-08-15 20:27:04 -0700 | [diff] [blame] | 110 | LOCAL_MODULE := bionic-unit-tests |
Elliott Hughes | 2e8f434 | 2012-09-05 14:27:17 -0700 | [diff] [blame] | 111 | LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk |
Elliott Hughes | ad88a08 | 2012-10-24 18:37:21 -0700 | [diff] [blame] | 112 | LOCAL_CFLAGS += $(test_c_flags) |
jeffhao | acf5aa7 | 2012-09-12 17:25:30 -0700 | [diff] [blame] | 113 | LOCAL_LDFLAGS += $(test_dynamic_ldflags) |
| 114 | LOCAL_SHARED_LIBRARIES += libdl |
| 115 | LOCAL_SRC_FILES := $(test_src_files) $(test_dynamic_src_files) |
Nick Kralevich | 5bcf398 | 2013-06-28 10:34:09 -0700 | [diff] [blame] | 116 | LOCAL_WHOLE_STATIC_LIBRARIES := $(test_fortify_static_libraries) |
Sergey Melnikov | c45087b | 2013-01-25 16:40:13 +0400 | [diff] [blame] | 117 | LOCAL_STATIC_LIBRARIES += bionic-unit-tests-unwind-test-impl |
Elliott Hughes | cc213f8 | 2012-08-14 15:32:42 -0700 | [diff] [blame] | 118 | include $(BUILD_NATIVE_TEST) |
| 119 | |
Elliott Hughes | 7be369d | 2012-11-08 15:37:43 -0800 | [diff] [blame] | 120 | # Build tests for the device (with bionic's .a). Run with: |
Elliott Hughes | bfeab1b | 2012-09-05 17:47:37 -0700 | [diff] [blame] | 121 | # adb shell /data/nativetest/bionic-unit-tests-static/bionic-unit-tests-static |
| 122 | include $(CLEAR_VARS) |
Elliott Hughes | bfeab1b | 2012-09-05 17:47:37 -0700 | [diff] [blame] | 123 | LOCAL_MODULE := bionic-unit-tests-static |
| 124 | LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk |
jeffhao | acf5aa7 | 2012-09-12 17:25:30 -0700 | [diff] [blame] | 125 | LOCAL_FORCE_STATIC_EXECUTABLE := true |
Christopher Ferris | 153d927 | 2013-08-27 14:32:15 -0700 | [diff] [blame^] | 126 | LOCAL_WHOLE_STATIC_LIBRARIES += libBionicTests |
Sergey Melnikov | c45087b | 2013-01-25 16:40:13 +0400 | [diff] [blame] | 127 | LOCAL_STATIC_LIBRARIES += libstlport_static libstdc++ libm libc bionic-unit-tests-unwind-test-impl |
Elliott Hughes | bfeab1b | 2012-09-05 17:47:37 -0700 | [diff] [blame] | 128 | include $(BUILD_NATIVE_TEST) |
| 129 | |
Elliott Hughes | 7be369d | 2012-11-08 15:37:43 -0800 | [diff] [blame] | 130 | # ----------------------------------------------------------------------------- |
Christopher Ferris | 153d927 | 2013-08-27 14:32:15 -0700 | [diff] [blame^] | 131 | # We build the static unit tests as a library so they can be used both for |
| 132 | # bionic-unit-tests-static and also as part of CTS. |
| 133 | # ----------------------------------------------------------------------------- |
| 134 | |
| 135 | include $(CLEAR_VARS) |
| 136 | LOCAL_MODULE := libBionicTests |
| 137 | LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk |
| 138 | LOCAL_CFLAGS += $(test_c_flags) |
| 139 | LOCAL_SRC_FILES := $(test_src_files) |
| 140 | LOCAL_CFLAGS += -DGTEST_OS_LINUX_ANDROID -DGTEST_HAS_STD_STRING |
| 141 | LOCAL_C_INCLUDES += bionic bionic/libstdc++/include external/gtest/include external/stlport/stlport |
| 142 | LOCAL_WHOLE_STATIC_LIBRARIES := $(test_fortify_static_libraries) |
| 143 | include $(BUILD_STATIC_LIBRARY) |
| 144 | |
| 145 | # ----------------------------------------------------------------------------- |
Elliott Hughes | 7be369d | 2012-11-08 15:37:43 -0800 | [diff] [blame] | 146 | # Test library for the unit tests. |
| 147 | # ----------------------------------------------------------------------------- |
Elliott Hughes | 124fae9 | 2012-10-31 14:20:03 -0700 | [diff] [blame] | 148 | |
| 149 | # Build no-elf-hash-table-library.so to test dlopen(3) on a library that |
Elliott Hughes | a43e906 | 2013-01-07 14:18:22 -0800 | [diff] [blame] | 150 | # only has a GNU-style hash table. MIPS doesn't support GNU hash style. |
| 151 | ifneq ($(TARGET_ARCH),mips) |
Elliott Hughes | 124fae9 | 2012-10-31 14:20:03 -0700 | [diff] [blame] | 152 | include $(CLEAR_VARS) |
| 153 | LOCAL_MODULE := no-elf-hash-table-library |
| 154 | LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk |
| 155 | LOCAL_SRC_FILES := empty.cpp |
| 156 | LOCAL_LDFLAGS := -Wl,--hash-style=gnu |
| 157 | include $(BUILD_SHARED_LIBRARY) |
Elliott Hughes | a43e906 | 2013-01-07 14:18:22 -0800 | [diff] [blame] | 158 | endif |
Elliott Hughes | 124fae9 | 2012-10-31 14:20:03 -0700 | [diff] [blame] | 159 | |
Elliott Hughes | 7be369d | 2012-11-08 15:37:43 -0800 | [diff] [blame] | 160 | # ----------------------------------------------------------------------------- |
| 161 | # Unit tests built against glibc. |
| 162 | # ----------------------------------------------------------------------------- |
Elliott Hughes | 124fae9 | 2012-10-31 14:20:03 -0700 | [diff] [blame] | 163 | |
Elliott Hughes | 7be369d | 2012-11-08 15:37:43 -0800 | [diff] [blame] | 164 | # Build tests for the host (with glibc). |
Elliott Hughes | cc213f8 | 2012-08-14 15:32:42 -0700 | [diff] [blame] | 165 | # Note that this will build against glibc, so it's not useful for testing |
| 166 | # bionic's implementation, but it does let you use glibc as a reference |
| 167 | # implementation for testing the tests themselves. |
Elliott Hughes | 38bfa21 | 2012-09-13 11:01:46 -0700 | [diff] [blame] | 168 | ifeq ($(HOST_OS)-$(HOST_ARCH),linux-x86) |
Elliott Hughes | cc213f8 | 2012-08-14 15:32:42 -0700 | [diff] [blame] | 169 | include $(CLEAR_VARS) |
Joe Onorato | 7b841f3 | 2012-08-15 20:27:04 -0700 | [diff] [blame] | 170 | LOCAL_MODULE := bionic-unit-tests-glibc |
Elliott Hughes | 2e8f434 | 2012-09-05 14:27:17 -0700 | [diff] [blame] | 171 | LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk |
Elliott Hughes | ad88a08 | 2012-10-24 18:37:21 -0700 | [diff] [blame] | 172 | LOCAL_CFLAGS += $(test_c_flags) |
Jeff Hao | 9b06cc3 | 2013-08-15 14:51:16 -0700 | [diff] [blame] | 173 | LOCAL_LDFLAGS += -lpthread -ldl -lrt |
jeffhao | acf5aa7 | 2012-09-12 17:25:30 -0700 | [diff] [blame] | 174 | LOCAL_LDFLAGS += $(test_dynamic_ldflags) |
| 175 | LOCAL_SRC_FILES := $(test_src_files) $(test_dynamic_src_files) |
Sergey Melnikov | c45087b | 2013-01-25 16:40:13 +0400 | [diff] [blame] | 176 | LOCAL_STATIC_LIBRARIES += bionic-unit-tests-unwind-test-impl-host |
Elliott Hughes | cc213f8 | 2012-08-14 15:32:42 -0700 | [diff] [blame] | 177 | include $(BUILD_HOST_NATIVE_TEST) |
Elliott Hughes | 38bfa21 | 2012-09-13 11:01:46 -0700 | [diff] [blame] | 178 | endif |
Benoit Goby | 5ac9eee | 2012-08-31 19:52:15 -0700 | [diff] [blame] | 179 | |
Nick Kralevich | 16d1af1 | 2013-06-17 14:49:19 -0700 | [diff] [blame] | 180 | # ----------------------------------------------------------------------------- |
Nick Kralevich | 5bcf398 | 2013-06-28 10:34:09 -0700 | [diff] [blame] | 181 | # FORTIFY_SOURCE tests |
Nick Kralevich | 16d1af1 | 2013-06-17 14:49:19 -0700 | [diff] [blame] | 182 | # ----------------------------------------------------------------------------- |
Nick Kralevich | 5bcf398 | 2013-06-28 10:34:09 -0700 | [diff] [blame] | 183 | |
| 184 | fortify_c_includes = \ |
| 185 | bionic \ |
| 186 | bionic/libstdc++/include \ |
| 187 | external/stlport/stlport \ |
| 188 | external/gtest/include |
| 189 | fortify_test_files = fortify_test.cpp |
Nick Kralevich | 16d1af1 | 2013-06-17 14:49:19 -0700 | [diff] [blame] | 190 | |
| 191 | # -Wno-error=unused-parameter needed as |
| 192 | # external/stlport/stlport/stl/_threads.c (included from |
| 193 | # external/gtest/include/gtest/gtest.h) does not compile cleanly under |
| 194 | # clang. TODO: fix this. |
Nick Kralevich | 5bcf398 | 2013-06-28 10:34:09 -0700 | [diff] [blame] | 195 | fortify_c_flags = $(test_c_flags) -Wno-error=unused-parameter |
Nick Kralevich | 16d1af1 | 2013-06-17 14:49:19 -0700 | [diff] [blame] | 196 | |
Nick Kralevich | 5bcf398 | 2013-06-28 10:34:09 -0700 | [diff] [blame] | 197 | include $(CLEAR_VARS) |
| 198 | LOCAL_SRC_FILES := $(fortify_test_files) |
| 199 | LOCAL_MODULE := fortify1-tests-gcc |
| 200 | LOCAL_CFLAGS += $(fortify_c_flags) -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DTEST_NAME=Fortify1_Gcc |
Nick Kralevich | 16d1af1 | 2013-06-17 14:49:19 -0700 | [diff] [blame] | 201 | LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk |
Nick Kralevich | 5bcf398 | 2013-06-28 10:34:09 -0700 | [diff] [blame] | 202 | LOCAL_C_INCLUDES += $(fortify_c_includes) |
| 203 | include $(BUILD_STATIC_LIBRARY) |
Nick Kralevich | 16d1af1 | 2013-06-17 14:49:19 -0700 | [diff] [blame] | 204 | |
Nick Kralevich | 5bcf398 | 2013-06-28 10:34:09 -0700 | [diff] [blame] | 205 | include $(CLEAR_VARS) |
| 206 | LOCAL_SRC_FILES := $(fortify_test_files) |
| 207 | LOCAL_MODULE := fortify2-tests-gcc |
| 208 | LOCAL_CFLAGS += $(fortify_c_flags) -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -DTEST_NAME=Fortify2_Gcc |
| 209 | LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk |
| 210 | LOCAL_C_INCLUDES += $(fortify_c_includes) |
| 211 | include $(BUILD_STATIC_LIBRARY) |
| 212 | |
| 213 | include $(CLEAR_VARS) |
| 214 | LOCAL_SRC_FILES := $(fortify_test_files) |
| 215 | LOCAL_MODULE := fortify1-tests-clang |
| 216 | LOCAL_CLANG := true |
| 217 | LOCAL_CFLAGS += $(fortify_c_flags) -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DTEST_NAME=Fortify1_Clang |
| 218 | LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk |
| 219 | LOCAL_C_INCLUDES += $(fortify_c_includes) |
| 220 | include $(BUILD_STATIC_LIBRARY) |
| 221 | |
| 222 | include $(CLEAR_VARS) |
| 223 | LOCAL_SRC_FILES := $(fortify_test_files) |
| 224 | LOCAL_MODULE := fortify2-tests-clang |
| 225 | LOCAL_CLANG := true |
| 226 | LOCAL_CFLAGS += $(fortify_c_flags) -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -DTEST_NAME=Fortify2_Clang |
| 227 | LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk |
| 228 | LOCAL_C_INCLUDES += $(fortify_c_includes) |
Nick Kralevich | 16d1af1 | 2013-06-17 14:49:19 -0700 | [diff] [blame] | 229 | include $(BUILD_STATIC_LIBRARY) |
| 230 | |
Benoit Goby | 5ac9eee | 2012-08-31 19:52:15 -0700 | [diff] [blame] | 231 | endif # !BUILD_TINY_ANDROID |