1#!/usr/bin/env bash 2 3# Copyright (C) 2022 The Android Open Source Project 4# 5# Licensed under the Apache License, Version 2.0 (the "License"); 6# you may not use this file except in compliance with the License. 7# You may obtain a copy of the License at 8# 9# http://www.apache.org/licenses/LICENSE-2.0 10# 11# Unless required by applicable law or agreed to in writing, software 12# distributed under the License is distributed on an "AS IS" BASIS, 13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14# See the License for the specific language governing permissions and 15# limitations under the License. 16 17# Tests that generated targets have correct srcs attribute. 18 19. "${RUNFILES_DIR}/bazel_tools/tools/bash/runfiles/runfiles.bash" 20 21readonly expected_query_v1="\ 22//build/bazel/rules/aidl/testing:Test.aidl 23//build/bazel/rules/aidl/testing:aidl_api/aidl_interface_test/1/.hash 24//build/bazel/rules/aidl/testing:aidl_api/aidl_interface_test/1/android/net/Test.aidl 25//build/bazel/rules/aidl/testing:aidl_api/aidl_interface_test/1/android/net/Test2.aidl 26//build/bazel/rules/aidl/testing:aidl_api/aidl_interface_test/1/android/net/Test3.aidl 27//system/tools/aidl/build:message_check_equality.txt" 28readonly expected_query_v2="\ 29//build/bazel/rules/aidl/testing:Test.aidl 30//build/bazel/rules/aidl/testing:aidl_api/aidl_interface_test/2/.hash 31//build/bazel/rules/aidl/testing:aidl_api/aidl_interface_test/2/Test2Only.aidl 32//system/tools/aidl/build:message_check_equality.txt" 33 34readonly query_path_v1="__main__/build/bazel/rules/aidl/testing/generated_target_V1_has_correct_srcs_query" 35readonly query_path_v2="__main__/build/bazel/rules/aidl/testing/generated_target_V2_has_correct_srcs_query" 36readonly actual_query_v1=$(cat "$(rlocation $query_path_v1)") 37readonly actual_query_v2=$(cat "$(rlocation $query_path_v2)") 38 39if [ "$expected_query_v1" != "$actual_query_v1" ]; then 40 echo "aidl_interface generated target V1 has incorrect srcs." && 41 echo "expected:" && 42 echo "$expected_query_v1" && 43 echo "actual:" && 44 echo "$actual_query_v1" && 45 exit 1 46fi 47 48if [ "$expected_query_v2" != "$actual_query_v2" ]; then 49 echo "aidl_interface generated target V2 has incorrect srcs." && 50 echo "expected:" && 51 echo "$expected_query_v2" && 52 echo "actual:" && 53 echo "$actual_query_v2" && 54 exit 1 55fi 56