blob: 3e18940fe67da090c7ad21ebd025ca2e1cc921cf [file] [log] [blame]
Yu Liu7f3605f2022-02-08 14:15:12 -08001// Copyright 2022 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 "testing"
19
20 "android/soong/android"
21)
22
David Brazdil958c9572022-04-22 15:17:54 +010023func TestBinaryLinkerScripts(t *testing.T) {
Liz Kammer7c5d1592022-10-31 16:27:38 -040024 t.Parallel()
David Brazdil958c9572022-04-22 15:17:54 +010025 result := PrepareForIntegrationTestWithCc.RunTestWithBp(t, `
26 cc_binary {
27 name: "foo",
28 srcs: ["foo.cc"],
29 linker_scripts: ["foo.ld", "bar.ld"],
30 }`)
31
32 binFoo := result.ModuleForTests("foo", "android_arm64_armv8-a").Rule("ld")
33
34 android.AssertStringListContains(t, "missing dependency on linker_scripts",
35 binFoo.Implicits.Strings(), "foo.ld")
36 android.AssertStringListContains(t, "missing dependency on linker_scripts",
37 binFoo.Implicits.Strings(), "bar.ld")
38 android.AssertStringDoesContain(t, "missing flag for linker_scripts",
David Brazdil3ac9d2b2022-05-09 19:35:10 +010039 binFoo.Args["ldFlags"], "-Wl,--script,foo.ld")
David Brazdil958c9572022-04-22 15:17:54 +010040 android.AssertStringDoesContain(t, "missing flag for linker_scripts",
David Brazdil3ac9d2b2022-05-09 19:35:10 +010041 binFoo.Args["ldFlags"], "-Wl,--script,bar.ld")
David Brazdil958c9572022-04-22 15:17:54 +010042}