1#
2# Copyright (C) 2013-2014 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.
15#
16
17LOCAL_PATH := $(call my-dir)
18
19# -----------------------------------------------------------------------------
20# Benchmarks.
21# -----------------------------------------------------------------------------
22
23test_module_prefix := liblog-
24test_tags := tests
25
26benchmark_c_flags := \
27    -Ibionic/tests \
28    -Wall -Wextra \
29    -Werror \
30    -fno-builtin \
31
32benchmark_src_files := \
33    benchmark_main.cpp \
34    liblog_benchmark.cpp
35
36# Build benchmarks for the device. Run with:
37#   adb shell liblog-benchmarks
38include $(CLEAR_VARS)
39LOCAL_MODULE := $(test_module_prefix)benchmarks
40LOCAL_MODULE_TAGS := $(test_tags)
41LOCAL_CFLAGS += $(benchmark_c_flags)
42LOCAL_SHARED_LIBRARIES += liblog libm libbase
43LOCAL_SRC_FILES := $(benchmark_src_files)
44include $(BUILD_NATIVE_TEST)
45
46# -----------------------------------------------------------------------------
47# Unit tests.
48# -----------------------------------------------------------------------------
49
50test_c_flags := \
51    -fstack-protector-all \
52    -g \
53    -Wall -Wextra \
54    -Werror \
55    -fno-builtin \
56
57test_src_files := \
58    liblog_test_default.cpp \
59    liblog_test_local.cpp \
60    liblog_test_stderr.cpp \
61    liblog_test_stderr_local.cpp \
62    log_id_test.cpp \
63    log_radio_test.cpp \
64    log_read_test.cpp \
65    log_system_test.cpp \
66    log_time_test.cpp
67
68# to prevent breaking the build if bionic not relatively visible to us
69ifneq ($(wildcard $(LOCAL_PATH)/../../../../bionic/libc/bionic/libc_logging.cpp),)
70
71test_src_files += \
72    libc_test.cpp
73
74endif
75
76# Build tests for the device (with .so). Run with:
77#   adb shell /data/nativetest/liblog-unit-tests/liblog-unit-tests
78include $(CLEAR_VARS)
79LOCAL_MODULE := $(test_module_prefix)unit-tests
80LOCAL_MODULE_TAGS := $(test_tags)
81LOCAL_CFLAGS += $(test_c_flags)
82LOCAL_SHARED_LIBRARIES := liblog libcutils libbase
83LOCAL_SRC_FILES := $(test_src_files)
84include $(BUILD_NATIVE_TEST)
85
86cts_executable := CtsLiblogTestCases
87
88include $(CLEAR_VARS)
89LOCAL_MODULE := $(cts_executable)
90LOCAL_MODULE_TAGS := tests
91LOCAL_CFLAGS += $(test_c_flags)
92LOCAL_SRC_FILES := $(test_src_files)
93LOCAL_MODULE_PATH := $(TARGET_OUT_DATA)/nativetest
94LOCAL_MULTILIB := both
95LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
96LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
97LOCAL_SHARED_LIBRARIES := liblog libcutils libbase
98LOCAL_STATIC_LIBRARIES := libgtest libgtest_main
99LOCAL_COMPATIBILITY_SUITE := cts
100LOCAL_CTS_TEST_PACKAGE := android.core.liblog
101include $(BUILD_CTS_EXECUTABLE)
102
103ifeq ($(HOST_OS)-$(HOST_ARCH),$(filter $(HOST_OS)-$(HOST_ARCH),linux-x86 linux-x86_64))
104
105include $(CLEAR_VARS)
106LOCAL_MODULE := $(cts_executable)_list
107LOCAL_MODULE_TAGS := optional
108LOCAL_CFLAGS := $(test_c_flags) -DHOST
109LOCAL_C_INCLUDES := external/gtest/include
110LOCAL_SRC_FILES := $(test_src_files)
111LOCAL_MULTILIB := both
112LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)
113LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
114LOCAL_CXX_STL := libc++
115LOCAL_SHARED_LIBRARIES := liblog libcutils libbase
116LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
117LOCAL_LDLIBS_linux := -lrt
118include $(BUILD_HOST_NATIVE_TEST)
119
120endif  # ifeq ($(HOST_OS)-$(HOST_ARCH),$(filter $(HOST_OS)-$(HOST_ARCH),linux-x86 linux-x86_64))
121