1/* 2 * Copyright 2017 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 17cc_defaults { 18 name: "NeuralNetworksTest_default_libs", 19 defaults: ["neuralnetworks_defaults"], 20 host_supported: false, 21 // b/109953668, disable OpenMP 22 // openmp: true, 23 shared_libs: [ 24 "android.hidl.allocator@1.0", 25 "android.hidl.memory@1.0", 26 "libandroid", 27 "libbase", 28 "libcutils", 29 "libfmq", 30 "libhidlbase", 31 "libhidlmemory", 32 "liblog", 33 "libnativewindow", 34 "libneuralnetworks_packageinfo", 35 "libutils", 36 ], 37 static_libs: [ 38 "android.hardware.neuralnetworks@1.0", 39 "android.hardware.neuralnetworks@1.1", 40 "android.hardware.neuralnetworks@1.2", 41 "android.hardware.neuralnetworks@1.3", 42 "libc++fs", 43 "libneuralnetworks_generated_test_harness", 44 "libsync", 45 "libtextclassifier_hash_static", 46 ], 47 whole_static_libs: [ 48 "libcrypto_static", 49 ], 50 srcs: [ 51 "RequireDebug.cpp", // Abort compilation if NDEBUG is defined 52 ], 53 cflags: [ 54 "-UNDEBUG", 55 ], 56} 57 58cc_defaults { 59 name: "NeuralNetworksTest_defaults", 60 defaults: ["NeuralNetworksTest_default_libs"], 61 srcs: [ 62 // Subset of tests that rely only on public functionality. 63 // 64 // Changes to this list must be reflected in the "CtsNNAPITests_static" 65 // library to ensure CTS tests coverage. 66 "GeneratedTestUtils.cpp", 67 "TestAssertions.cpp", 68 "TestControlFlow.cpp", 69 "TestFree.cpp", 70 "TestGenerated.cpp", 71 "TestMemory.cpp", 72 "TestNeuralNetworksWrapper.cpp", 73 "TestOperandExtraParams.cpp", 74 "TestTrivialModel.cpp", 75 "TestUnknownDimensions.cpp", 76 "TestUnspecifiedDimensions.cpp", 77 78 "TestValidateModel.cpp", 79 "TestValidateOperations.cpp", 80 "TestValidation.cpp", 81 "TestWrapper.cpp", 82 83 ], 84 header_libs: [ 85 "libneuralnetworks_common_headers", 86 ], 87 static_libs: [ 88 "libgmock", 89 ], 90 whole_static_libs: [ 91 "neuralnetworks_generated_V1_0_example", 92 "neuralnetworks_generated_V1_1_example", 93 "neuralnetworks_generated_V1_2_example", 94 "neuralnetworks_generated_V1_3_cts_only_example", 95 "neuralnetworks_generated_V1_3_example", 96 ], 97} 98 99cc_test { 100 name: "NeuralNetworksTest_shared_partial", 101 defaults: ["NeuralNetworksTest_defaults"], 102 srcs: [ 103 "TestMain.cpp", 104 ], 105 cflags: [ 106 "-DNNTEST_ONLY_PUBLIC_API", 107 ], 108 shared_libs: [ 109 "libneuralnetworks", 110 ], 111} 112 113cc_defaults { 114 name: "NeuralNetworksTest_static_defaults", 115 defaults: ["NeuralNetworksTest_defaults"], 116 srcs: [ 117 // Tests that rely on non-public functionality (i.e., symbols 118 // not exported from libneuralnetworks.so). 119 // 120 // b/109953668, disable OpenMP 121 // "TestOpenmpSettings.cpp", 122 "TestCompilationCaching.cpp", 123 "TestCompliance.cpp", 124 "TestExecution.cpp", 125 "TestExtensions.cpp", 126 "TestFailingDriver.cpp", 127 "TestIntrospectionControl.cpp", 128 "TestMemoryDomain.cpp", 129 "TestMemoryInternal.cpp", 130 "TestPartitioning.cpp", 131 "TestPartitioningRandom.cpp", 132 "TestRemoveDefaultArguments.cpp", 133 "TestVersionedInterfaces.cpp", 134 "fibonacci_extension/FibonacciDriver.cpp", 135 "fibonacci_extension/FibonacciExtensionTest.cpp", 136 137 "TestMain.cpp", 138 139 "Bridge.cpp", 140 ], 141 static_libs: [ 142 "android.hardware.neuralnetworks@1.0-adapter-helper", 143 "android.hardware.neuralnetworks@1.1-adapter-helper", 144 "android.hardware.neuralnetworks@1.2-adapter-helper", 145 "android.hardware.neuralnetworks@1.3-adapter-helper", 146 "libSampleDriver", 147 "libgmock", 148 "libhidladapter", 149 "libneuralnetworks_common", 150 "libneuralnetworks_generated_test_harness", 151 "libneuralnetworks_static", 152 ], 153 shared_libs: [ 154 "libcutils", 155 ], 156 header_libs: [ 157 "libneuralnetworks_private_headers", 158 "libutils_headers", 159 "neuralnetworks_example_fibonacci_extension", 160 ], 161} 162 163cc_test { 164 name: "NeuralNetworksTest_static", 165 defaults: ["NeuralNetworksTest_static_defaults"], 166 test_suites: [ 167 "general-tests", 168 ], 169} 170 171cc_test { 172 name: "NeuralNetworksTest_static_fuzzing", 173 defaults: ["NeuralNetworksTest_default_libs"], 174 srcs: [ 175 "GeneratedTestUtils.cpp", 176 "TestNeuralNetworksWrapper.cpp", 177 "fuzzing/OperationManager.cpp", 178 "fuzzing/RandomGraphGenerator.cpp", 179 "fuzzing/RandomGraphGeneratorUtils.cpp", 180 "fuzzing/RandomVariable.cpp", 181 "fuzzing/TestRandomGraph.cpp", 182 "fuzzing/operation_signatures/*.cpp", 183 ], 184 static_libs: [ 185 "libSampleDriver", 186 "libgmock", 187 "libneuralnetworks_common", 188 "libneuralnetworks_static", 189 ], 190 shared_libs: ["libmemunreachable"], 191 header_libs: [ 192 "libneuralnetworks_private_headers", 193 ], 194} 195 196cc_fuzz { 197 name: "libneuralnetworks_fuzzer", 198 defaults: ["NeuralNetworksTest_default_libs"], 199 owner: "google", 200 fuzz_config: { 201 cc: ["butlermichael@google.com"], 202 }, 203 srcs: [ 204 "android_fuzzing/Converter.cpp", 205 "android_fuzzing/FuzzTest.cpp", 206 "android_fuzzing/StaticAssert.cpp", 207 ], 208 corpus: ["android_fuzzing/corpus/*"], 209 shared_libs: ["libprotobuf-cpp-full"], 210 static_libs: [ 211 "libneuralnetworks_common", 212 "libneuralnetworks_fuzzer_proto", 213 "libneuralnetworks_generated_test_harness", 214 "libneuralnetworks_static", 215 "libprotobuf-mutator", 216 ], 217} 218 219// Temporarily disabled due to b/139889855. 220cc_test { 221 name: "NeuralNetworksTest_static_asan", 222 defaults: ["NeuralNetworksTest_static_defaults"], 223 enabled: false, 224 sanitize: { 225 address: true, 226 }, 227 // Declare explicit library dependency for continuous builds 228 target: { 229 android_arm: { 230 required: [ 231 "libclang_rt.asan-arm-android", 232 ], 233 }, 234 android_arm64: { 235 required: [ 236 "libclang_rt.asan-aarch64-android", 237 ], 238 }, 239 android_x86: { 240 required: [ 241 "libclang_rt.asan-i686-android", 242 ], 243 }, 244 android_x86_64: { 245 required: [ 246 "libclang_rt.asan-x86_64-android", 247 ], 248 }, 249 }, 250} 251 252// Temporarily disabled due to b/139889855. 253cc_test { 254 name: "NeuralNetworksTest_static_ubsan", 255 defaults: ["NeuralNetworksTest_static_defaults"], 256 enabled: false, 257 sanitize: { 258 undefined: true, 259 all_undefined: true, 260 diag: { 261 undefined: true, 262 }, 263 }, 264} 265 266cc_defaults { 267 name: "NeuralNetworksTest_mt_defaults", 268 defaults: ["NeuralNetworksTest_default_libs"], 269 srcs: [ 270 "GeneratedTestUtils.cpp", 271 "TestGenerated.cpp", 272 "TestMain.cpp", 273 "TestNeuralNetworksWrapper.cpp", 274 ], 275 cflags: [ 276 "-DNNTEST_MULTITHREADED", 277 ], 278 static_libs: [ 279 "libSampleDriver", 280 "libgmock", 281 "libneuralnetworks_common", 282 "libneuralnetworks_static", 283 ], 284 whole_static_libs: [ 285 "neuralnetworks_generated_V1_0_example", 286 "neuralnetworks_generated_V1_1_example", 287 "neuralnetworks_generated_V1_2_example", 288 "neuralnetworks_generated_V1_3_cts_only_example", 289 "neuralnetworks_generated_V1_3_example", 290 ], 291 shared_libs: [ 292 "libcutils", 293 ], 294 header_libs: [ 295 "libneuralnetworks_private_headers", 296 ], 297} 298 299cc_test { 300 name: "NeuralNetworksTest_mt_static", 301 defaults: ["NeuralNetworksTest_mt_defaults"], 302} 303 304// Temporarily disabled due to b/139889855. 305cc_test { 306 // Note: tsan not supported on Android (yet) 307 name: "NeuralNetworksTest_mt_static_asan", 308 defaults: ["NeuralNetworksTest_mt_defaults"], 309 enabled: false, 310 sanitize: { 311 address: true, 312 }, 313} 314 315cc_library_static { 316 name: "CtsNNAPITests_static", 317 defaults: ["neuralnetworks_float16"], 318 srcs: [ 319 ":libneuralnetworks_generated_test_harness_for_cts", 320 "CtsMain.cpp", 321 "GeneratedTestUtils.cpp", 322 "RequireDebug.cpp", // Abort compilation if NDEBUG is defined 323 "TestControlFlow.cpp", 324 "TestFree.cpp", 325 "TestGenerated.cpp", 326 "TestMemory.cpp", 327 "TestNeuralNetworksWrapper.cpp", 328 "TestTrivialModel.cpp", 329 "TestUnknownDimensions.cpp", 330 "TestValidateModel.cpp", 331 "TestValidateOperations.cpp", 332 "TestValidation.cpp", 333 "TestWrapper.cpp", 334 "fuzzing/OperationManager.cpp", 335 "fuzzing/RandomGraphGenerator.cpp", 336 "fuzzing/RandomGraphGeneratorUtils.cpp", 337 "fuzzing/RandomVariable.cpp", 338 "fuzzing/TestRandomGraph.cpp", 339 "fuzzing/operation_signatures/*.cpp", 340 "generated/spec_V1_*/*.example.cpp", 341 ], 342 include_dirs: [ 343 "frameworks/ml/nn/common/include", 344 "frameworks/ml/nn/runtime/", 345 "frameworks/ml/nn/runtime/include/", 346 "frameworks/ml/nn/tools/test_generator/test_harness/include", 347 ], 348 cflags: [ 349 "-DNNTEST_CTS", 350 "-DNNTEST_ONLY_PUBLIC_API", 351 "-UNDEBUG", 352 "-Wall", 353 "-Werror", 354 ], 355 shared_libs: [ 356 "libandroid", 357 "liblog", 358 "libneuralnetworks", 359 ], 360 static_libs: [ 361 "libbase_ndk", 362 "libgmock_ndk", 363 "libgtest_ndk_c++", 364 ], 365 sdk_version: "current", 366 stl: "c++_static", 367} 368 369cc_library_static { 370 name: "neuralnetworks_generated_V1_0_example", 371 defaults: ["neuralnetworks_float16"], 372 srcs: ["generated/spec_V1_0/*.example.cpp"], 373 static_libs: ["libneuralnetworks_generated_test_harness"], 374} 375 376cc_library_static { 377 name: "neuralnetworks_generated_V1_1_example", 378 defaults: ["neuralnetworks_float16"], 379 srcs: ["generated/spec_V1_1/*.example.cpp"], 380 static_libs: ["libneuralnetworks_generated_test_harness"], 381} 382 383cc_library_static { 384 name: "neuralnetworks_generated_V1_2_example", 385 defaults: ["neuralnetworks_float16"], 386 srcs: ["generated/spec_V1_2/*.example.cpp"], 387 static_libs: ["libneuralnetworks_generated_test_harness"], 388} 389 390cc_library_static { 391 name: "neuralnetworks_generated_V1_3_example", 392 defaults: ["neuralnetworks_float16"], 393 srcs: ["generated/spec_V1_3/*.example.cpp"], 394 static_libs: ["libneuralnetworks_generated_test_harness"], 395} 396 397cc_library_static { 398 name: "neuralnetworks_generated_V1_3_cts_only_example", 399 defaults: ["neuralnetworks_float16"], 400 srcs: ["generated/spec_V1_3_cts_only/*.example.cpp"], 401 static_libs: ["libneuralnetworks_generated_test_harness"], 402} 403