Colin Cross | cceefc8 | 2024-09-30 14:05:50 -0700 | [diff] [blame] | 1 | // Copyright 2024 Google Inc. All rights reserved. |
| 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 | |
| 15 | package cc |
| 16 | |
| 17 | import ( |
| 18 | "android/soong/android" |
| 19 | "testing" |
| 20 | ) |
| 21 | |
| 22 | func TestSabi(t *testing.T) { |
| 23 | bp := ` |
| 24 | cc_library { |
| 25 | name: "libsabi", |
| 26 | srcs: ["sabi.cpp"], |
| 27 | static_libs: ["libdirect"], |
| 28 | header_abi_checker: { |
| 29 | enabled: true, |
| 30 | symbol_file: "libsabi.map.txt", |
| 31 | ref_dump_dirs: ["abi-dumps"], |
| 32 | }, |
| 33 | } |
| 34 | |
| 35 | cc_library { |
| 36 | name: "libdirect", |
| 37 | srcs: ["direct.cpp"], |
| 38 | whole_static_libs: ["libtransitive"], |
| 39 | } |
| 40 | |
| 41 | cc_library { |
| 42 | name: "libtransitive", |
| 43 | srcs: ["transitive.cpp"], |
| 44 | } |
| 45 | ` |
| 46 | |
| 47 | result := android.GroupFixturePreparers( |
| 48 | PrepareForTestWithCcDefaultModules, |
| 49 | ).RunTestWithBp(t, bp) |
| 50 | |
Colin Cross | 91ae5ec | 2024-10-01 14:03:40 -0700 | [diff] [blame] | 51 | libsabiStatic := result.ModuleForTests("libsabi", "android_arm64_armv8-a_static_sabi") |
Colin Cross | cceefc8 | 2024-09-30 14:05:50 -0700 | [diff] [blame] | 52 | sabiObjSDump := libsabiStatic.Output("obj/sabi.sdump") |
| 53 | |
Colin Cross | 91ae5ec | 2024-10-01 14:03:40 -0700 | [diff] [blame] | 54 | libDirect := result.ModuleForTests("libdirect", "android_arm64_armv8-a_static_sabi") |
Colin Cross | cceefc8 | 2024-09-30 14:05:50 -0700 | [diff] [blame] | 55 | directObjSDump := libDirect.Output("obj/direct.sdump") |
| 56 | |
Colin Cross | 91ae5ec | 2024-10-01 14:03:40 -0700 | [diff] [blame] | 57 | libTransitive := result.ModuleForTests("libtransitive", "android_arm64_armv8-a_static_sabi") |
Colin Cross | cceefc8 | 2024-09-30 14:05:50 -0700 | [diff] [blame] | 58 | transitiveObjSDump := libTransitive.Output("obj/transitive.sdump") |
| 59 | |
| 60 | libsabiShared := result.ModuleForTests("libsabi", "android_arm64_armv8-a_shared") |
| 61 | sabiLink := libsabiShared.Rule("sAbiLink") |
| 62 | |
| 63 | android.AssertStringListContains(t, "sabi link inputs", sabiLink.Inputs.Strings(), sabiObjSDump.Output.String()) |
| 64 | android.AssertStringListContains(t, "sabi link inputs", sabiLink.Inputs.Strings(), directObjSDump.Output.String()) |
| 65 | android.AssertStringListContains(t, "sabi link inputs", sabiLink.Inputs.Strings(), transitiveObjSDump.Output.String()) |
| 66 | } |