blob: 8ec387182473d97965ff18fa5732b4edd23b5ec0 [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
23func TestCcBinaryWithBazel(t *testing.T) {
24 bp := `
25cc_binary {
26 name: "foo",
27 srcs: ["foo.cc"],
28 bazel_module: { label: "//foo/bar:bar" },
29}`
30 config := TestConfig(t.TempDir(), android.Android, nil, bp, nil)
31 config.BazelContext = android.MockBazelContext{
32 OutputBaseDir: "outputbase",
33 LabelToOutputFiles: map[string][]string{
34 "//foo/bar:bar": []string{"foo"},
35 },
36 }
37 ctx := testCcWithConfig(t, config)
38
39 binMod := ctx.ModuleForTests("foo", "android_arm64_armv8-a").Module()
40 producer := binMod.(android.OutputFileProducer)
41 outputFiles, err := producer.OutputFiles("")
42 if err != nil {
43 t.Errorf("Unexpected error getting cc_binary outputfiles %s", err)
44 }
45 expectedOutputFiles := []string{"outputbase/execroot/__main__/foo"}
46 android.AssertDeepEquals(t, "output files", expectedOutputFiles, outputFiles.Strings())
47
48 unStrippedFilePath := binMod.(*Module).UnstrippedOutputFile()
49 expectedUnStrippedFile := "outputbase/execroot/__main__/foo"
50 android.AssertStringEquals(t, "Unstripped output file", expectedUnStrippedFile, unStrippedFilePath.String())
51}