1// 2// Copyright (C) 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 17package { 18 default_team: "trendy_team_renderscript_nnapi", 19 default_applicable_licenses: ["Android-Apache-2.0"], 20} 21 22java_genrule { 23 name: "lib-test-profile-text-protos", 24 host_supported: true, 25 tools: ["aprotoc"], 26 srcs: [ 27 ":profile-proto-def", 28 "assets/*.textpb", 29 ], 30 out: ["lib-test-profiles.jar"], 31 /* 32 * Loops over all *.textpb files under assets/ and serializes them into binary protos with 33 * ".pb" extension using aprotoc. The generated *.pb files are put under an assets/ 34 * directory, which gets packed into a .jar file and ends up under the assets/ 35 * directory in the package, which can then be read with asset manager. 36 * 37 * If a profile fails to parse, an error is thrown and the build will fail. 38 */ 39 cmd: "out_dir=$$(dirname $(out)) && assets_dir=\"assets\" " + 40 "&& mkdir -p $$out_dir/$$assets_dir && src_protos=($(locations assets/*.textpb)) " + 41 "&& for file in $${src_protos[@]} ; do fname=$$(basename $$file) " + 42 "&& if ! ($(location aprotoc) --encode=longevity.profile.Configuration " + 43 "$(location :profile-proto-def) < $$file > " + 44 "$$out_dir/$$assets_dir/$${fname//.textpb/.pb}) ; then " + 45 "echo \"\x1b[0;31mFailed to parse profile $$file. See above for errors.\x1b[0m\" " + 46 "&& exit 1 ; fi ; done && jar cf $(out) -C $$(dirname $(out)) $$assets_dir", 47} 48 49android_test { 50 name: "LongevityPlatformLibTests", 51 52 min_sdk_version: "26", 53 static_libs: [ 54 "androidx.test.runner", 55 "common-platform-scenarios", 56 "guava", 57 "lib-test-profile-text-protos", 58 "longevity-device-lib", 59 "microbenchmark-device-lib", 60 "mockito-target", 61 "platform-test-composers", 62 "platform-test-rules", 63 "truth", 64 "ub-uiautomator", 65 ], 66 srcs: ["src/**/*.java"], 67 test_suites: ["device-tests"], 68} 69