aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'cc/cc_test.go')
-rw-r--r--cc/cc_test.go49
1 files changed, 47 insertions, 2 deletions
diff --git a/cc/cc_test.go b/cc/cc_test.go
index f3d5e60d..36d8aa41 100644
--- a/cc/cc_test.go
+++ b/cc/cc_test.go
@@ -20,6 +20,7 @@ import (
20 "fmt" 20 "fmt"
21 "io/ioutil" 21 "io/ioutil"
22 "os" 22 "os"
23 "path/filepath"
23 "reflect" 24 "reflect"
24 "sort" 25 "sort"
25 "strings" 26 "strings"
@@ -75,6 +76,7 @@ func createTestContext(t *testing.T, config android.Config, bp string, os androi
75 ctx.PostDepsMutators(func(ctx android.RegisterMutatorsContext) { 76 ctx.PostDepsMutators(func(ctx android.RegisterMutatorsContext) {
76 ctx.TopDown("double_loadable", checkDoubleLoadableLibraries).Parallel() 77 ctx.TopDown("double_loadable", checkDoubleLoadableLibraries).Parallel()
77 }) 78 })
79 ctx.RegisterSingletonType("vndk-snapshot", android.SingletonFactoryAdaptor(VndkSnapshotSingleton))
78 ctx.Register() 80 ctx.Register()
79 81
80 // add some modules that are required by the compiler and/or linker 82 // add some modules that are required by the compiler and/or linker
@@ -286,8 +288,28 @@ func checkVndkModule(t *testing.T, ctx *android.TestContext, name, subDir string
286 } 288 }
287} 289}
288 290
291func checkVndkSnapshot(t *testing.T, ctx *android.TestContext, name, subDir, variant string) {
292 vndkSnapshot := ctx.SingletonForTests("vndk-snapshot")
293
294 snapshotPath := filepath.Join(subDir, name+".so")
295 mod := ctx.ModuleForTests(name, variant).Module().(*Module)
296 if !mod.outputFile.Valid() {
297 t.Errorf("%q must have output\n", name)
298 return
299 }
300
301 out := vndkSnapshot.Output(snapshotPath)
302 if out.Input != mod.outputFile.Path() {
303 t.Errorf("The input of VNDK snapshot must be %q, but %q", out.Input.String(), mod.outputFile.String())
304 }
305}
306
289func TestVndk(t *testing.T) { 307func TestVndk(t *testing.T) {
290 ctx := testCc(t, ` 308 config := android.TestArchConfig(buildDir, nil)
309 config.TestProductVariables.DeviceVndkVersion = StringPtr("current")
310 config.TestProductVariables.Platform_vndk_version = StringPtr("VER")
311
312 ctx := testCcWithConfig(t, `
291 cc_library { 313 cc_library {
292 name: "libvndk", 314 name: "libvndk",
293 vendor_available: true, 315 vendor_available: true,
@@ -325,12 +347,35 @@ func TestVndk(t *testing.T) {
325 }, 347 },
326 nocrt: true, 348 nocrt: true,
327 } 349 }
328 `) 350 `, config)
329 351
330 checkVndkModule(t, ctx, "libvndk", "vndk-VER", false, "") 352 checkVndkModule(t, ctx, "libvndk", "vndk-VER", false, "")
331 checkVndkModule(t, ctx, "libvndk_private", "vndk-VER", false, "") 353 checkVndkModule(t, ctx, "libvndk_private", "vndk-VER", false, "")
332 checkVndkModule(t, ctx, "libvndk_sp", "vndk-sp-VER", true, "") 354 checkVndkModule(t, ctx, "libvndk_sp", "vndk-sp-VER", true, "")
333 checkVndkModule(t, ctx, "libvndk_sp_private", "vndk-sp-VER", true, "") 355 checkVndkModule(t, ctx, "libvndk_sp_private", "vndk-sp-VER", true, "")
356
357 // Check VNDK snapshot output.
358
359 snapshotDir := "vndk-snapshot"
360 snapshotVariantPath := filepath.Join(buildDir, snapshotDir, "arm64")
361
362 vndkLibPath := filepath.Join(snapshotVariantPath, fmt.Sprintf("arch-%s-%s",
363 "arm64", "armv8-a"))
364 vndkLib2ndPath := filepath.Join(snapshotVariantPath, fmt.Sprintf("arch-%s-%s",
365 "arm", "armv7-a-neon"))
366
367 vndkCoreLibPath := filepath.Join(vndkLibPath, "shared", "vndk-core")
368 vndkSpLibPath := filepath.Join(vndkLibPath, "shared", "vndk-sp")
369 vndkCoreLib2ndPath := filepath.Join(vndkLib2ndPath, "shared", "vndk-core")
370 vndkSpLib2ndPath := filepath.Join(vndkLib2ndPath, "shared", "vndk-sp")
371
372 variant := "android_arm64_armv8-a_vendor_shared"
373 variant2nd := "android_arm_armv7-a-neon_vendor_shared"
374
375 checkVndkSnapshot(t, ctx, "libvndk", vndkCoreLibPath, variant)
376 checkVndkSnapshot(t, ctx, "libvndk", vndkCoreLib2ndPath, variant2nd)
377 checkVndkSnapshot(t, ctx, "libvndk_sp", vndkSpLibPath, variant)
378 checkVndkSnapshot(t, ctx, "libvndk_sp", vndkSpLib2ndPath, variant2nd)
334} 379}
335 380
336func TestVndkDepError(t *testing.T) { 381func TestVndkDepError(t *testing.T) {