Merge "Move cc_object tests to object_test.go"

This commit is contained in:
Treehugger Robot 2021-04-19 22:48:15 +00:00 committed by Gerrit Code Review
commit a0b235a9d9
2 changed files with 54 additions and 53 deletions

View File

@ -3778,59 +3778,6 @@ func TestMinSdkVersionInClangTriple(t *testing.T) {
android.AssertStringDoesContain(t, "min sdk version", cFlags, "-target aarch64-linux-android29") 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 type MemtagNoteType int
const ( const (

View File

@ -19,6 +19,60 @@ import (
"testing" "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) { func TestLinkerScript(t *testing.T) {
t.Run("script", func(t *testing.T) { t.Run("script", func(t *testing.T) {
testCc(t, ` testCc(t, `