Merge "Move cc_object tests to object_test.go"
diff --git a/cc/cc_test.go b/cc/cc_test.go
index 26d1f8e..db696ef 100644
--- a/cc/cc_test.go
+++ b/cc/cc_test.go
@@ -3778,59 +3778,6 @@
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 f82d544..0e5508a 100644
--- a/cc/object_test.go
+++ b/cc/object_test.go
@@ -19,6 +19,60 @@
"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, `