Move cc_object tests to object_test.go
Test: go test cc tests Change-Id: I6a138482f678b6168b06b523ddbfeb639bf70364
This commit is contained in:
parent
0b21bf60b6
commit
25f369fdca
2 changed files with 54 additions and 53 deletions
|
@ -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 (
|
||||
|
|
|
@ -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, `
|
||||
|
|
Loading…
Reference in a new issue