From 07bc5f9c4e4aa36af38227d214141c903bdb4446 Mon Sep 17 00:00:00 2001 From: Liz Kammer Date: Thu, 8 Apr 2021 13:28:56 -0400 Subject: [PATCH] Add test for building cc_object with Bazel. Test: go test cc tests Change-Id: I45a341d09c92f57769d1c3b686f8abac113b3548 --- cc/object_test.go | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/cc/object_test.go b/cc/object_test.go index 6ff8a00c3..f82d5448b 100644 --- a/cc/object_test.go +++ b/cc/object_test.go @@ -15,6 +15,7 @@ package cc import ( + "android/soong/android" "testing" ) @@ -27,5 +28,28 @@ func TestLinkerScript(t *testing.T) { linker_script: "foo.lds", }`) }) - +} + +func TestCcObjectWithBazel(t *testing.T) { + bp := ` +cc_object { + name: "foo", + srcs: ["baz.o"], + bazel_module: { label: "//foo/bar:bar" }, +}` + config := TestConfig(t.TempDir(), android.Android, nil, bp, nil) + config.BazelContext = android.MockBazelContext{ + OutputBaseDir: "outputbase", + LabelToOutputFiles: map[string][]string{ + "//foo/bar:bar": []string{"bazel_out.o"}}} + ctx := testCcWithConfig(t, config) + + module := ctx.ModuleForTests("foo", "android_arm_armv7-a-neon").Module() + outputFiles, err := module.(android.OutputFileProducer).OutputFiles("") + if err != nil { + t.Errorf("Unexpected error getting cc_object outputfiles %s", err) + } + + expectedOutputFiles := []string{"outputbase/execroot/__main__/bazel_out.o"} + android.AssertDeepEquals(t, "output files", expectedOutputFiles, outputFiles.Strings()) }