blob: 849fc36e8c795ce984ce799901e35c871e66044b [file] [log] [blame]
Colin Crosscceefc82024-09-30 14:05:50 -07001// 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
15package cc
16
17import (
18 "android/soong/android"
19 "testing"
20)
21
22func 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
51 libsabiStatic := result.ModuleForTests("libsabi", "android_arm64_armv8-a_static")
52 sabiObjSDump := libsabiStatic.Output("obj/sabi.sdump")
53
54 libDirect := result.ModuleForTests("libdirect", "android_arm64_armv8-a_static")
55 directObjSDump := libDirect.Output("obj/direct.sdump")
56
57 libTransitive := result.ModuleForTests("libtransitive", "android_arm64_armv8-a_static")
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}