1/*
2 * Copyright (C) 2023 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
17package {
18    default_applicable_licenses: ["Android-Apache-2.0"],
19}
20
21cc_library_headers {
22    name: "libberberis_ndk_program_tests_headers",
23    native_bridge_supported: true,
24    export_include_dirs: ["include"],
25}
26
27filegroup {
28    name: "berberis_ndk_program_tests_srcs",
29    srcs: [
30        "atomics_test.cc",
31        "clone_test.cc",
32        "condvar_test.cc",
33        "cpp_test.cc",
34        "ctype_test.cc",
35        "div_test.cc",
36        "epoll_test.cc",
37        "memory_order_test.cc",
38        "mutex_test.cc",
39        "ptrace_test.cc",
40        "resource_test.cc",
41        "sem_test.cc",
42        "setjmp_test.cc",
43        "sigaltstack_test.cc",
44        "signal_test.cc",
45        "string_test.cc",
46        "sysconf_test.cc",
47        "thread_test.cc",
48        "time_test.cc",
49        "user_test.cc",
50        "wchar_test.cc",
51        "zlib_test.cc",
52    ],
53}
54
55filegroup {
56    name: "berberis_ndk_program_tests_riscv64_srcs",
57    srcs: [
58        "riscv64/handle_not_executable_test.cc",
59        "riscv64/runtime_code_patching_test.cc",
60        "riscv64/sigill_test.cc",
61    ],
62}
63
64cc_defaults {
65    name: "berberis_ndk_program_tests_defaults",
66    native_bridge_supported: true,
67    cflags: [
68        "-fexceptions",
69        "-Wunused",
70        "-Wextra",
71        "-Wall",
72        "-Werror",
73        "-Wno-deprecated-declarations",
74    ],
75    srcs: [":berberis_ndk_program_tests_srcs"],
76    arch: {
77        riscv64: {
78            srcs: [":berberis_ndk_program_tests_riscv64_srcs"],
79            // Note: we don't even need to use anything from that library, just need to ensure it
80            // can be compiled successfully: all checks are done with static_asserts.
81            static_libs: ["libberberis_emulated_libvulkan_api_checker"],
82        },
83    },
84    header_libs: ["libberberis_ndk_program_tests_headers"],
85    static_libs: ["libgtest"],
86}
87
88cc_test {
89    name: "berberis_ndk_program_tests",
90    defaults: ["berberis_ndk_program_tests_defaults"],
91    shared_libs: ["libz"],
92    srcs: [
93        "proc_self_maps_test.cc",
94        // TODO(b/187471779): Signal stress test is unstable with high number of repetitions.
95        // TODO(b/188086209): Errno emulation is not thread-safe - some checks fail.
96        "signal_stress_test.cc",
97        "system_properties_test.cc",
98    ],
99}
100
101cc_test {
102    name: "berberis_ndk_program_tests_static",
103    defaults: ["berberis_ndk_program_tests_defaults"],
104    static_libs: ["libz"],
105    static_executable: true,
106}
107
108//
109// TODO(b/232598137): Merge riscv targets above into general targets with customizations below.
110//
111
112cc_defaults {
113    name: "ndk_program_tests_common_defaults",
114    native_bridge_supported: true,
115    cflags: [
116        "-fexceptions",
117        "-Wunused",
118        "-Wextra",
119        "-Wall",
120        "-Werror",
121        "-Wno-deprecated-declarations",
122    ],
123    srcs: [":berberis_ndk_program_tests_srcs"],
124    arch: {
125        arm: {
126            srcs: [
127                "arm/sigill_test.cc",
128            ],
129        },
130        arm64: {
131            srcs: [
132                "arm64/runtime_code_patching_test.cc",
133                "arm64/sigill_test.cc",
134            ],
135        },
136    },
137    header_libs: ["libberberis_ndk_program_tests_headers"],
138}
139
140cc_defaults {
141    name: "ndk_program_tests_dynamic_defaults",
142    defaults: ["ndk_program_tests_common_defaults"],
143    srcs: [
144        "signal_stress_test.cc",
145        "system_properties_test.cc",
146    ],
147    arch: {
148        arm: {
149            srcs: [
150                "arm/arm_test.cc",
151                "arm/cpu_features_test.cc",
152                "arm/handle_not_executable_test.cc",
153                "arm/neon_test.cc",
154                "arm/runtime_code_patching_test.cc",
155                "arm/syscall_test.cc",
156                "file_test.cc",
157                "futex_test.cc",
158            ],
159        },
160        arm64: {
161            srcs: [
162                "arm64/cpu_features_test.cc",
163                "arm64/handle_not_executable_test.cc",
164            ],
165        },
166    },
167    static_libs: ["cpufeatures"],
168    shared_libs: ["libz"],
169}
170
171cc_test {
172    name: "ndk_program_tests",
173    defaults: ["ndk_program_tests_dynamic_defaults"],
174    arch: {
175        arm: {
176            cflags: [
177                "-march=armv7-a",
178                "-mcpu=cortex-a9",
179                "-mfpu=neon",
180                "-mfloat-abi=softfp",
181            ],
182        },
183    },
184}
185
186cc_test {
187    name: "ndk_program_tests_armv8",
188    defaults: ["ndk_program_tests_dynamic_defaults"],
189    enabled: false,
190    arch: {
191        arm: {
192            enabled: true,
193            cflags: [
194                "-march=armv8-a",
195                "-mcpu=cortex-a57",
196                "-mfpu=neon",
197                "-mfloat-abi=softfp",
198            ],
199        },
200    },
201}
202
203cc_test {
204    name: "ndk_program_tests_static",
205    defaults: ["ndk_program_tests_common_defaults"],
206    srcs: [
207        // TODO(b/187471779): fix for static executable.
208        // "handle_not_executable_test.cc",
209        // TODO(b/297942688): We do not support accurate exec bit emulation in /proc/self/maps
210        // on systems without CONFIG_ANON_VMA_NAME.
211        // "proc_self_maps_test.cc",
212        // TODO(b/187471779): Signal stress test is unstable with high number of repeatitions.
213        // TODO(b/188086209): Errno emulation is not thread-safe - some checks fail.
214        // "signal_stress_test.cc",
215    ],
216    static_libs: ["libz"],
217    static_executable: true,
218}
219