[bazel] Rewrite Android GM tests to use the modular build.
This CL is similar to https://skia-review.googlesource.com/c/skia/+/815096.
On that CL, I commented out all GM Android tests due to breaking changes I introduced in the android_test Bazel macro. This CL addresses those breaking changes and uncomments all Android GM tests.
I also added an Android Ganesh/Vulkan GM test for demonstration purposes.
Bug: b/40045064
Bug: b/40045301
Change-Id: I7879d5a878a8255240c5dd1a719bff6383fd0555
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/816005
Commit-Queue: Leandro Lovisolo <lovisolo@google.com>
Reviewed-by: Kevin Lubick <kjlubick@google.com>
diff --git a/gm/BUILD.bazel b/gm/BUILD.bazel
index 106dcb73..afda11f 100644
--- a/gm/BUILD.bazel
+++ b/gm/BUILD.bazel
@@ -1,4 +1,5 @@
load("//bazel:skia_rules.bzl", "exports_files_legacy", "skia_cc_library", "skia_cc_test")
+load("//tools/testrunners/gm:android_gm_test.bzl", "android_gm_test")
load(":png_codec.bzl", "png_codec_tests")
licenses(["notice"])
@@ -656,100 +657,127 @@
],
)
-# Android tests temporarily disabled until we rewrite them to use the modular build.
+android_gm_test(
+ name = "hello_bazel_world_android_test",
+ srcs = [
+ "hello_bazel_world.cpp",
+ "//tools/testrunners/gm:BazelGMTestRunner.cpp",
+ ],
+ args = [
+ "--surfaceConfig",
+ "8888",
+ ],
+ requires_resources_dir = True,
+ deps = [
+ ":tests_base",
+ "//tools/testrunners/common/surface_manager:raster",
+ "//tools/testrunners/gm/vias:simple_vias",
+ ],
+)
-# load("//tools/testrunners/gm:android_gm_test.bzl", "android_gm_test")
+[
+ # Sample invocation (assuming there's a Pixel 5 or similar device available via adb):
+ #
+ # $ bazel test --config=android_rbe --config=Pixel5 //gm:cpu_8888_android_test
+ #
+ # Then inspect the PNG and JSON files produced by the GMs:
+ #
+ # $ unzip -l bazel-testlogs/gm/cpu_8888_android_test/test.outputs/outputs.zip
+ android_gm_test(
+ name = "cpu_%s_android_test" % surface_config,
+ srcs = CPU_GMS + [
+ "//tools/testrunners/gm:BazelGMTestRunner.cpp",
+ ],
+ args = [
+ "--surfaceConfig",
+ "8888",
+ ],
+ requires_resources_dir = True,
+ deps = [
+ ":tests_base",
+ "//tools/testrunners/common/surface_manager:raster",
+ "//tools/testrunners/gm/vias:simple_vias",
+ "//tools/timer", # Required by addarc.cpp and animatedimageblurs.cpp.
+ ],
+ )
+ for surface_config in [
+ "8888",
+ "565",
+ ]
+]
-# android_gm_test(
-# name = "hello_bazel_world_android_test",
-# srcs = ["hello_bazel_world.cpp"],
-# requires_resources_dir = True,
-# surface_config = "8888",
-# deps = [":tests_base"],
-# )
+android_gm_test(
+ name = "ganesh_gles_android_test",
+ srcs = GPU_GMS + [
+ "//tools/testrunners/gm:BazelGMTestRunner.cpp",
+ ],
+ args = [
+ "--surfaceConfig",
+ "gles",
+ ],
+ requires_resources_dir = True,
+ deps = [
+ ":tests_base",
+ "//tools/testrunners/common/surface_manager:ganesh_gl",
+ "//tools/testrunners/gm/vias:simple_vias",
+ ],
+)
-# [
-# # Sample invocation (assuming there's a Pixel 5 or similar device available via adb):
-# #
-# # $ bazel test --config=linux_rbe //gm:cpu_8888_android_test --config=pixel_5
-# #
-# # Then inspect the PNG and JSON files produced by the GMs:
-# #
-# # $ unzip -l bazel-testlogs/gm/cpu_8888_android_test/test.outputs/outputs.zip
-# android_gm_test(
-# name = "cpu_%s_android_test" % surface_config,
-# srcs = CPU_GMS,
-# flags = {
-# "include_decoder": [
-# "gif_decode_codec",
-# "webp_decode_codec",
-# ],
-# },
-# requires_resources_dir = True,
-# surface_config = surface_config,
-# deps = [":tests_base"],
-# )
-# for surface_config in [
-# "8888",
-# "565",
-# ]
-# ]
+android_gm_test(
+ name = "ganesh_gles_via_picture_serialization_android_test",
+ srcs = GPU_GMS + [
+ "//tools/testrunners/gm:BazelGMTestRunner.cpp",
+ ],
+ args = [
+ "--surfaceConfig",
+ "gles",
+ "--via",
+ "picture_serialization",
+ "--skip",
+ "anisomips", # Fails with "Recorded and reference bitmap pixels do not match".
+ ],
+ requires_resources_dir = True,
+ deps = [
+ ":tests_base",
+ "//tools/testrunners/common/surface_manager:ganesh_gl",
+ "//tools/testrunners/gm/vias:simple_vias",
+ ],
+)
-# android_gm_test(
-# name = "gpu_gles_android_test",
-# srcs = GPU_GMS,
-# flags = {
-# "include_decoder": [
-# "png_decode_codec",
-# "webp_decode_codec",
-# ],
-# },
-# requires_condition = "//src/gpu:gl_ganesh",
-# requires_resources_dir = True,
-# surface_config = "gles",
-# deps = [":tests_base"],
-# )
+android_gm_test(
+ name = "ganesh_gles_via_picture_android_test",
+ srcs = GPU_GMS + [
+ "//tools/testrunners/gm:BazelGMTestRunner.cpp",
+ ],
+ args = [
+ "--surfaceConfig",
+ "gles",
+ "--via",
+ "picture",
+ "--skip",
+ "anisomips", # Fails with "Recorded and reference bitmap pixels do not match".
+ ],
+ requires_resources_dir = True,
+ deps = [
+ ":tests_base",
+ "//tools/testrunners/common/surface_manager:ganesh_gl",
+ "//tools/testrunners/gm/vias:simple_vias",
+ ],
+)
-# # Currently fails the "anisomips" GM with "Deserialized and reference bitmap pixels do not match".
-# # Other GMs do pass.
-# # TODO(lovisolo): Define flag --skip and skip the "anisomips" GM.
-# android_gm_test(
-# name = "gpu_gles_via_picture_serialization_android_test",
-# srcs = GPU_GMS,
-# flags = {
-# "include_decoder": [
-# "png_decode_codec",
-# "webp_decode_codec",
-# ],
-# "include_encoder": [
-# "png_encode_codec", # Required by the "picture_serialization" via.
-# ],
-# },
-# requires_condition = "//src/gpu:gl_ganesh",
-# requires_resources_dir = True,
-# surface_config = "gles",
-# via = "picture_serialization",
-# deps = [":tests_base"],
-# )
-
-# # Currently fails the "anisomips" GM with "Deserialized and reference bitmap pixels do not match".
-# # Other GMs do pass.
-# # TODO(lovisolo): Define flag --skip and skip the "anisomips" GM.
-# android_gm_test(
-# name = "gpu_gles_via_picture_android_test",
-# srcs = GPU_GMS,
-# flags = {
-# "include_decoder": [
-# "png_decode_codec",
-# "webp_decode_codec",
-# ],
-# "include_encoder": [
-# "png_encode_codec", # Required by the "picture" via.
-# ],
-# },
-# requires_condition = "//src/gpu:gl_ganesh",
-# requires_resources_dir = True,
-# surface_config = "gles",
-# via = "picture",
-# deps = [":tests_base"],
-# )
+android_gm_test(
+ name = "ganesh_vk_android_test",
+ srcs = GPU_GMS + [
+ "//tools/testrunners/gm:BazelGMTestRunner.cpp",
+ ],
+ args = [
+ "--surfaceConfig",
+ "vk",
+ ],
+ requires_resources_dir = True,
+ deps = [
+ ":tests_base",
+ "//tools/testrunners/common/surface_manager:ganesh_vulkan",
+ "//tools/testrunners/gm/vias:simple_vias",
+ ],
+)
diff --git a/tools/testrunners/common/surface_manager/surface_configs.bzl b/tools/testrunners/common/surface_manager/surface_configs.bzl
deleted file mode 100644
index 3ecd1bf..0000000
--- a/tools/testrunners/common/surface_manager/surface_configs.bzl
+++ /dev/null
@@ -1,10 +0,0 @@
-"""This module defines the SURFACE_CONFIGS constant."""
-
-# This list should be kept in sync with the union of all configs supported by all SurfaceManager
-# in //tools/testrunners/common/surface_manager.
-SURFACE_CONFIGS = [
- "nonrendering",
- "8888",
- "565",
- "gles",
-]
diff --git a/tools/testrunners/gm/android_gm_test.bzl b/tools/testrunners/gm/android_gm_test.bzl
index 228bfa1..78e4f0e 100644
--- a/tools/testrunners/gm/android_gm_test.bzl
+++ b/tools/testrunners/gm/android_gm_test.bzl
@@ -1,43 +1,23 @@
"""This module defines the android_gm_test macro."""
load("//tools/testrunners/common/android:android_test.bzl", "android_test")
-load("//tools/testrunners/common/surface_manager:surface_configs.bzl", "SURFACE_CONFIGS")
-def android_gm_test(surface_config, via = None, extra_args = [], flags = {}, **kwargs):
+def android_gm_test(args = [], **kwargs):
"""Defines an Android GM test.
This macro is just a wrapper around the android_test macro with the necessary defaults for
Android GM tests. See the android_test macro documentation for details.
Args:
- surface_config: The surface config under which the GMs should run.
- via: The via under which the GMs should run. If set, the "flags" argument will be updated
- to set the //gm/vias:via flag accordingly. If unset, no via will be used.
- extra_args: See the android_test macro documentation.
- flags: See the android_test macro documentation.
+ args: Any command-line arguments to pass to the test.
**kwargs: Any arguments to pass to the underlying android_test macro instance.
"""
- if surface_config not in SURFACE_CONFIGS:
- fail("Unknown surface_config: " + surface_config)
-
- # Set the //gm/vias:via flag to match the "via" argument. This ensures that the build includes
- # the sources for the requested via. If the "via" argument has an unknown value, Bazel will
- # produce an error when the underlying cc_binary_with_flags target attempts to set the
- # //gm/vias:via flag.
- if via:
- flags.update([("via", [via])])
-
android_test(
- test_runner_if_required_condition_is_satisfied = "//tools/testrunners/gm:testrunner",
- test_runner_if_required_condition_is_not_satisfied = "//tools/testrunners/common:noop_testrunner",
- extra_args = extra_args + [
+ extra_args = args + [
"--outputDir",
# This environment variable is set by the adb_test_runner.go program.
"$ADB_TEST_OUTPUT_DIR",
- "--surfaceConfig",
- surface_config,
- ] + (["--via", via] if via else []),
- flags = flags,
+ ],
save_output_files = True, # Save any produced PNG and JSON files as undeclared outputs.
**kwargs
)