summaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/benchmarks/base/BUILD1
-rw-r--r--test/benchmarks/database/BUILD1
-rw-r--r--test/benchmarks/fs/BUILD1
-rw-r--r--test/benchmarks/media/BUILD1
-rw-r--r--test/benchmarks/ml/BUILD1
-rw-r--r--test/benchmarks/network/BUILD1
-rw-r--r--test/e2e/integration_test.go7
-rw-r--r--test/fuse/linux/fuse_base.cc2
-rw-r--r--test/runner/defs.bzl2
-rw-r--r--test/runner/gtest/gtest.go8
-rw-r--r--test/runner/runner.go31
-rw-r--r--test/syscalls/BUILD192
-rw-r--r--test/syscalls/linux/socket_ipv4_udp_unbound.cc100
13 files changed, 136 insertions, 212 deletions
diff --git a/test/benchmarks/base/BUILD b/test/benchmarks/base/BUILD
index 5e099d0f9..32c139204 100644
--- a/test/benchmarks/base/BUILD
+++ b/test/benchmarks/base/BUILD
@@ -25,6 +25,7 @@ go_test(
"manual",
"local",
],
+ visibility = ["//:sandbox"],
deps = [
"//pkg/test/dockerutil",
"//test/benchmarks/harness",
diff --git a/test/benchmarks/database/BUILD b/test/benchmarks/database/BUILD
index 6139f6e8a..93b380e8a 100644
--- a/test/benchmarks/database/BUILD
+++ b/test/benchmarks/database/BUILD
@@ -19,6 +19,7 @@ go_test(
"manual",
"local",
],
+ visibility = ["//:sandbox"],
deps = [
"//pkg/test/dockerutil",
"//test/benchmarks/harness",
diff --git a/test/benchmarks/fs/BUILD b/test/benchmarks/fs/BUILD
index 20654d88f..45f11372b 100644
--- a/test/benchmarks/fs/BUILD
+++ b/test/benchmarks/fs/BUILD
@@ -22,6 +22,7 @@ go_test(
"local",
"manual",
],
+ visibility = ["//:sandbox"],
deps = [
"//pkg/test/dockerutil",
"//test/benchmarks/harness",
diff --git a/test/benchmarks/media/BUILD b/test/benchmarks/media/BUILD
index 6c41fc4f6..bb242d385 100644
--- a/test/benchmarks/media/BUILD
+++ b/test/benchmarks/media/BUILD
@@ -14,6 +14,7 @@ go_test(
size = "large",
srcs = ["ffmpeg_test.go"],
library = ":media",
+ visibility = ["//:sandbox"],
deps = [
"//pkg/test/dockerutil",
"//test/benchmarks/harness",
diff --git a/test/benchmarks/ml/BUILD b/test/benchmarks/ml/BUILD
index 2430b60a7..970f52706 100644
--- a/test/benchmarks/ml/BUILD
+++ b/test/benchmarks/ml/BUILD
@@ -14,6 +14,7 @@ go_test(
size = "large",
srcs = ["tensorflow_test.go"],
library = ":ml",
+ visibility = ["//:sandbox"],
deps = [
"//pkg/test/dockerutil",
"//test/benchmarks/harness",
diff --git a/test/benchmarks/network/BUILD b/test/benchmarks/network/BUILD
index df5ff7265..bd3f6245c 100644
--- a/test/benchmarks/network/BUILD
+++ b/test/benchmarks/network/BUILD
@@ -25,6 +25,7 @@ go_test(
"manual",
"local",
],
+ visibility = ["//:sandbox"],
deps = [
"//pkg/test/dockerutil",
"//pkg/test/testutil",
diff --git a/test/e2e/integration_test.go b/test/e2e/integration_test.go
index 71ec4791e..809244bab 100644
--- a/test/e2e/integration_test.go
+++ b/test/e2e/integration_test.go
@@ -167,6 +167,13 @@ func TestCheckpointRestore(t *testing.T) {
t.Skip("Pause/resume is not supported.")
}
+ // TODO(gvisor.dev/issue/3373): Remove after implementing.
+ if usingVFS2, err := dockerutil.UsingVFS2(); usingVFS2 {
+ t.Skip("CheckpointRestore not implemented in VFS2.")
+ } else if err != nil {
+ t.Fatalf("failed to read config for runtime %s: %v", dockerutil.Runtime(), err)
+ }
+
ctx := context.Background()
d := dockerutil.MakeContainer(ctx, t)
defer d.CleanUp(ctx)
diff --git a/test/fuse/linux/fuse_base.cc b/test/fuse/linux/fuse_base.cc
index 4a2c64998..9c3124472 100644
--- a/test/fuse/linux/fuse_base.cc
+++ b/test/fuse/linux/fuse_base.cc
@@ -25,8 +25,8 @@
#include <iostream>
-#include "absl/strings/str_format.h"
#include "gtest/gtest.h"
+#include "absl/strings/str_format.h"
#include "test/util/posix_error.h"
#include "test/util/temp_path.h"
#include "test/util/test_util.h"
diff --git a/test/runner/defs.bzl b/test/runner/defs.bzl
index 1ae13a4a5..2d64934b0 100644
--- a/test/runner/defs.bzl
+++ b/test/runner/defs.bzl
@@ -132,7 +132,7 @@ def syscall_test(
add_overlay = False,
add_uds_tree = False,
add_hostinet = False,
- vfs2 = False,
+ vfs2 = True,
fuse = False,
tags = None):
"""syscall_test is a macro that will create targets for all platforms.
diff --git a/test/runner/gtest/gtest.go b/test/runner/gtest/gtest.go
index 869169ad5..e4445e01b 100644
--- a/test/runner/gtest/gtest.go
+++ b/test/runner/gtest/gtest.go
@@ -146,10 +146,13 @@ func ParseTestCases(testBin string, benchmarks bool, extraArgs ...string) ([]Tes
return nil, fmt.Errorf("could not enumerate gtest benchmarks: %v\nstderr\n%s", err, exitErr.Stderr)
}
- out = []byte(strings.Trim(string(out), "\n"))
+ benches := strings.Trim(string(out), "\n")
+ if len(benches) == 0 {
+ return t, nil
+ }
// Parse benchmark output.
- for _, line := range strings.Split(string(out), "\n") {
+ for _, line := range strings.Split(benches, "\n") {
// Strip comments.
line = strings.Split(line, "#")[0]
@@ -163,6 +166,5 @@ func ParseTestCases(testBin string, benchmarks bool, extraArgs ...string) ([]Tes
benchmark: true,
})
}
-
return t, nil
}
diff --git a/test/runner/runner.go b/test/runner/runner.go
index bc4b39cbb..5ac91310d 100644
--- a/test/runner/runner.go
+++ b/test/runner/runner.go
@@ -172,13 +172,14 @@ func runRunsc(tc gtest.TestCase, spec *specs.Spec) error {
args = append(args, "-fsgofer-host-uds")
}
- undeclaredOutputsDir, ok := syscall.Getenv("TEST_UNDECLARED_OUTPUTS_DIR")
- if ok {
- tdir := filepath.Join(undeclaredOutputsDir, strings.Replace(name, "/", "_", -1))
- if err := os.MkdirAll(tdir, 0755); err != nil {
+ testLogDir := ""
+ if undeclaredOutputsDir, ok := syscall.Getenv("TEST_UNDECLARED_OUTPUTS_DIR"); ok {
+ // Create log directory dedicated for this test.
+ testLogDir = filepath.Join(undeclaredOutputsDir, strings.Replace(name, "/", "_", -1))
+ if err := os.MkdirAll(testLogDir, 0755); err != nil {
return fmt.Errorf("could not create test dir: %v", err)
}
- debugLogDir, err := ioutil.TempDir(tdir, "runsc")
+ debugLogDir, err := ioutil.TempDir(testLogDir, "runsc")
if err != nil {
return fmt.Errorf("could not create temp dir: %v", err)
}
@@ -227,10 +228,10 @@ func runRunsc(tc gtest.TestCase, spec *specs.Spec) error {
dArgs := append([]string{}, args...)
dArgs = append(dArgs, "-alsologtostderr=true", "debug", "--stacks", id)
go func(dArgs []string) {
- cmd := exec.Command(*runscPath, dArgs...)
- cmd.Stdout = os.Stdout
- cmd.Stderr = os.Stderr
- cmd.Run()
+ debug := exec.Command(*runscPath, dArgs...)
+ debug.Stdout = os.Stdout
+ debug.Stderr = os.Stderr
+ debug.Run()
done <- true
}(dArgs)
@@ -245,17 +246,17 @@ func runRunsc(tc gtest.TestCase, spec *specs.Spec) error {
dArgs = append(args, "debug",
fmt.Sprintf("--signal=%d", syscall.SIGTERM),
id)
- cmd := exec.Command(*runscPath, dArgs...)
- cmd.Stdout = os.Stdout
- cmd.Stderr = os.Stderr
- cmd.Run()
+ signal := exec.Command(*runscPath, dArgs...)
+ signal.Stdout = os.Stdout
+ signal.Stderr = os.Stderr
+ signal.Run()
}()
err = cmd.Run()
- if err == nil {
+ if err == nil && len(testLogDir) > 0 {
// If the test passed, then we erase the log directory. This speeds up
// uploading logs in continuous integration & saves on disk space.
- os.RemoveAll(undeclaredOutputsDir)
+ os.RemoveAll(testLogDir)
}
return err
diff --git a/test/syscalls/BUILD b/test/syscalls/BUILD
index a31612b41..571785ad2 100644
--- a/test/syscalls/BUILD
+++ b/test/syscalls/BUILD
@@ -4,75 +4,62 @@ package(licenses = ["notice"])
syscall_test(
test = "//test/syscalls/linux:32bit_test",
- vfs2 = "True",
)
syscall_test(
test = "//test/syscalls/linux:accept_bind_stream_test",
- vfs2 = "True",
)
syscall_test(
size = "large",
shard_count = 50,
test = "//test/syscalls/linux:accept_bind_test",
- vfs2 = "True",
)
syscall_test(
add_overlay = True,
test = "//test/syscalls/linux:access_test",
- vfs2 = "True",
)
syscall_test(
test = "//test/syscalls/linux:affinity_test",
- vfs2 = "True",
)
syscall_test(
add_overlay = True,
test = "//test/syscalls/linux:aio_test",
- vfs2 = "True",
)
syscall_test(
size = "medium",
shard_count = 5,
test = "//test/syscalls/linux:alarm_test",
- vfs2 = "True",
)
syscall_test(
test = "//test/syscalls/linux:arch_prctl_test",
- vfs2 = "True",
)
syscall_test(
test = "//test/syscalls/linux:bad_test",
- vfs2 = "True",
)
syscall_test(
size = "large",
add_overlay = True,
test = "//test/syscalls/linux:bind_test",
- vfs2 = "True",
)
syscall_test(
test = "//test/syscalls/linux:brk_test",
- vfs2 = "True",
)
syscall_test(
test = "//test/syscalls/linux:socket_test",
- vfs2 = "True",
)
syscall_test(
test = "//test/syscalls/linux:socket_capability_test",
- vfs2 = "True",
)
syscall_test(
@@ -82,19 +69,16 @@ syscall_test(
# involve much concurrency, TSAN's usefulness here is limited anyway.
tags = ["nogotsan"],
test = "//test/syscalls/linux:socket_stress_test",
- vfs2 = "True",
)
syscall_test(
add_overlay = True,
test = "//test/syscalls/linux:chdir_test",
- vfs2 = "True",
)
syscall_test(
add_overlay = True,
test = "//test/syscalls/linux:chmod_test",
- vfs2 = "True",
)
syscall_test(
@@ -102,116 +86,96 @@ syscall_test(
add_overlay = True,
test = "//test/syscalls/linux:chown_test",
use_tmpfs = True, # chwon tests require gofer to be running as root.
- vfs2 = "True",
)
syscall_test(
add_overlay = True,
test = "//test/syscalls/linux:chroot_test",
- vfs2 = "True",
)
syscall_test(
test = "//test/syscalls/linux:clock_getres_test",
- vfs2 = "True",
)
syscall_test(
size = "medium",
test = "//test/syscalls/linux:clock_gettime_test",
- vfs2 = "True",
)
syscall_test(
test = "//test/syscalls/linux:clock_nanosleep_test",
- vfs2 = "True",
)
syscall_test(
test = "//test/syscalls/linux:concurrency_test",
- vfs2 = "True",
)
syscall_test(
add_uds_tree = True,
test = "//test/syscalls/linux:connect_external_test",
use_tmpfs = True,
- vfs2 = "True",
)
syscall_test(
add_overlay = True,
test = "//test/syscalls/linux:creat_test",
- vfs2 = "True",
)
syscall_test(
fuse = "True",
test = "//test/syscalls/linux:dev_test",
- vfs2 = "True",
)
syscall_test(
add_overlay = True,
test = "//test/syscalls/linux:dup_test",
- vfs2 = "True",
)
syscall_test(
test = "//test/syscalls/linux:epoll_test",
- vfs2 = "True",
)
syscall_test(
test = "//test/syscalls/linux:eventfd_test",
- vfs2 = "True",
)
syscall_test(
test = "//test/syscalls/linux:exceptions_test",
- vfs2 = "True",
)
syscall_test(
size = "medium",
add_overlay = True,
test = "//test/syscalls/linux:exec_test",
- vfs2 = "True",
)
syscall_test(
size = "medium",
add_overlay = True,
test = "//test/syscalls/linux:exec_binary_test",
- vfs2 = "True",
)
syscall_test(
test = "//test/syscalls/linux:exit_test",
- vfs2 = "True",
)
syscall_test(
add_overlay = True,
test = "//test/syscalls/linux:fadvise64_test",
- vfs2 = "True",
)
syscall_test(
add_overlay = True,
test = "//test/syscalls/linux:fallocate_test",
- vfs2 = "True",
)
syscall_test(
test = "//test/syscalls/linux:fault_test",
- vfs2 = "True",
)
syscall_test(
add_overlay = True,
test = "//test/syscalls/linux:fchdir_test",
- vfs2 = "True",
)
syscall_test(
@@ -223,204 +187,168 @@ syscall_test(
size = "medium",
add_overlay = True,
test = "//test/syscalls/linux:flock_test",
- vfs2 = "True",
)
syscall_test(
test = "//test/syscalls/linux:fork_test",
- vfs2 = "True",
)
syscall_test(
test = "//test/syscalls/linux:fpsig_fork_test",
- vfs2 = "True",
)
syscall_test(
test = "//test/syscalls/linux:fpsig_nested_test",
- vfs2 = "True",
)
syscall_test(
add_overlay = True,
test = "//test/syscalls/linux:fsync_test",
- vfs2 = "True",
)
syscall_test(
size = "medium",
shard_count = 5,
test = "//test/syscalls/linux:futex_test",
- vfs2 = "True",
)
syscall_test(
test = "//test/syscalls/linux:getcpu_host_test",
- vfs2 = "True",
)
syscall_test(
test = "//test/syscalls/linux:getcpu_test",
- vfs2 = "True",
)
syscall_test(
add_overlay = True,
test = "//test/syscalls/linux:getdents_test",
- vfs2 = "True",
)
syscall_test(
test = "//test/syscalls/linux:getrandom_test",
- vfs2 = "True",
)
syscall_test(
test = "//test/syscalls/linux:getrusage_test",
- vfs2 = "True",
)
syscall_test(
size = "medium",
add_overlay = False, # TODO(gvisor.dev/issue/317): enable when fixed.
test = "//test/syscalls/linux:inotify_test",
- vfs2 = "True",
)
syscall_test(
size = "medium",
add_overlay = True,
test = "//test/syscalls/linux:ioctl_test",
- vfs2 = "True",
)
syscall_test(
test = "//test/syscalls/linux:iptables_test",
- vfs2 = "True",
)
syscall_test(
size = "large",
shard_count = 5,
test = "//test/syscalls/linux:itimer_test",
- vfs2 = "True",
)
syscall_test(
test = "//test/syscalls/linux:kill_test",
- vfs2 = "True",
)
syscall_test(
add_overlay = True,
test = "//test/syscalls/linux:link_test",
use_tmpfs = True, # gofer needs CAP_DAC_READ_SEARCH to use AT_EMPTY_PATH with linkat(2)
- vfs2 = "True",
)
syscall_test(
add_overlay = True,
test = "//test/syscalls/linux:lseek_test",
- vfs2 = "True",
)
syscall_test(
test = "//test/syscalls/linux:madvise_test",
- vfs2 = "True",
)
syscall_test(
test = "//test/syscalls/linux:memory_accounting_test",
- vfs2 = "True",
)
syscall_test(
test = "//test/syscalls/linux:mempolicy_test",
- vfs2 = "True",
)
syscall_test(
test = "//test/syscalls/linux:mincore_test",
- vfs2 = "True",
)
syscall_test(
add_overlay = True,
test = "//test/syscalls/linux:mkdir_test",
- vfs2 = "True",
)
syscall_test(
add_overlay = True,
test = "//test/syscalls/linux:mknod_test",
- vfs2 = "True",
)
syscall_test(
size = "medium",
shard_count = 5,
test = "//test/syscalls/linux:mmap_test",
- vfs2 = "True",
)
syscall_test(
add_overlay = True,
test = "//test/syscalls/linux:mount_test",
- vfs2 = "True",
)
syscall_test(
size = "medium",
test = "//test/syscalls/linux:mremap_test",
- vfs2 = "True",
)
syscall_test(
size = "medium",
test = "//test/syscalls/linux:msync_test",
- vfs2 = "True",
)
syscall_test(
test = "//test/syscalls/linux:munmap_test",
- vfs2 = "True",
)
syscall_test(
test = "//test/syscalls/linux:network_namespace_test",
- vfs2 = "True",
)
syscall_test(
add_overlay = True,
test = "//test/syscalls/linux:open_create_test",
- vfs2 = "True",
)
syscall_test(
add_overlay = True,
test = "//test/syscalls/linux:open_test",
- vfs2 = "True",
)
syscall_test(
test = "//test/syscalls/linux:packet_socket_raw_test",
- vfs2 = "True",
)
syscall_test(
test = "//test/syscalls/linux:packet_socket_test",
- vfs2 = "True",
)
syscall_test(
test = "//test/syscalls/linux:partial_bad_buffer_test",
- vfs2 = "True",
)
syscall_test(
test = "//test/syscalls/linux:pause_test",
- vfs2 = "True",
)
syscall_test(
@@ -428,7 +356,6 @@ syscall_test(
# Takes too long under gotsan to run.
tags = ["nogotsan"],
test = "//test/syscalls/linux:ping_socket_test",
- vfs2 = "True",
)
syscall_test(
@@ -436,229 +363,188 @@ syscall_test(
add_overlay = True,
shard_count = 5,
test = "//test/syscalls/linux:pipe_test",
- vfs2 = "True",
)
syscall_test(
test = "//test/syscalls/linux:poll_test",
- vfs2 = "True",
)
syscall_test(
size = "medium",
test = "//test/syscalls/linux:ppoll_test",
- vfs2 = "True",
)
syscall_test(
test = "//test/syscalls/linux:prctl_setuid_test",
- vfs2 = "True",
)
syscall_test(
test = "//test/syscalls/linux:prctl_test",
- vfs2 = "True",
)
syscall_test(
add_overlay = True,
test = "//test/syscalls/linux:pread64_test",
- vfs2 = "True",
)
syscall_test(
add_overlay = True,
test = "//test/syscalls/linux:preadv_test",
- vfs2 = "True",
)
syscall_test(
add_overlay = True,
test = "//test/syscalls/linux:preadv2_test",
- vfs2 = "True",
)
syscall_test(
test = "//test/syscalls/linux:priority_test",
- vfs2 = "True",
)
syscall_test(
size = "medium",
test = "//test/syscalls/linux:proc_test",
- vfs2 = "True",
)
syscall_test(
test = "//test/syscalls/linux:proc_net_test",
- vfs2 = "True",
)
syscall_test(
test = "//test/syscalls/linux:proc_pid_oomscore_test",
- vfs2 = "True",
)
syscall_test(
test = "//test/syscalls/linux:proc_pid_smaps_test",
- vfs2 = "True",
)
syscall_test(
test = "//test/syscalls/linux:proc_pid_uid_gid_map_test",
- vfs2 = "True",
)
syscall_test(
size = "medium",
test = "//test/syscalls/linux:pselect_test",
- vfs2 = "True",
)
syscall_test(
test = "//test/syscalls/linux:ptrace_test",
- vfs2 = "True",
)
syscall_test(
size = "medium",
shard_count = 5,
test = "//test/syscalls/linux:pty_test",
- vfs2 = "True",
)
syscall_test(
test = "//test/syscalls/linux:pty_root_test",
- vfs2 = "True",
)
syscall_test(
add_overlay = True,
test = "//test/syscalls/linux:pwritev2_test",
- vfs2 = "True",
)
syscall_test(
add_overlay = True,
test = "//test/syscalls/linux:pwrite64_test",
- vfs2 = "True",
)
syscall_test(
test = "//test/syscalls/linux:raw_socket_hdrincl_test",
- vfs2 = "True",
)
syscall_test(
test = "//test/syscalls/linux:raw_socket_icmp_test",
- vfs2 = "True",
)
syscall_test(
test = "//test/syscalls/linux:raw_socket_test",
- vfs2 = "True",
)
syscall_test(
add_overlay = True,
test = "//test/syscalls/linux:read_test",
- vfs2 = "True",
)
syscall_test(
add_overlay = True,
test = "//test/syscalls/linux:readahead_test",
- vfs2 = "True",
)
syscall_test(
size = "medium",
shard_count = 5,
test = "//test/syscalls/linux:readv_socket_test",
- vfs2 = "True",
)
syscall_test(
size = "medium",
add_overlay = True,
test = "//test/syscalls/linux:readv_test",
- vfs2 = "True",
)
syscall_test(
size = "medium",
add_overlay = True,
test = "//test/syscalls/linux:rename_test",
- vfs2 = "True",
)
syscall_test(
test = "//test/syscalls/linux:rlimits_test",
- vfs2 = "True",
)
syscall_test(
test = "//test/syscalls/linux:rseq_test",
- vfs2 = "True",
)
syscall_test(
test = "//test/syscalls/linux:rtsignal_test",
- vfs2 = "True",
)
syscall_test(
test = "//test/syscalls/linux:signalfd_test",
- vfs2 = "True",
)
syscall_test(
test = "//test/syscalls/linux:sched_test",
- vfs2 = "True",
)
syscall_test(
test = "//test/syscalls/linux:sched_yield_test",
- vfs2 = "True",
)
syscall_test(
test = "//test/syscalls/linux:seccomp_test",
- vfs2 = "True",
)
syscall_test(
test = "//test/syscalls/linux:select_test",
- vfs2 = "True",
)
syscall_test(
shard_count = 20,
test = "//test/syscalls/linux:semaphore_test",
- vfs2 = "True",
)
syscall_test(
add_overlay = True,
test = "//test/syscalls/linux:sendfile_socket_test",
- vfs2 = "True",
)
syscall_test(
add_overlay = True,
test = "//test/syscalls/linux:sendfile_test",
- vfs2 = "True",
)
syscall_test(
add_overlay = True,
test = "//test/syscalls/linux:splice_test",
- vfs2 = "True",
)
syscall_test(
test = "//test/syscalls/linux:sigaction_test",
- vfs2 = "True",
)
# TODO(b/119826902): Enable once the test passes in runsc.
@@ -666,62 +552,52 @@ syscall_test(
syscall_test(
test = "//test/syscalls/linux:sigiret_test",
- vfs2 = "True",
)
syscall_test(
test = "//test/syscalls/linux:sigprocmask_test",
- vfs2 = "True",
)
syscall_test(
size = "medium",
test = "//test/syscalls/linux:sigstop_test",
- vfs2 = "True",
)
syscall_test(
test = "//test/syscalls/linux:sigtimedwait_test",
- vfs2 = "True",
)
syscall_test(
size = "medium",
test = "//test/syscalls/linux:shm_test",
- vfs2 = "True",
)
syscall_test(
size = "medium",
test = "//test/syscalls/linux:socket_abstract_non_blocking_test",
- vfs2 = "True",
)
syscall_test(
size = "large",
shard_count = 50,
test = "//test/syscalls/linux:socket_abstract_test",
- vfs2 = "True",
)
syscall_test(
size = "medium",
test = "//test/syscalls/linux:socket_domain_non_blocking_test",
- vfs2 = "True",
)
syscall_test(
size = "large",
shard_count = 50,
test = "//test/syscalls/linux:socket_domain_test",
- vfs2 = "True",
)
syscall_test(
size = "medium",
add_overlay = True,
test = "//test/syscalls/linux:socket_filesystem_non_blocking_test",
- vfs2 = "True",
)
syscall_test(
@@ -729,14 +605,12 @@ syscall_test(
add_overlay = True,
shard_count = 50,
test = "//test/syscalls/linux:socket_filesystem_test",
- vfs2 = "True",
)
syscall_test(
size = "large",
shard_count = 50,
test = "//test/syscalls/linux:socket_inet_loopback_test",
- vfs2 = "True",
)
syscall_test(
@@ -745,122 +619,101 @@ syscall_test(
# Takes too long for TSAN. Creates a lot of TCP sockets.
tags = ["nogotsan"],
test = "//test/syscalls/linux:socket_inet_loopback_nogotsan_test",
- vfs2 = "True",
)
syscall_test(
size = "large",
shard_count = 50,
test = "//test/syscalls/linux:socket_ip_tcp_generic_loopback_test",
- vfs2 = "True",
)
syscall_test(
size = "medium",
test = "//test/syscalls/linux:socket_ip_tcp_loopback_non_blocking_test",
- vfs2 = "True",
)
syscall_test(
size = "large",
shard_count = 50,
test = "//test/syscalls/linux:socket_ip_tcp_loopback_test",
- vfs2 = "True",
)
syscall_test(
size = "medium",
shard_count = 50,
test = "//test/syscalls/linux:socket_ip_tcp_udp_generic_loopback_test",
- vfs2 = "True",
)
syscall_test(
size = "medium",
test = "//test/syscalls/linux:socket_ip_udp_loopback_non_blocking_test",
- vfs2 = "True",
)
syscall_test(
size = "large",
shard_count = 50,
test = "//test/syscalls/linux:socket_ip_udp_loopback_test",
- vfs2 = "True",
)
syscall_test(
size = "medium",
test = "//test/syscalls/linux:socket_ipv4_udp_unbound_loopback_test",
- vfs2 = "True",
)
syscall_test(
test = "//test/syscalls/linux:socket_ip_unbound_test",
- vfs2 = "True",
)
syscall_test(
test = "//test/syscalls/linux:socket_netdevice_test",
- vfs2 = "True",
)
syscall_test(
test = "//test/syscalls/linux:socket_netlink_test",
- vfs2 = "True",
)
syscall_test(
test = "//test/syscalls/linux:socket_netlink_route_test",
- vfs2 = "True",
)
syscall_test(
test = "//test/syscalls/linux:socket_netlink_uevent_test",
- vfs2 = "True",
)
syscall_test(
test = "//test/syscalls/linux:socket_blocking_local_test",
- vfs2 = "True",
)
syscall_test(
test = "//test/syscalls/linux:socket_blocking_ip_test",
- vfs2 = "True",
)
syscall_test(
test = "//test/syscalls/linux:socket_non_stream_blocking_local_test",
- vfs2 = "True",
)
syscall_test(
test = "//test/syscalls/linux:socket_non_stream_blocking_udp_test",
- vfs2 = "True",
)
syscall_test(
size = "large",
test = "//test/syscalls/linux:socket_stream_blocking_local_test",
- vfs2 = "True",
)
syscall_test(
size = "large",
test = "//test/syscalls/linux:socket_stream_blocking_tcp_test",
- vfs2 = "True",
)
syscall_test(
size = "medium",
test = "//test/syscalls/linux:socket_stream_local_test",
- vfs2 = "True",
)
syscall_test(
size = "medium",
test = "//test/syscalls/linux:socket_stream_nonblock_local_test",
- vfs2 = "True",
)
syscall_test(
@@ -868,13 +721,11 @@ syscall_test(
size = "enormous",
shard_count = 5,
test = "//test/syscalls/linux:socket_unix_dgram_local_test",
- vfs2 = "True",
)
syscall_test(
size = "medium",
test = "//test/syscalls/linux:socket_unix_dgram_non_blocking_test",
- vfs2 = "True",
)
syscall_test(
@@ -882,7 +733,6 @@ syscall_test(
add_overlay = True,
shard_count = 50,
test = "//test/syscalls/linux:socket_unix_pair_test",
- vfs2 = "True",
)
syscall_test(
@@ -890,156 +740,129 @@ syscall_test(
size = "enormous",
shard_count = 5,
test = "//test/syscalls/linux:socket_unix_seqpacket_local_test",
- vfs2 = "True",
)
syscall_test(
size = "medium",
test = "//test/syscalls/linux:socket_unix_stream_test",
- vfs2 = "True",
)
syscall_test(
size = "medium",
test = "//test/syscalls/linux:socket_unix_unbound_abstract_test",
- vfs2 = "True",
)
syscall_test(
size = "medium",
test = "//test/syscalls/linux:socket_unix_unbound_dgram_test",
- vfs2 = "True",
)
syscall_test(
size = "medium",
test = "//test/syscalls/linux:socket_unix_unbound_filesystem_test",
- vfs2 = "True",
)
syscall_test(
size = "medium",
shard_count = 10,
test = "//test/syscalls/linux:socket_unix_unbound_seqpacket_test",
- vfs2 = "True",
)
syscall_test(
size = "large",
shard_count = 50,
test = "//test/syscalls/linux:socket_unix_unbound_stream_test",
- vfs2 = "True",
)
syscall_test(
add_overlay = True,
test = "//test/syscalls/linux:statfs_test",
- vfs2 = "True",
)
syscall_test(
add_overlay = True,
test = "//test/syscalls/linux:stat_test",
- vfs2 = "True",
)
syscall_test(
add_overlay = True,
test = "//test/syscalls/linux:stat_times_test",
- vfs2 = "True",
)
syscall_test(
add_overlay = True,
test = "//test/syscalls/linux:sticky_test",
- vfs2 = "True",
)
syscall_test(
add_overlay = True,
test = "//test/syscalls/linux:symlink_test",
- vfs2 = "True",
)
syscall_test(
add_overlay = True,
test = "//test/syscalls/linux:sync_test",
- vfs2 = "True",
)
syscall_test(
add_overlay = True,
test = "//test/syscalls/linux:sync_file_range_test",
- vfs2 = "True",
)
syscall_test(
test = "//test/syscalls/linux:sysinfo_test",
- vfs2 = "True",
)
syscall_test(
test = "//test/syscalls/linux:syslog_test",
- vfs2 = "True",
)
syscall_test(
test = "//test/syscalls/linux:sysret_test",
- vfs2 = "True",
)
syscall_test(
size = "medium",
shard_count = 10,
test = "//test/syscalls/linux:tcp_socket_test",
- vfs2 = "True",
)
syscall_test(
test = "//test/syscalls/linux:tgkill_test",
- vfs2 = "True",
)
syscall_test(
test = "//test/syscalls/linux:timerfd_test",
- vfs2 = "True",
)
syscall_test(
test = "//test/syscalls/linux:timers_test",
- vfs2 = "True",
)
syscall_test(
test = "//test/syscalls/linux:time_test",
- vfs2 = "True",
)
syscall_test(
test = "//test/syscalls/linux:tkill_test",
- vfs2 = "True",
)
syscall_test(
add_overlay = True,
test = "//test/syscalls/linux:truncate_test",
- vfs2 = "True",
)
syscall_test(
test = "//test/syscalls/linux:tuntap_test",
- vfs2 = "True",
)
syscall_test(
add_hostinet = True,
test = "//test/syscalls/linux:tuntap_hostinet_test",
- vfs2 = "True",
)
syscall_test(
test = "//test/syscalls/linux:udp_bind_test",
- vfs2 = "True",
)
syscall_test(
@@ -1047,80 +870,65 @@ syscall_test(
add_hostinet = True,
shard_count = 10,
test = "//test/syscalls/linux:udp_socket_test",
- vfs2 = "True",
)
syscall_test(
test = "//test/syscalls/linux:uidgid_test",
- vfs2 = "True",
)
syscall_test(
test = "//test/syscalls/linux:uname_test",
- vfs2 = "True",
)
syscall_test(
add_overlay = True,
test = "//test/syscalls/linux:unlink_test",
- vfs2 = "True",
)
syscall_test(
test = "//test/syscalls/linux:unshare_test",
- vfs2 = "True",
)
syscall_test(
test = "//test/syscalls/linux:utimes_test",
- vfs2 = "True",
)
syscall_test(
size = "medium",
test = "//test/syscalls/linux:vdso_clock_gettime_test",
- vfs2 = "True",
)
syscall_test(
test = "//test/syscalls/linux:vdso_test",
- vfs2 = "True",
)
syscall_test(
test = "//test/syscalls/linux:vsyscall_test",
- vfs2 = "True",
)
syscall_test(
test = "//test/syscalls/linux:vfork_test",
- vfs2 = "True",
)
syscall_test(
size = "medium",
shard_count = 5,
test = "//test/syscalls/linux:wait_test",
- vfs2 = "True",
)
syscall_test(
add_overlay = True,
test = "//test/syscalls/linux:write_test",
- vfs2 = "True",
)
syscall_test(
test = "//test/syscalls/linux:proc_net_unix_test",
- vfs2 = "True",
)
syscall_test(
test = "//test/syscalls/linux:proc_net_tcp_test",
- vfs2 = "True",
)
syscall_test(
test = "//test/syscalls/linux:proc_net_udp_test",
- vfs2 = "True",
)
diff --git a/test/syscalls/linux/socket_ipv4_udp_unbound.cc b/test/syscalls/linux/socket_ipv4_udp_unbound.cc
index de0f5f01b..bc005e2bb 100644
--- a/test/syscalls/linux/socket_ipv4_udp_unbound.cc
+++ b/test/syscalls/linux/socket_ipv4_udp_unbound.cc
@@ -2452,5 +2452,105 @@ TEST_P(IPv4UDPUnboundSocketTest, SetSocketSendBuf) {
ASSERT_EQ(quarter_sz, val);
}
+
+TEST_P(IPv4UDPUnboundSocketTest, IpMulticastIPPacketInfo) {
+ auto sender_socket = ASSERT_NO_ERRNO_AND_VALUE(NewSocket());
+ auto receiver_socket = ASSERT_NO_ERRNO_AND_VALUE(NewSocket());
+
+ // Bind the first FD to the loopback. This is an alternative to
+ // IP_MULTICAST_IF for setting the default send interface.
+ auto sender_addr = V4Loopback();
+ ASSERT_THAT(
+ bind(sender_socket->get(), reinterpret_cast<sockaddr*>(&sender_addr.addr),
+ sender_addr.addr_len),
+ SyscallSucceeds());
+
+ // Bind the second FD to the v4 any address to ensure that we can receive the
+ // multicast packet.
+ auto receiver_addr = V4Any();
+ ASSERT_THAT(bind(receiver_socket->get(),
+ reinterpret_cast<sockaddr*>(&receiver_addr.addr),
+ receiver_addr.addr_len),
+ SyscallSucceeds());
+ socklen_t receiver_addr_len = receiver_addr.addr_len;
+ ASSERT_THAT(getsockname(receiver_socket->get(),
+ reinterpret_cast<sockaddr*>(&receiver_addr.addr),
+ &receiver_addr_len),
+ SyscallSucceeds());
+ EXPECT_EQ(receiver_addr_len, receiver_addr.addr_len);
+
+ // Register to receive multicast packets.
+ ip_mreqn group = {};
+ group.imr_multiaddr.s_addr = inet_addr(kMulticastAddress);
+ group.imr_ifindex = ASSERT_NO_ERRNO_AND_VALUE(InterfaceIndex("lo"));
+ ASSERT_THAT(setsockopt(receiver_socket->get(), IPPROTO_IP, IP_ADD_MEMBERSHIP,
+ &group, sizeof(group)),
+ SyscallSucceeds());
+
+ // Register to receive IP packet info.
+ const int one = 1;
+ ASSERT_THAT(setsockopt(receiver_socket->get(), IPPROTO_IP, IP_PKTINFO, &one,
+ sizeof(one)),
+ SyscallSucceeds());
+
+ // Send a multicast packet.
+ auto send_addr = V4Multicast();
+ reinterpret_cast<sockaddr_in*>(&send_addr.addr)->sin_port =
+ reinterpret_cast<sockaddr_in*>(&receiver_addr.addr)->sin_port;
+ char send_buf[200];
+ RandomizeBuffer(send_buf, sizeof(send_buf));
+ ASSERT_THAT(
+ RetryEINTR(sendto)(sender_socket->get(), send_buf, sizeof(send_buf), 0,
+ reinterpret_cast<sockaddr*>(&send_addr.addr),
+ send_addr.addr_len),
+ SyscallSucceedsWithValue(sizeof(send_buf)));
+
+ // Check that we received the multicast packet.
+ msghdr recv_msg = {};
+ iovec recv_iov = {};
+ char recv_buf[sizeof(send_buf)];
+ char recv_cmsg_buf[CMSG_SPACE(sizeof(in_pktinfo))] = {};
+ size_t cmsg_data_len = sizeof(in_pktinfo);
+ recv_iov.iov_base = recv_buf;
+ recv_iov.iov_len = sizeof(recv_buf);
+ recv_msg.msg_iov = &recv_iov;
+ recv_msg.msg_iovlen = 1;
+ recv_msg.msg_controllen = CMSG_LEN(cmsg_data_len);
+ recv_msg.msg_control = recv_cmsg_buf;
+ ASSERT_THAT(RetryEINTR(recvmsg)(receiver_socket->get(), &recv_msg, 0),
+ SyscallSucceedsWithValue(sizeof(send_buf)));
+ EXPECT_EQ(0, memcmp(send_buf, recv_buf, sizeof(send_buf)));
+
+ // Check the IP_PKTINFO control message.
+ cmsghdr* cmsg = CMSG_FIRSTHDR(&recv_msg);
+ ASSERT_NE(cmsg, nullptr);
+ EXPECT_EQ(cmsg->cmsg_len, CMSG_LEN(cmsg_data_len));
+ EXPECT_EQ(cmsg->cmsg_level, IPPROTO_IP);
+ EXPECT_EQ(cmsg->cmsg_type, IP_PKTINFO);
+
+ // Get loopback index.
+ ifreq ifr = {};
+ absl::SNPrintF(ifr.ifr_name, IFNAMSIZ, "lo");
+ ASSERT_THAT(ioctl(receiver_socket->get(), SIOCGIFINDEX, &ifr),
+ SyscallSucceeds());
+ ASSERT_NE(ifr.ifr_ifindex, 0);
+
+ in_pktinfo received_pktinfo = {};
+ memcpy(&received_pktinfo, CMSG_DATA(cmsg), sizeof(in_pktinfo));
+ EXPECT_EQ(received_pktinfo.ipi_ifindex, ifr.ifr_ifindex);
+ if (IsRunningOnGvisor()) {
+ // This should actually be a unicast address assigned to the interface.
+ //
+ // TODO(gvisor.dev/issue/3556): This check is validating incorrect
+ // behaviour. We still include the test so that once the bug is
+ // resolved, this test will start to fail and the individual tasked
+ // with fixing this bug knows to also fix this test :).
+ EXPECT_EQ(received_pktinfo.ipi_spec_dst.s_addr, group.imr_multiaddr.s_addr);
+ } else {
+ EXPECT_EQ(received_pktinfo.ipi_spec_dst.s_addr, htonl(INADDR_LOOPBACK));
+ }
+ EXPECT_EQ(received_pktinfo.ipi_addr.s_addr, group.imr_multiaddr.s_addr);
+}
+
} // namespace testing
} // namespace gvisor