1// Build the unit tests. 2 3package { 4 default_team: "trendy_team_art_mainline", 5 // http://go/android-license-faq 6 // A large-scale-change added 'default_applicable_licenses' to import 7 // the below license kinds from "libnativehelper_license": 8 // SPDX-license-identifier-Apache-2.0 9 default_applicable_licenses: ["libnativehelper_license"], 10} 11 12cc_defaults { 13 name: "libnativehelper_common_test_defaults", 14 cflags: [ 15 // Base set of cflags used by all things ART. 16 "-fno-rtti", 17 "-ggdb3", 18 "-Wall", 19 "-Werror", 20 "-Wextra", 21 "-Wstrict-aliasing", 22 "-fstrict-aliasing", 23 "-Wunreachable-code", 24 "-Wredundant-decls", 25 "-Wshadow", 26 "-Wunused", 27 "-fvisibility=protected", 28 29 // Warn about thread safety violations with clang. 30 "-Wthread-safety", 31 "-Wthread-safety-negative", 32 33 // Warn if switch fallthroughs aren't annotated. 34 "-Wimplicit-fallthrough", 35 36 // Enable float equality warnings. 37 "-Wfloat-equal", 38 39 // Enable warning of converting ints to void*. 40 "-Wint-to-void-pointer-cast", 41 42 // Enable warning for deprecated language features. 43 "-Wdeprecated", 44 45 // Disable warning from external/libcxxabi/include/cxxabi.h 46 "-Wno-deprecated-dynamic-exception-spec", 47 48 // Enable warning for unreachable break & return. 49 "-Wunreachable-code-break", 50 "-Wunreachable-code-return", 51 52 // Enable thread annotations for std::mutex, etc. 53 "-D_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS", 54 ], 55 tidy: true, 56} 57 58cc_defaults { 59 name: "libnativehelper_unit_test_defaults", 60 defaults: ["libnativehelper_common_test_defaults"], 61 host_supported: true, 62 test_options: { 63 unit_test: true, 64 }, 65} 66 67cc_test { 68 name: "libnativehelper_tests", 69 defaults: ["libnativehelper_unit_test_defaults"], 70 test_suites: ["general-tests"], 71 srcs: [ 72 "scoped_local_frame_test.cpp", 73 "scoped_local_ref_test.cpp", 74 "scoped_primitive_array_test.cpp", 75 "libnativehelper_api_test.c", 76 "JniSafeRegisterNativeMethods_test.cpp", 77 ], 78 shared_libs: ["libnativehelper"], 79} 80 81cc_test { 82 name: "libnativehelper_lazy_tests", 83 defaults: ["libnativehelper_unit_test_defaults"], 84 test_suites: ["general-tests"], 85 srcs: ["libnativehelper_lazy_test.cpp"], 86 shared_libs: ["liblog"], 87 static_libs: ["libnativehelper_lazy"], 88} 89 90// Tests for internal functions that aren't present in the APEX stub API. Use 91// `bootstrap:true` to bypass the stub library. This test won't link when 92// prebuilts are preferred, because we cannot link against the source variant 93// then. 94// TODO(b/180107266): Enable in TEST_MAPPING. Also use a better way than 95// `bootstrap:true` - `test_for` ought to work but fails because the test is 96// host enabled so host variants of the APEXes are expected. 97cc_test { 98 name: "libnativehelper_internal_tests", 99 defaults: [ 100 "libnativehelper_unit_test_defaults", 101 ], 102 srcs: [ 103 "ExpandableString_test.cpp", 104 "JniInvocation_test.cpp", 105 ], 106 bootstrap: true, 107 shared_libs: ["libnativehelper"], 108} 109 110cc_library { 111 name: "libnativehelper_internal_tests_jni", 112 defaults: [ 113 "libnativehelper_common_test_defaults", 114 ], 115 host_supported: false, 116 srcs: [ 117 "libnativehelper_test.cpp", 118 ], 119 shared_libs: [ 120 "libnativehelper", 121 "liblog", 122 ], 123 static_libs: [ 124 "libbase", 125 "libgmock", 126 "libnativetesthelper_jni", 127 ], 128} 129 130android_test { 131 name: "LibnativehelperInternalTestCases", 132 srcs: [ 133 "src/**/*.java", 134 ], 135 jni_libs: [ 136 "libnativehelper_internal_tests_jni", 137 ], 138 static_libs: [ 139 "ctstestrunner-axt", 140 "nativetesthelper", 141 ], 142 manifest: "AndroidManifest.xml", 143 test_suites: ["general-tests"], 144} 145