Enable S/R for all syscall tests.

Enable S/R by default for all syscall tests.

PiperOrigin-RevId: 607116892
This commit is contained in:
Nayana Bidari
2024-02-14 15:05:19 -08:00
committed by gVisor bot
parent f5462c934b
commit 568434b397
7 changed files with 315 additions and 114 deletions
+17 -2
View File
@@ -274,7 +274,7 @@ steps:
# All system call tests.
- <<: *common
label: ":toolbox: System call tests (AMD64)"
command: "make BAZEL_OPTIONS=--test_tag_filters=$SYSCALL_TEST_FILTERS syscall-tests"
command: make BAZEL_OPTIONS=--test_tag_filters=-allsave syscall-tests
parallelism: 20
agents:
<<: *platform_specific_agents
@@ -283,7 +283,22 @@ steps:
- <<: *common
<<: *source_test
label: ":muscle: System call tests (ARM64)"
command: make BAZEL_OPTIONS=--test_tag_filters=runsc_ptrace,runsc_systrap syscall-tests
command: make BAZEL_OPTIONS=--test_tag_filters=-allsave,runsc_ptrace,runsc_systrap syscall-tests
parallelism: 10
agents:
arch: "arm64"
# All S/R system call tests.
- <<: *common
<<: *source_test
label: ":muscle: System call save restore tests (AMD64)"
command: make BAZEL_OPTIONS=--test_tag_filters=save_restore syscall-tests
parallelism: 20
agents:
arch: "amd64"
- <<: *common
<<: *source_test
label: ":muscle: System call save restore tests (ARM64)"
command: make BAZEL_OPTIONS=--test_tag_filters=save_restore syscall-tests
parallelism: 10
agents:
arch: "arm64"
+50
View File
@@ -8,49 +8,67 @@ package(
syscall_test(
debug = False,
# Takes too long to run with S/R.
save = False,
test = "//test/perf/linux:clock_getres_benchmark",
)
syscall_test(
debug = False,
# Takes too long to run with S/R.
save = False,
test = "//test/perf/linux:clock_gettime_benchmark",
)
syscall_test(
debug = False,
# Takes too long to run with S/R.
save = False,
test = "//test/perf/linux:death_benchmark",
)
syscall_test(
debug = False,
# Takes too long to run with S/R.
save = False,
test = "//test/perf/linux:epoll_benchmark",
)
syscall_test(
debug = False,
# Takes too long to run with S/R.
save = False,
test = "//test/perf/linux:poll_benchmark",
)
syscall_test(
debug = False,
# Takes too long to run with S/R.
save = False,
test = "//test/perf/linux:select_benchmark",
)
syscall_test(
size = "large",
debug = False,
# Takes too long to run with S/R.
save = False,
test = "//test/perf/linux:fork_benchmark",
)
syscall_test(
size = "large",
debug = False,
# Takes too long to run with S/R.
save = False,
test = "//test/perf/linux:futex_benchmark",
)
syscall_test(
size = "large",
debug = False,
# Takes too long to run with S/R.
save = False,
shard_count = more_shards,
tags = ["nogotsan"],
test = "//test/perf/linux:getdents_benchmark",
@@ -59,12 +77,16 @@ syscall_test(
syscall_test(
size = "large",
debug = False,
# Takes too long to run with S/R.
save = False,
test = "//test/perf/linux:getpid_benchmark",
)
syscall_test(
size = "large",
debug = False,
# Takes too long to run with S/R.
save = False,
tags = ["nogotsan"],
test = "//test/perf/linux:gettid_benchmark",
)
@@ -72,6 +94,8 @@ syscall_test(
syscall_test(
size = "large",
debug = False,
# Takes too long to run with S/R.
save = False,
test = "//test/perf/linux:mapping_benchmark",
)
@@ -79,6 +103,8 @@ syscall_test(
size = "large",
add_overlay = True,
debug = False,
# Takes too long to run with S/R.
save = False,
test = "//test/perf/linux:open_benchmark",
)
@@ -86,11 +112,15 @@ syscall_test(
size = "large",
add_overlay = True,
debug = False,
# Takes too long to run with S/R.
save = False,
test = "//test/perf/linux:dup_benchmark",
)
syscall_test(
debug = False,
# Takes too long to run with S/R.
save = False,
test = "//test/perf/linux:pipe_benchmark",
)
@@ -98,6 +128,8 @@ syscall_test(
size = "large",
add_overlay = True,
debug = False,
# Takes too long to run with S/R.
save = False,
test = "//test/perf/linux:randread_benchmark",
)
@@ -105,18 +137,24 @@ syscall_test(
size = "large",
add_overlay = True,
debug = False,
# Takes too long to run with S/R.
save = False,
test = "//test/perf/linux:read_benchmark",
)
syscall_test(
size = "large",
debug = False,
# Takes too long to run with S/R.
save = False,
test = "//test/perf/linux:sched_yield_benchmark",
)
syscall_test(
size = "large",
debug = False,
# Takes too long to run with S/R.
save = False,
test = "//test/perf/linux:send_recv_benchmark",
)
@@ -124,17 +162,23 @@ syscall_test(
size = "large",
add_overlay = True,
debug = False,
# Takes too long to run with S/R.
save = False,
test = "//test/perf/linux:seqwrite_benchmark",
)
syscall_test(
size = "large",
debug = False,
# Takes too long to run with S/R.
save = False,
test = "//test/perf/linux:signal_benchmark",
)
syscall_test(
debug = False,
# Takes too long to run with S/R.
save = False,
test = "//test/perf/linux:sleep_benchmark",
)
@@ -142,6 +186,8 @@ syscall_test(
size = "large",
add_overlay = True,
debug = False,
# Takes too long to run with S/R.
save = False,
test = "//test/perf/linux:stat_benchmark",
)
@@ -149,6 +195,8 @@ syscall_test(
size = "large",
add_overlay = True,
debug = False,
# Takes too long to run with S/R.
save = False,
tags = ["nogotsan"],
test = "//test/perf/linux:unlink_benchmark",
)
@@ -157,5 +205,7 @@ syscall_test(
size = "large",
add_overlay = True,
debug = False,
# Takes too long to run with S/R.
save = False,
test = "//test/perf/linux:write_benchmark",
)
+206 -106
View File
@@ -1,6 +1,6 @@
"""Defines a rule for syscall test targets."""
load("//tools:defs.bzl", "default_platform", "platform_capabilities", "platforms")
load("//tools:defs.bzl", "default_platform", "platform_capabilities", "platforms", "save_restore_platforms")
# Maps platform names to a GVISOR_PLATFORM_SUPPORT environment variable consumed by platform_util.cc
_platform_support_env_vars = {
@@ -106,6 +106,11 @@ def _syscall_test(
tags = list(tags)
tags += [full_platform, "file_" + file_access]
if save:
tags.append("allsave")
if platform in save_restore_platforms:
tags.append("save_restore")
# Hash this target into one of 15 buckets. This can be used to
# randomly split targets between different workflows.
hash15 = hash(native.package_name() + name) % 15
@@ -178,6 +183,157 @@ def all_platforms():
available[default_platform] = platforms.get(default_platform, [])
return available.items()
def syscall_test_variants(
test,
use_tmpfs = False,
add_fusefs = False,
add_overlay = False,
add_host_uds = False,
add_host_connector = False,
add_host_fifo = False,
add_hostinet = False,
add_directfs = True,
one_sandbox = True,
iouring = False,
allow_native = True,
leak_check = True,
debug = True,
container = None,
tags = None,
save = False,
size = "medium",
timeout = None,
**kwargs):
"""Generates syscall tests for all variants.
Args:
test: the test target.
use_tmpfs: use tmpfs in the defined tests.
add_fusefs: add a fusefs test.
add_overlay: add an overlay test.
add_host_uds: setup bound UDS on the host.
add_host_connector: setup host threads to connect to bound UDS created by sandbox.
add_host_fifo: setup FIFO files on the host.
add_hostinet: add a hostinet test.
add_directfs: add a directfs test.
one_sandbox: runs each unit test in a new sandbox instance.
iouring: enable IO_URING support.
allow_native: generate a native test variant.
debug: enable debug output.
container: Run the test in a container. If None, determined from other information.
tags: starting test tags.
leak_check: enables leak check.
save: save restore test.
size: test size.
timeout: timeout for the test.
**kwargs: additional test arguments.
"""
for platform, platform_tags in all_platforms():
# Add directfs to the default platform variant.
directfs = add_directfs and platform == default_platform
_syscall_test(
test = test,
platform = platform,
use_tmpfs = use_tmpfs,
add_host_uds = add_host_uds,
add_host_connector = add_host_connector,
add_host_fifo = add_host_fifo,
tags = platform_tags + tags,
iouring = iouring,
directfs = directfs,
debug = debug,
container = container,
one_sandbox = one_sandbox,
leak_check = leak_check,
save = save,
size = size,
timeout = timeout,
**kwargs
)
if add_overlay:
_syscall_test(
test = test,
platform = default_platform,
use_tmpfs = use_tmpfs,
add_host_uds = add_host_uds,
add_host_connector = add_host_connector,
add_host_fifo = add_host_fifo,
tags = platforms.get(default_platform, []) + tags,
debug = debug,
iouring = iouring,
container = container,
one_sandbox = one_sandbox,
overlay = True,
leak_check = leak_check,
save = save,
size = size,
timeout = timeout,
**kwargs
)
# TODO(b/192114729): hostinet is not supported with S/R.
if add_hostinet and not save:
_syscall_test(
test = test,
platform = default_platform,
use_tmpfs = use_tmpfs,
network = "host",
add_host_uds = add_host_uds,
add_host_connector = add_host_connector,
add_host_fifo = add_host_fifo,
tags = platforms.get(default_platform, []) + tags,
debug = debug,
iouring = iouring,
container = container,
one_sandbox = one_sandbox,
leak_check = leak_check,
save = save,
size = size,
timeout = timeout,
**kwargs
)
if not use_tmpfs:
# Also test shared gofer access.
_syscall_test(
test = test,
platform = default_platform,
use_tmpfs = use_tmpfs,
add_host_uds = add_host_uds,
add_host_connector = add_host_connector,
add_host_fifo = add_host_fifo,
tags = platforms.get(default_platform, []) + tags,
iouring = iouring,
debug = debug,
container = container,
one_sandbox = one_sandbox,
file_access = "shared",
leak_check = leak_check,
save = save,
size = size,
timeout = timeout,
**kwargs
)
if add_fusefs:
_syscall_test(
test = test,
platform = default_platform,
use_tmpfs = True,
fusefs = True,
add_host_uds = add_host_uds,
add_host_connector = add_host_connector,
add_host_fifo = add_host_fifo,
tags = platforms.get(default_platform, []) + tags,
debug = debug,
container = container,
one_sandbox = one_sandbox,
leak_check = leak_check,
save = save,
size = size,
timeout = timeout,
**kwargs
)
def syscall_test(
test,
use_tmpfs = False,
@@ -195,8 +351,8 @@ def syscall_test(
debug = True,
container = None,
tags = None,
#TODO(b/323000153): Change save to True after all the tests pass with S/R enabled.
save = False,
save = True,
size = "medium",
**kwargs):
"""syscall_test is a macro that will create targets for all platforms.
@@ -218,6 +374,7 @@ def syscall_test(
tags: starting test tags.
leak_check: enables leak check.
save: save restore test.
size: test size.
**kwargs: additional test arguments.
"""
if not tags:
@@ -239,108 +396,51 @@ def syscall_test(
**kwargs
)
for platform, platform_tags in all_platforms():
# Add directfs to the default platform variant.
directfs = add_directfs and platform == default_platform
_syscall_test(
test = test,
platform = platform,
use_tmpfs = use_tmpfs,
add_host_uds = add_host_uds,
add_host_connector = add_host_connector,
add_host_fifo = add_host_fifo,
tags = platform_tags + tags,
iouring = iouring,
directfs = directfs,
debug = debug,
container = container,
one_sandbox = one_sandbox,
leak_check = leak_check,
**kwargs
)
syscall_test_variants(
test,
use_tmpfs,
add_fusefs,
add_overlay,
add_host_uds,
add_host_connector,
add_host_fifo,
add_hostinet,
add_directfs,
one_sandbox,
iouring,
allow_native,
leak_check,
debug,
container,
tags,
False, # save, generate all tests without save variant.
size,
**kwargs
)
if add_overlay:
_syscall_test(
test = test,
platform = default_platform,
use_tmpfs = use_tmpfs,
add_host_uds = add_host_uds,
add_host_connector = add_host_connector,
add_host_fifo = add_host_fifo,
tags = platforms.get(default_platform, []) + tags,
debug = debug,
iouring = iouring,
container = container,
one_sandbox = one_sandbox,
overlay = True,
leak_check = leak_check,
**kwargs
)
if add_hostinet:
_syscall_test(
test = test,
platform = default_platform,
use_tmpfs = use_tmpfs,
network = "host",
add_host_uds = add_host_uds,
add_host_connector = add_host_connector,
add_host_fifo = add_host_fifo,
tags = platforms.get(default_platform, []) + tags,
debug = debug,
iouring = iouring,
container = container,
one_sandbox = one_sandbox,
leak_check = leak_check,
**kwargs
)
if not use_tmpfs:
# Also test shared gofer access.
_syscall_test(
test = test,
platform = default_platform,
use_tmpfs = use_tmpfs,
add_host_uds = add_host_uds,
add_host_connector = add_host_connector,
add_host_fifo = add_host_fifo,
tags = platforms.get(default_platform, []) + tags,
iouring = iouring,
debug = debug,
container = container,
one_sandbox = one_sandbox,
file_access = "shared",
leak_check = leak_check,
**kwargs
)
if add_fusefs:
_syscall_test(
test = test,
platform = default_platform,
use_tmpfs = True,
fusefs = True,
add_host_uds = add_host_uds,
add_host_connector = add_host_connector,
add_host_fifo = add_host_fifo,
tags = platforms.get(default_platform, []) + tags,
debug = debug,
container = container,
one_sandbox = one_sandbox,
leak_check = leak_check,
**kwargs
)
# Add save variant to all other variants generated above.
if save:
for platform, platform_tags in all_platforms():
_syscall_test(
test = test,
platform = platform,
use_tmpfs = True,
save = True,
add_host_uds = add_host_uds,
add_host_connector = add_host_connector,
add_host_fifo = add_host_fifo,
tags = platform_tags,
debug = debug,
container = container,
one_sandbox = one_sandbox,
leak_check = leak_check,
**kwargs
)
# Disable go sanitizers for save tests.
tags.append("nogotsan")
syscall_test_variants(
test,
use_tmpfs,
add_fusefs,
add_overlay,
add_host_uds,
add_host_connector,
add_host_fifo,
add_hostinet,
add_directfs,
one_sandbox,
iouring,
allow_native,
leak_check,
debug,
container,
tags,
True, # save, generate all tests with save variant.
"large", # size, use size as large by default for all S/R tests.
"long", # timeout, use long timeout for S/R tests.
**kwargs
)
+6 -2
View File
@@ -543,6 +543,8 @@ func runRunsc(tc *gtest.TestCase, spec *specs.Spec) error {
// Delete the existing sandbox.
if err := deleteSandbox(saveArgs, id); err != nil {
printAll(dirs)
removeAll(dirs)
return fmt.Errorf("deleteSandbox error %v", err)
}
@@ -550,6 +552,8 @@ func runRunsc(tc *gtest.TestCase, spec *specs.Spec) error {
restoreArgs := saveArgs
restoreArgs, dirs, err = prepareSave(restoreArgs, undeclaredOutputsDir, dirs, i)
if err != nil {
printAll(dirs)
removeAll(dirs)
return fmt.Errorf("prepareSave error: %v", err)
}
restoreArgs = append(restoreArgs, "restore", "--image-path", dirs[i-1], "--bundle", bundleDir, id)
@@ -568,8 +572,8 @@ func runRunsc(tc *gtest.TestCase, spec *specs.Spec) error {
return fmt.Errorf("after restore error: %v", err)
}
}
printAll(dirs)
defer removeAll(dirs)
// Do not output state files when the test succeeds.
removeAll(dirs)
} else {
err = cmd.Run()
if *waitForPid != 0 {
+33 -3
View File
@@ -61,7 +61,6 @@ syscall_test(
)
syscall_test(
save = True,
test = "//test/syscalls/linux:brk_test",
)
@@ -126,6 +125,8 @@ syscall_test(
# TODO(b/318948806): lisafs.BoundSocketFD is leaked.
leak_check = False,
one_sandbox = False,
# Takes too long to run with S/R.
save = False,
test = "//test/syscalls/linux:bind_external_test",
# Shared mode tests replace /tmp which hides the files created for
# add_host_connector. use_tmpfs makes shared mode be skipped.
@@ -138,6 +139,8 @@ syscall_test(
# TODO(b/318948806): lisafs.BoundSocketFD is leaked.
leak_check = False,
one_sandbox = False,
# Takes too long to run with S/R.
save = False,
test = "//test/syscalls/linux:connect_external_test",
# Shared mode tests replace /tmp which hides the files created for
# add_host_uds. use_tmpfs makes shared mode be skipped.
@@ -147,6 +150,8 @@ syscall_test(
syscall_test(
add_host_fifo = True,
one_sandbox = False,
# Takes too long to run with S/R.
save = False,
test = "//test/syscalls/linux:pipe_external_test",
# Shared mode tests replace /tmp which hides the files created for
# add_host_fifo. use_tmpfs makes shared mode be skipped.
@@ -272,6 +277,7 @@ syscall_test(
syscall_test(
add_overlay = True,
shard_count = most_shards,
test = "//test/syscalls/linux:getdents_test",
)
@@ -393,6 +399,8 @@ syscall_test(
syscall_test(
add_overlay = True,
# TODO(b/323000153): Enable S/R only for the overlay variant.
save = False,
test = "//test/syscalls/linux:mount_test",
)
@@ -516,6 +524,7 @@ syscall_test(
syscall_test(
size = "medium",
shard_count = most_shards,
test = "//test/syscalls/linux:proc_test",
)
@@ -757,6 +766,8 @@ syscall_test(
syscall_test(
size = "large",
add_hostinet = True,
# Takes too long to run with S/R.
save = False,
shard_count = most_shards,
test = "//test/syscalls/linux:socket_inet_loopback_test",
)
@@ -794,6 +805,7 @@ syscall_test(
syscall_test(
size = "medium",
add_hostinet = True,
shard_count = most_shards,
test = "//test/syscalls/linux:socket_ip_tcp_loopback_non_blocking_test",
)
@@ -853,6 +865,8 @@ syscall_test(
syscall_test(
add_hostinet = True,
# FIXME(b/323000153): These tests fail with S/R, fix them and then enable.
save = False,
test = "//test/syscalls/linux:socket_ipv4_udp_unbound_loopback_netlink_test",
)
@@ -947,6 +961,8 @@ syscall_test(
syscall_test(
size = "large",
add_hostinet = True,
# Takes too long to run with S/R.
save = False,
shard_count = most_shards,
test = "//test/syscalls/linux:socket_stress_test",
)
@@ -958,6 +974,8 @@ syscall_test(
syscall_test(
flaky = 1, # NOTE(b/116636318): Large sendmsg may stall a long time.
# Takes too long to run with S/R.
save = False,
shard_count = more_shards,
test = "//test/syscalls/linux:socket_unix_dgram_local_test",
)
@@ -976,17 +994,23 @@ syscall_test(
syscall_test(
flaky = 1, # NOTE(b/116636318): Large sendmsg may stall a long time.
# Takes too long to run with S/R.
save = False,
shard_count = more_shards,
test = "//test/syscalls/linux:socket_unix_seqpacket_local_test",
)
syscall_test(
size = "medium",
shard_count = most_shards,
test = "//test/syscalls/linux:socket_unix_stream_test",
)
syscall_test(
size = "medium",
# TODO(b/323000153): Test fails with S/R enabled during restore of abstract
# sockets. Fix this and then enable S/R.
save = False,
test = "//test/syscalls/linux:socket_unix_unbound_abstract_test",
)
@@ -1022,6 +1046,8 @@ syscall_test(
syscall_test(
add_fusefs = True,
add_overlay = True,
# TODO(b/323000153): Enable S/R only for the overlay variant.
save = False,
test = "//test/syscalls/linux:stat_test",
)
@@ -1033,6 +1059,7 @@ syscall_test(
syscall_test(
add_overlay = True,
save = False,
test = "//test/syscalls/linux:sticky_test",
)
@@ -1103,6 +1130,8 @@ syscall_test(
syscall_test(
# TODO(b/318948806): tun.tunEndpoint is leaked.
leak_check = False,
# TODO(b/110961832): /dev/net/tun does not support S/R.
save = False,
test = "//test/syscalls/linux:tuntap_test",
)
@@ -1176,12 +1205,10 @@ syscall_test(
syscall_test(
add_fusefs = True,
add_overlay = True,
save = True,
test = "//test/syscalls/linux:write_test",
)
syscall_test(
save = True,
test = "//test/syscalls/linux:proc_net_unix_test",
)
@@ -1203,10 +1230,13 @@ syscall_test(
)
syscall_test(
save = False,
test = "//test/syscalls/linux:deleted_test",
)
syscall_test(
size = "small",
# FIXME(b/323000153): These tests fail with S/R, fix them and then enable.
save = False,
test = "//test/syscalls/linux:close_range_test",
)
+1
View File
@@ -42,3 +42,4 @@ platform_capabilities = {
}
default_platform = "systrap"
save_restore_platforms = ["systrap"]
+2 -1
View File
@@ -11,7 +11,7 @@ load("//tools/bazeldefs:cc.bzl", _cc_binary = "cc_binary", _cc_flags_supplier =
load("//tools/bazeldefs:defs.bzl", _BuildSettingInfo = "BuildSettingInfo", _bool_flag = "bool_flag", _bpf_program = "bpf_program", _build_test = "build_test", _bzl_library = "bzl_library", _coreutil = "coreutil", _default_net_util = "default_net_util", _more_shards = "more_shards", _most_shards = "most_shards", _proto_library = "proto_library", _select_system = "select_system", _short_path = "short_path", _version = "version")
load("//tools/bazeldefs:go.bzl", _gazelle = "gazelle", _go_binary = "go_binary", _go_grpc_and_proto_libraries = "go_grpc_and_proto_libraries", _go_library = "go_library", _go_path = "go_path", _go_proto_library = "go_proto_library", _go_test = "go_test", _gotsan_flag_values = "gotsan_flag_values", _gotsan_values = "gotsan_values", _select_goarch = "select_goarch", _select_goos = "select_goos")
load("//tools/bazeldefs:pkg.bzl", _pkg_deb = "pkg_deb", _pkg_tar = "pkg_tar")
load("//tools/bazeldefs:platforms.bzl", _default_platform = "default_platform", _platform_capabilities = "platform_capabilities", _platforms = "platforms")
load("//tools/bazeldefs:platforms.bzl", _default_platform = "default_platform", _platform_capabilities = "platform_capabilities", _platforms = "platforms", _save_restore_platforms = "save_restore_platforms")
load("//tools/bazeldefs:tags.bzl", "go_suffixes")
load("//tools/nogo:defs.bzl", "nogo_test")
@@ -62,6 +62,7 @@ pkg_tar = _pkg_tar
default_platform = _default_platform
platforms = _platforms
platform_capabilities = _platform_capabilities
save_restore_platforms = _save_restore_platforms
def go_binary(name, nogo = True, pure = False, static = False, x_defs = None, **kwargs):
"""Wraps the standard go_binary.