From 25f369fdca0011b09823f1bcc03929c553d1005d Mon Sep 17 00:00:00 2001 From: Liz Kammer Date: Mon, 19 Apr 2021 12:44:51 -0400 Subject: [PATCH] Move cc_object tests to object_test.go Test: go test cc tests Change-Id: I6a138482f678b6168b06b523ddbfeb639bf70364 --- cc/cc_test.go | 53 ---------------------------------------------- cc/object_test.go | 54 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 53 deletions(-) diff --git a/cc/cc_test.go b/cc/cc_test.go index 07dcc951f..c4d75ec81 100644 --- a/cc/cc_test.go +++ b/cc/cc_test.go @@ -3756,59 +3756,6 @@ func TestMinSdkVersionInClangTriple(t *testing.T) { android.AssertStringDoesContain(t, "min sdk version", cFlags, "-target aarch64-linux-android29") } -func TestMinSdkVersionsOfCrtObjects(t *testing.T) { - ctx := testCc(t, ` - cc_object { - name: "crt_foo", - srcs: ["foo.c"], - crt: true, - stl: "none", - min_sdk_version: "28", - - }`) - - arch := "android_arm64_armv8-a" - for _, v := range []string{"", "28", "29", "30", "current"} { - var variant string - if v == "" { - variant = arch - } else { - variant = arch + "_sdk_" + v - } - cflags := ctx.ModuleForTests("crt_foo", variant).Rule("cc").Args["cFlags"] - vNum := v - if v == "current" || v == "" { - vNum = "10000" - } - expected := "-target aarch64-linux-android" + vNum + " " - android.AssertStringDoesContain(t, "cflag", cflags, expected) - } -} - -func TestUseCrtObjectOfCorrectVersion(t *testing.T) { - ctx := testCc(t, ` - cc_binary { - name: "bin", - srcs: ["foo.c"], - stl: "none", - min_sdk_version: "29", - sdk_version: "current", - } - `) - - // Sdk variant uses the crt object of the matching min_sdk_version - variant := "android_arm64_armv8-a_sdk" - crt := ctx.ModuleForTests("bin", variant).Rule("ld").Args["crtBegin"] - android.AssertStringDoesContain(t, "crt dep of sdk variant", crt, - variant+"_29/crtbegin_dynamic.o") - - // platform variant uses the crt object built for platform - variant = "android_arm64_armv8-a" - crt = ctx.ModuleForTests("bin", variant).Rule("ld").Args["crtBegin"] - android.AssertStringDoesContain(t, "crt dep of platform variant", crt, - variant+"/crtbegin_dynamic.o") -} - type MemtagNoteType int const ( diff --git a/cc/object_test.go b/cc/object_test.go index f82d5448b..0e5508a4a 100644 --- a/cc/object_test.go +++ b/cc/object_test.go @@ -19,6 +19,60 @@ import ( "testing" ) +func TestMinSdkVersionsOfCrtObjects(t *testing.T) { + ctx := testCc(t, ` + cc_object { + name: "crt_foo", + srcs: ["foo.c"], + crt: true, + stl: "none", + min_sdk_version: "28", + + }`) + + arch := "android_arm64_armv8-a" + for _, v := range []string{"", "28", "29", "30", "current"} { + var variant string + // platform variant + if v == "" { + variant = arch + } else { + variant = arch + "_sdk_" + v + } + cflags := ctx.ModuleForTests("crt_foo", variant).Rule("cc").Args["cFlags"] + vNum := v + if v == "current" || v == "" { + vNum = "10000" + } + expected := "-target aarch64-linux-android" + vNum + " " + android.AssertStringDoesContain(t, "cflag", cflags, expected) + } +} + +func TestUseCrtObjectOfCorrectVersion(t *testing.T) { + ctx := testCc(t, ` + cc_binary { + name: "bin", + srcs: ["foo.c"], + stl: "none", + min_sdk_version: "29", + sdk_version: "current", + } + `) + + // Sdk variant uses the crt object of the matching min_sdk_version + variant := "android_arm64_armv8-a_sdk" + crt := ctx.ModuleForTests("bin", variant).Rule("ld").Args["crtBegin"] + android.AssertStringDoesContain(t, "crt dep of sdk variant", crt, + variant+"_29/crtbegin_dynamic.o") + + // platform variant uses the crt object built for platform + variant = "android_arm64_armv8-a" + crt = ctx.ModuleForTests("bin", variant).Rule("ld").Args["crtBegin"] + android.AssertStringDoesContain(t, "crt dep of platform variant", crt, + variant+"/crtbegin_dynamic.o") +} + func TestLinkerScript(t *testing.T) { t.Run("script", func(t *testing.T) { testCc(t, `