1#
2# Copyright (C) 2016 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
19include $(LOCAL_PATH)/../Android.clean.mk
20
21test_cflags = \
22    -fstack-protector-all \
23    -g \
24    -Wall -Wextra -Wunused \
25    -Werror \
26    -fno-builtin \
27
28test_cflags += -D__STDC_LIMIT_MACROS  # For glibc.
29
30test_cppflags := \
31
32test_executable := VtsHalLightsTestCases
33list_executable := $(test_executable)_list
34
35include $(CLEAR_VARS)
36LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
37
38LOCAL_MODULE := $(test_executable)
39LOCAL_MODULE_TAGS := optional
40LOCAL_MODULE_PATH := $(TARGET_OUT_DATA)/nativetest
41LOCAL_MULTILIB := both
42LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
43LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
44
45LOCAL_SHARED_LIBRARIES += \
46    libdl \
47    libhardware \
48
49LOCAL_WHOLE_STATIC_LIBRARIES += \
50    libHalLightsTests \
51    libVtsGtestMain \
52
53LOCAL_STATIC_LIBRARIES += \
54    libbase \
55    libtinyxml2 \
56    liblog \
57    libgtest \
58
59# Tag this module as a vts test artifact
60LOCAL_COMPATIBILITY_SUITE := vts
61
62# May need more in CFLAGS.
63LOCAL_CFLAGS += -Wall -Wextra -Werror
64include $(BUILD_EXECUTABLE)
65
66# VTS testcase isn't designed to be run on host due to its dependencies to
67# libhardware or other android runtime.
68build_host := false
69common_additional_dependencies := $(LOCAL_PATH)/Android.mk $(LOCAL_PATH)/../Android.build.mk
70
71# -----------------------------------------------------------------------------
72# All standard tests.
73# -----------------------------------------------------------------------------
74
75libHalLightsStandardTests_src_files := \
76    hal_lights_basic_test.cpp
77
78libHalLightsStandardTests_cflags := \
79    $(test_cflags) \
80
81libHalLightsStandardTests_cppflags := \
82    $(test_cppflags) \
83
84libHalLightsStandardTests_c_includes := \
85    test/vts/testcases/include \
86    external/tinyxml2 \
87
88libHalLightsStandardTests_static_libraries := \
89    libbase \
90
91libHalLightsStandardTests_ldlibs_host := \
92    -lrt \
93
94module := libHalLightsStandardTests
95module_tag := optional
96build_type := target
97build_target := STATIC_TEST_LIBRARY
98include $(LOCAL_PATH)/../Android.build.mk
99build_type := host
100include $(LOCAL_PATH)/../Android.build.mk
101
102# Library of all tests (excluding the dynamic linker tests).
103# -----------------------------------------------------------------------------
104libHalLightsTests_whole_static_libraries := \
105    libHalLightsStandardTests \
106
107
108module := libHalLightsTests
109module_tag := optional
110build_type := target
111build_target := STATIC_TEST_LIBRARY
112include $(LOCAL_PATH)/../Android.build.mk
113build_type := host
114include $(LOCAL_PATH)/../Android.build.mk
115
116# -----------------------------------------------------------------------------
117# Tests for the device using HAL Lights's .so. Run with:
118#   adb shell /data/nativetest/hallights-unit-tests/hallights-unit-tests32
119#   adb shell /data/nativetest/hallights-unit-tests/hallights-unit-tests64
120#   adb shell /data/nativetest/hallights-unit-tests/hallights-unit-tests-gcc32
121#   adb shell /data/nativetest/hallights-unit-tests/hallights-unit-tests-gcc64
122# -----------------------------------------------------------------------------
123common_hallights-unit-tests_whole_static_libraries := \
124    libHalLightsTests \
125    libVtsGtestMain \
126
127common_hallights-unit-tests_static_libraries := \
128    libtinyxml2 \
129    liblog \
130    libbase \
131
132# TODO: Include __cxa_thread_atexit_test.cpp to glibc tests once it is upgraded (glibc 2.18+)
133common_hallights-unit-tests_src_files := \
134    hal_lights_basic_test.cpp \
135
136common_hallights-unit-tests_cflags := $(test_cflags)
137
138common_hallights-unit-tests_conlyflags := \
139    -fexceptions \
140    -fnon-call-exceptions \
141
142common_hallights-unit-tests_cppflags := \
143    $(test_cppflags)
144
145common_hallights-unit-tests_ldflags := \
146    -Wl,--export-dynamic
147
148common_hallights-unit-tests_c_includes := \
149
150common_hallights-unit-tests_shared_libraries_target := \
151    libdl \
152    libhardware \
153
154# The order of these libraries matters, do not shuffle them.
155common_hallights-unit-tests_static_libraries_target := \
156    libbase \
157    libziparchive \
158    libz \
159    libutils \
160
161module_tag := optional
162build_type := target
163build_target := NATIVE_TEST
164
165module := hallights-unit-tests
166hallights-unit-tests_clang_target := true
167hallights-unit-tests_whole_static_libraries := $(common_hallights-unit-tests_whole_static_libraries)
168hallights-unit-tests_static_libraries := $(common_hallights-unit-tests_static_libraries)
169hallights-unit-tests_src_files := $(common_hallights-unit-tests_src_files)
170hallights-unit-tests_cflags := $(common_hallights-unit-tests_cflags)
171hallights-unit-tests_conlyflags := $(common_hallights-unit-tests_conlyflags)
172hallights-unit-tests_cppflags := $(common_hallights-unit-tests_cppflags)
173hallights-unit-tests_ldflags := $(common_hallights-unit-tests_ldflags)
174hallights-unit-tests_c_includes := $(common_hallights-unit-tests_c_includes)
175hallights-unit-tests_shared_libraries_target := $(common_hallights-unit-tests_shared_libraries_target)
176hallights-unit-tests_static_libraries_target := $(common_hallights-unit-tests_static_libraries_target)
177include $(LOCAL_PATH)/../Android.build.mk
178
179module := hallights-unit-tests-gcc
180hallights-unit-tests-gcc_clang_target := false
181hallights-unit-tests-gcc_whole_static_libraries := $(common_hallights-unit-tests_whole_static_libraries)
182hallights-unit-tests-gcc_static_libraries := $(common_hallights-unit-tests_static_libraries)
183hallights-unit-tests-gcc_src_files := $(common_hallights-unit-tests_src_files)
184hallights-unit-tests-gcc_cflags := $(common_hallights-unit-tests_cflags)
185hallights-unit-tests-gcc_conlyflags := $(common_hallights-unit-tests_conlyflags)
186hallights-unit-tests-gcc_cppflags := $(common_hallights-unit-tests_cppflags)
187hallights-unit-tests-gcc_ldflags := $(common_hallights-unit-tests_ldflags)
188hallights-unit-tests-gcc_c_includes := $(common_hallights-unit-tests_c_includes)
189hallights-unit-tests-gcc_shared_libraries_target := $(common_hallights-unit-tests_shared_libraries_target)
190hallights-unit-tests-gcc_static_libraries_target := $(common_hallights-unit-tests_static_libraries_target)
191include $(LOCAL_PATH)/../Android.build.mk
192