1# Copyright (C) 2023 The Android Open Source Project 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14 15load( 16 "//build/bazel/rules/test_common:flags.bzl", 17 "action_flags_absent_for_mnemonic_aosp_arm64_host_test", 18 "action_flags_absent_for_mnemonic_aosp_arm64_test", 19 "action_flags_present_only_for_mnemonic_aosp_arm64_host_test", 20 "action_flags_present_only_for_mnemonic_aosp_arm64_test", 21) 22 23def _test_device_present(): 24 test_name = "test_device_present" 25 26 action_flags_present_only_for_mnemonic_aosp_arm64_test( 27 name = test_name, 28 target_under_test = ":build.bazel.examples.soong_config_variables.plus_os__internal_root_cpp", 29 mnemonics = ["CppCompile"], 30 expected_flags = [ 31 "-DDEFAULT", 32 "-DDEFAULT_PLUS_ANDROID", 33 "-DBOOL_VAR_DEFAULT", 34 "-DBOOL_VAR_DEFAULT_PLUS_ANDROID", 35 ], 36 ) 37 38 return test_name 39 40def _test_device_absent(): 41 test_name = "test_device_absent" 42 43 action_flags_absent_for_mnemonic_aosp_arm64_test( 44 name = test_name, 45 target_under_test = ":build.bazel.examples.soong_config_variables.plus_os__internal_root_cpp", 46 mnemonics = ["CppCompile"], 47 expected_absent_flags = [ 48 "-DDEFAULT_PLUS_HOST", 49 "-DBOOL_VAR_DEFAULT_PLUS_HOST", 50 ], 51 ) 52 53 return test_name 54 55def _test_host_present(): 56 test_name = "test_host_present" 57 58 action_flags_present_only_for_mnemonic_aosp_arm64_host_test( 59 name = test_name, 60 target_under_test = ":build.bazel.examples.soong_config_variables.plus_os__internal_root_cpp", 61 mnemonics = ["CppCompile"], 62 expected_flags = [ 63 "-DDEFAULT", 64 "-DDEFAULT_PLUS_HOST", 65 "-DBOOL_VAR_DEFAULT", 66 "-DBOOL_VAR_DEFAULT_PLUS_HOST", 67 ], 68 ) 69 70 return test_name 71 72def _test_host_absent(): 73 test_name = "test_host_absent" 74 75 action_flags_absent_for_mnemonic_aosp_arm64_host_test( 76 name = test_name, 77 target_under_test = ":build.bazel.examples.soong_config_variables.plus_os__internal_root_cpp", 78 mnemonics = ["CppCompile"], 79 expected_absent_flags = [ 80 "-DDEFAULT_PLUS_ANDROID", 81 "-DBOOL_VAR_DEFAULT_PLUS_ANDROID", 82 ], 83 ) 84 85 return test_name 86 87def soong_config_variables_plus_os_test_suite(name): 88 native.test_suite( 89 name = name, 90 tests = [ 91 _test_device_present(), 92 _test_device_absent(), 93 _test_host_present(), 94 _test_host_absent(), 95 ], 96 ) 97