Skip to content

Commit

Permalink
Add tests with netstack s/r enabled.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 722790574
  • Loading branch information
nybidari authored and gvisor-bot committed Feb 3, 2025
1 parent bd0dbf9 commit f6b843d
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 0 deletions.
40 changes: 40 additions & 0 deletions test/runner/defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ def _syscall_test(
leak_check = False,
save = False,
save_resume = False,
netstack_sr = False,
**kwargs):
# Prepend "runsc" to non-native platform names.
full_platform = platform if platform == "native" else "runsc_" + platform
Expand All @@ -99,6 +100,8 @@ def _syscall_test(
name += "_save"
if save_resume:
name += "_save_resume"
if save and netstack_sr:
name += "_netstack_save"

# Apply all tags.
if tags == None:
Expand Down Expand Up @@ -169,6 +172,7 @@ def _syscall_test(
"--leak-check=" + str(leak_check),
"--save=" + str(save),
"--save-resume=" + str(save_resume),
"--netstack-sr=" + str(netstack_sr),
]

# Trace points are platform agnostic, so enable them for ptrace only.
Expand Down Expand Up @@ -212,6 +216,7 @@ def syscall_test_variants(
size = "medium",
timeout = None,
overlay = False,
netstack_sr = False,
**kwargs):
"""Generates syscall tests for all variants.
Expand Down Expand Up @@ -260,6 +265,7 @@ def syscall_test_variants(
size = size,
timeout = timeout,
overlay = overlay,
netstack_sr = netstack_sr,
**kwargs
)

Expand All @@ -282,6 +288,7 @@ def syscall_test_variants(
save_resume = save_resume,
size = size,
timeout = timeout,
netstack_sr = netstack_sr,
**kwargs
)

Expand All @@ -305,6 +312,7 @@ def syscall_test_variants(
save_resume = save_resume,
size = size,
timeout = timeout,
netstack_sr = netstack_sr,
**kwargs
)
if not use_tmpfs:
Expand All @@ -327,6 +335,7 @@ def syscall_test_variants(
save_resume = save_resume,
size = size,
timeout = timeout,
netstack_sr = netstack_sr,
**kwargs
)
if add_fusefs:
Expand All @@ -347,6 +356,7 @@ def syscall_test_variants(
save_resume = save_resume,
size = size,
timeout = timeout,
netstack_sr = netstack_sr,
**kwargs
)

Expand All @@ -370,6 +380,7 @@ def syscall_test(
save = True,
size = "medium",
overlay = False,
netstack_sr = False,
**kwargs):
"""syscall_test is a macro that will create targets for all platforms.
Expand Down Expand Up @@ -434,6 +445,7 @@ def syscall_test(
False, # save_resume, generate all tests without save_resume variant.
size,
overlay = overlay,
netstack_sr = False,
**kwargs
)

Expand Down Expand Up @@ -462,9 +474,36 @@ def syscall_test(
False, # save_resume, generate all tests without save_resume variant.
"large", # size, use size as large by default for all S/R tests.
"long", # timeout, use long timeout for S/R tests.
netstack_sr = False,
**kwargs
)

if netstack_sr:
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.
False, # save_resume, generate all tests without save_resume variant.
"large", # size, use size as large by default for all S/R tests.
"long", # timeout, use long timeout for S/R tests.
netstack_sr = True, # netstack_sr, generate all tests with netstack s/r.
**kwargs
)

# Add save resume variant to all other variants generated above.
syscall_test_variants(
test,
Expand All @@ -487,5 +526,6 @@ def syscall_test(
True, # save_resume, generate all tests with save_resume variant.
"large", # size, use size as large by default for all S/R tests.
"long", # timeout, use long timeout for S/R tests.
netstack_sr = False,
**kwargs
)
4 changes: 4 additions & 0 deletions test/runner/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ var (
waitForPid = flag.Duration("delay-for-debugger", 0, "Print out the sandbox PID and wait for the specified duration to start the test. This is useful for attaching a debugger to the runsc-sandbox process.")
save = flag.Bool("save", false, "enables save restore")
saveResume = flag.Bool("save-resume", false, "enables save resume")
netstackSR = flag.Bool("netstack-sr", false, "enables netstack s/r")
)

const (
Expand Down Expand Up @@ -406,6 +407,9 @@ func runRunsc(tc *gtest.TestCase, spec *specs.Spec) error {

// Create the state file.
if *save || *saveResume {
if *netstackSR {
args = append(args, "--TESTONLY-save-restore-netstack=true")
}
saveArgs = args
args, dirs, err = prepareSave(args, undeclaredOutputsDir, dirs, 0)
if err != nil {
Expand Down
9 changes: 9 additions & 0 deletions test/syscalls/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,7 @@ syscall_test(

syscall_test(
add_hostinet = True,
netstack_sr = True,
test = "//test/syscalls/linux:network_namespace_test",
)

Expand All @@ -457,6 +458,7 @@ syscall_test(

syscall_test(
add_hostinet = True,
netstack_sr = True,
test = "//test/syscalls/linux:packet_socket_dgram_test",
)

Expand Down Expand Up @@ -807,12 +809,14 @@ syscall_test(

syscall_test(
add_hostinet = True,
netstack_sr = True,
test = "//test/syscalls/linux:socket_ipv4_udp_unbound_external_networking_test",
)

syscall_test(
size = "large",
add_hostinet = True,
netstack_sr = True,
shard_count = most_shards,
test = "//test/syscalls/linux:socket_ip_tcp_generic_loopback_test",
)
Expand Down Expand Up @@ -893,6 +897,7 @@ syscall_test(

syscall_test(
add_hostinet = True,
netstack_sr = True,
test = "//test/syscalls/linux:socket_ipv6_udp_unbound_loopback_netlink_test",
)

Expand All @@ -913,6 +918,7 @@ syscall_test(

syscall_test(
add_hostinet = True,
netstack_sr = True,
test = "//test/syscalls/linux:socket_ip_unbound_netlink_test",
)

Expand Down Expand Up @@ -1023,6 +1029,7 @@ syscall_test(

syscall_test(
size = "medium",
netstack_sr = True,
shard_count = most_shards,
test = "//test/syscalls/linux:socket_unix_stream_test",
)
Expand Down Expand Up @@ -1171,12 +1178,14 @@ syscall_test(
syscall_test(
size = "medium",
add_hostinet = True,
netstack_sr = True,
shard_count = more_shards,
test = "//test/syscalls/linux:udp_socket_test",
)

syscall_test(
add_hostinet = True,
netstack_sr = True,
test = "//test/syscalls/linux:udp_raw_socket_test",
)

Expand Down

0 comments on commit f6b843d

Please sign in to comment.