| Yu Liu | 7f3605f | 2022-02-08 14:15:12 -0800 | [diff] [blame] | 1 | // 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 |  | 
|  | 15 | package cc | 
|  | 16 |  | 
|  | 17 | import ( | 
|  | 18 | "testing" | 
|  | 19 |  | 
|  | 20 | "android/soong/android" | 
|  | 21 | ) | 
|  | 22 |  | 
| David Brazdil | 958c957 | 2022-04-22 15:17:54 +0100 | [diff] [blame] | 23 | func TestBinaryLinkerScripts(t *testing.T) { | 
| Liz Kammer | 7c5d159 | 2022-10-31 16:27:38 -0400 | [diff] [blame] | 24 | t.Parallel() | 
| David Brazdil | 958c957 | 2022-04-22 15:17:54 +0100 | [diff] [blame] | 25 | 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 Brazdil | 3ac9d2b | 2022-05-09 19:35:10 +0100 | [diff] [blame] | 39 | binFoo.Args["ldFlags"], "-Wl,--script,foo.ld") | 
| David Brazdil | 958c957 | 2022-04-22 15:17:54 +0100 | [diff] [blame] | 40 | android.AssertStringDoesContain(t, "missing flag for linker_scripts", | 
| David Brazdil | 3ac9d2b | 2022-05-09 19:35:10 +0100 | [diff] [blame] | 41 | binFoo.Args["ldFlags"], "-Wl,--script,bar.ld") | 
| David Brazdil | 958c957 | 2022-04-22 15:17:54 +0100 | [diff] [blame] | 42 | } |