summaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/benchmarks/base/sysbench_test.go6
-rw-r--r--test/benchmarks/fs/fio_test.go12
-rw-r--r--test/cmd/test_app/fds.go2
-rw-r--r--test/iptables/filter_input.go1
-rw-r--r--test/iptables/nat.go30
-rw-r--r--test/packetimpact/netdevs/netdevs_test.go12
-rw-r--r--test/packetimpact/tests/udp_icmp_error_propagation_test.go8
-rw-r--r--test/root/crictl_test.go8
-rw-r--r--test/runner/gtest/gtest.go2
-rw-r--r--test/syscalls/linux/inotify.cc39
10 files changed, 80 insertions, 40 deletions
diff --git a/test/benchmarks/base/sysbench_test.go b/test/benchmarks/base/sysbench_test.go
index 80569687c..d0f3f9261 100644
--- a/test/benchmarks/base/sysbench_test.go
+++ b/test/benchmarks/base/sysbench_test.go
@@ -31,7 +31,7 @@ type testCase struct {
// BenchmarSysbench runs sysbench on the runtime.
func BenchmarkSysbench(b *testing.B) {
testCases := []testCase{
- testCase{
+ {
name: "CPU",
test: &tools.SysbenchCPU{
SysbenchBase: tools.SysbenchBase{
@@ -39,7 +39,7 @@ func BenchmarkSysbench(b *testing.B) {
},
},
},
- testCase{
+ {
name: "Memory",
test: &tools.SysbenchMemory{
SysbenchBase: tools.SysbenchBase{
@@ -47,7 +47,7 @@ func BenchmarkSysbench(b *testing.B) {
},
},
},
- testCase{
+ {
name: "Mutex",
test: &tools.SysbenchMutex{
SysbenchBase: tools.SysbenchBase{
diff --git a/test/benchmarks/fs/fio_test.go b/test/benchmarks/fs/fio_test.go
index 83b8376a5..242374e2c 100644
--- a/test/benchmarks/fs/fio_test.go
+++ b/test/benchmarks/fs/fio_test.go
@@ -32,37 +32,37 @@ import (
// caches can be dropped.
func BenchmarkFio(b *testing.B) {
testCases := []tools.Fio{
- tools.Fio{
+ {
Test: "write",
Size: b.N,
BlockSize: 4,
IODepth: 4,
},
- tools.Fio{
+ {
Test: "write",
Size: b.N,
BlockSize: 1024,
IODepth: 4,
},
- tools.Fio{
+ {
Test: "read",
Size: b.N,
BlockSize: 4,
IODepth: 4,
},
- tools.Fio{
+ {
Test: "read",
Size: b.N,
BlockSize: 1024,
IODepth: 4,
},
- tools.Fio{
+ {
Test: "randwrite",
Size: b.N,
BlockSize: 4,
IODepth: 4,
},
- tools.Fio{
+ {
Test: "randread",
Size: b.N,
BlockSize: 4,
diff --git a/test/cmd/test_app/fds.go b/test/cmd/test_app/fds.go
index d4354f0d3..9b5f7231a 100644
--- a/test/cmd/test_app/fds.go
+++ b/test/cmd/test_app/fds.go
@@ -89,7 +89,7 @@ func (fds *fdSender) Execute(ctx context.Context, f *flag.FlagSet, args ...inter
w := s.Writer(true)
w.ControlMessage.PackFDs(int(fileToSend.Fd()))
- if _, err := w.WriteVec([][]byte{[]byte{'a'}}); err != nil {
+ if _, err := w.WriteVec([][]byte{{'a'}}); err != nil {
log.Fatalf("Error sending FD %q over socket %q: %v", fileToSend.Fd(), fds.socketPath, err)
}
diff --git a/test/iptables/filter_input.go b/test/iptables/filter_input.go
index b45d448b8..37a1a6694 100644
--- a/test/iptables/filter_input.go
+++ b/test/iptables/filter_input.go
@@ -328,6 +328,7 @@ func (FilterInputRequireProtocolUDP) ContainerAction(ctx context.Context, ip net
return nil
}
+// LocalAction implements TestCase.LocalAction.
func (FilterInputRequireProtocolUDP) LocalAction(ctx context.Context, ip net.IP, ipv6 bool) error {
// No-op.
return nil
diff --git a/test/iptables/nat.go b/test/iptables/nat.go
index b98d99fb8..495241482 100644
--- a/test/iptables/nat.go
+++ b/test/iptables/nat.go
@@ -621,24 +621,24 @@ func listenForRedirectedConn(ctx context.Context, ipv6 bool, originalDsts []net.
}
}
return fmt.Errorf("SO_ORIGINAL_DST returned %+v, but wanted one of %+v (note: port numbers are in network byte order)", got, originalDsts)
- } else {
- got, err := originalDestination4(connFD)
- if err != nil {
- return err
+ }
+
+ got, err := originalDestination4(connFD)
+ if err != nil {
+ return err
+ }
+ // The original destination could be any of our IPs.
+ for _, dst := range originalDsts {
+ want := syscall.RawSockaddrInet4{
+ Family: syscall.AF_INET,
+ Port: htons(dropPort),
}
- // The original destination could be any of our IPs.
- for _, dst := range originalDsts {
- want := syscall.RawSockaddrInet4{
- Family: syscall.AF_INET,
- Port: htons(dropPort),
- }
- copy(want.Addr[:], dst.To4())
- if got == want {
- return nil
- }
+ copy(want.Addr[:], dst.To4())
+ if got == want {
+ return nil
}
- return fmt.Errorf("SO_ORIGINAL_DST returned %+v, but wanted one of %+v (note: port numbers are in network byte order)", got, originalDsts)
}
+ return fmt.Errorf("SO_ORIGINAL_DST returned %+v, but wanted one of %+v (note: port numbers are in network byte order)", got, originalDsts)
}
// loopbackTests runs an iptables rule and ensures that packets sent to
diff --git a/test/packetimpact/netdevs/netdevs_test.go b/test/packetimpact/netdevs/netdevs_test.go
index 24ad12198..379386980 100644
--- a/test/packetimpact/netdevs/netdevs_test.go
+++ b/test/packetimpact/netdevs/netdevs_test.go
@@ -63,7 +63,7 @@ func TestParseDevices(t *testing.T) {
inet6 fe80::42:daff:fe33:130a/64 scope link tentative
valid_lft forever preferred_lft forever`,
want: map[string]DeviceInfo{
- "lo": DeviceInfo{
+ "lo": {
ID: 1,
MAC: mustParseMAC("00:00:00:00:00:00"),
IPv4Addr: net.IPv4(127, 0, 0, 1),
@@ -77,7 +77,7 @@ func TestParseDevices(t *testing.T) {
Mask: net.CIDRMask(128, 128),
},
},
- "eth0": DeviceInfo{
+ "eth0": {
ID: 2613,
MAC: mustParseMAC("02:42:c0:a8:09:02"),
IPv4Addr: net.IPv4(192, 168, 9, 2),
@@ -91,7 +91,7 @@ func TestParseDevices(t *testing.T) {
Mask: net.CIDRMask(64, 128),
},
},
- "eth1": DeviceInfo{
+ "eth1": {
ID: 2617,
MAC: mustParseMAC("02:42:da:33:13:0a"),
IPv4Addr: net.IPv4(218, 51, 19, 10),
@@ -105,7 +105,7 @@ func TestParseDevices(t *testing.T) {
Mask: net.CIDRMask(64, 128),
},
},
- "eth2": DeviceInfo{
+ "eth2": {
ID: 2615,
MAC: mustParseMAC("02:42:df:f5:e1:0a"),
IPv4Addr: net.IPv4(223, 245, 225, 10),
@@ -129,7 +129,7 @@ func TestParseDevices(t *testing.T) {
inet 192.168.9.2/24 brd 192.168.9.255 scope global eth0
valid_lft forever preferred_lft forever`,
want: map[string]DeviceInfo{
- "eth0": DeviceInfo{
+ "eth0": {
ID: 2613,
MAC: mustParseMAC("02:42:c0:a8:09:02"),
IPv4Addr: net.IPv4(192, 168, 9, 2),
@@ -148,7 +148,7 @@ func TestParseDevices(t *testing.T) {
inet6 fe80::42:dfff:fef5:e10a/64 scope link tentative
valid_lft forever preferred_lft forever`,
want: map[string]DeviceInfo{
- "eth2": DeviceInfo{
+ "eth2": {
ID: 2615,
MAC: mustParseMAC("02:42:df:f5:e1:0a"),
IPv6Addr: net.ParseIP("fe80::42:dfff:fef5:e10a"),
diff --git a/test/packetimpact/tests/udp_icmp_error_propagation_test.go b/test/packetimpact/tests/udp_icmp_error_propagation_test.go
index cd4523e88..58d49d31a 100644
--- a/test/packetimpact/tests/udp_icmp_error_propagation_test.go
+++ b/test/packetimpact/tests/udp_icmp_error_propagation_test.go
@@ -220,12 +220,12 @@ func TestUDPICMPErrorPropagation(t *testing.T) {
wantErrno := wantErrno(connect, icmpErr)
for _, errDetect := range []errorDetection{
- errorDetection{"SendTo", false, testSendTo},
+ {"SendTo", false, testSendTo},
// Send to an address that's different from the one that caused an ICMP
// error to be returned.
- errorDetection{"SendToValid", true, testSendTo},
- errorDetection{"Recv", false, testRecv},
- errorDetection{"SockOpt", false, testSockOpt},
+ {"SendToValid", true, testSendTo},
+ {"Recv", false, testRecv},
+ {"SockOpt", false, testSockOpt},
} {
t.Run(fmt.Sprintf("%s/%s/%s", connect, icmpErr, errDetect.name), func(t *testing.T) {
dut := testbench.NewDUT(t)
diff --git a/test/root/crictl_test.go b/test/root/crictl_test.go
index df52dd381..863b98d0f 100644
--- a/test/root/crictl_test.go
+++ b/test/root/crictl_test.go
@@ -128,22 +128,22 @@ func TestCrictlSanity(t *testing.T) {
// mounts.
var HttpdMountPaths = SimpleSpec("httpd", "basic/httpd", nil, map[string]interface{}{
"mounts": []map[string]interface{}{
- map[string]interface{}{
+ {
"container_path": "/var/run/secrets/kubernetes.io/serviceaccount",
"host_path": "/var/lib/kubelet/pods/82bae206-cdf5-11e8-b245-8cdcd43ac064/volumes/kubernetes.io~secret/default-token-2rpfx",
"readonly": true,
},
- map[string]interface{}{
+ {
"container_path": "/etc/hosts",
"host_path": "/var/lib/kubelet/pods/82bae206-cdf5-11e8-b245-8cdcd43ac064/etc-hosts",
"readonly": false,
},
- map[string]interface{}{
+ {
"container_path": "/dev/termination-log",
"host_path": "/var/lib/kubelet/pods/82bae206-cdf5-11e8-b245-8cdcd43ac064/containers/httpd/d1709580",
"readonly": false,
},
- map[string]interface{}{
+ {
"container_path": "/usr/local/apache2/htdocs/test",
"host_path": "/var/lib/kubelet/pods/82bae206-cdf5-11e8-b245-8cdcd43ac064",
"readonly": true,
diff --git a/test/runner/gtest/gtest.go b/test/runner/gtest/gtest.go
index e4445e01b..38e57d62f 100644
--- a/test/runner/gtest/gtest.go
+++ b/test/runner/gtest/gtest.go
@@ -91,7 +91,7 @@ func ParseTestCases(testBin string, benchmarks bool, extraArgs ...string) ([]Tes
// return something that will run the binary with no
// flags, which should execute all tests.
return []TestCase{
- TestCase{
+ {
Suite: "Default",
Name: "All",
all: true,
diff --git a/test/syscalls/linux/inotify.cc b/test/syscalls/linux/inotify.cc
index e4392a450..8137f0e29 100644
--- a/test/syscalls/linux/inotify.cc
+++ b/test/syscalls/linux/inotify.cc
@@ -1703,6 +1703,45 @@ TEST(Inotify, Fallocate) {
EXPECT_THAT(events, Are({Event(IN_MODIFY, wd)}));
}
+TEST(Inotify, Utimensat) {
+ SKIP_IF(IsRunningWithVFS1());
+
+ const TempPath file = ASSERT_NO_ERRNO_AND_VALUE(TempPath::CreateFile());
+ const FileDescriptor fd =
+ ASSERT_NO_ERRNO_AND_VALUE(Open(file.path(), O_RDWR));
+
+ const FileDescriptor inotify_fd =
+ ASSERT_NO_ERRNO_AND_VALUE(InotifyInit1(IN_NONBLOCK));
+ const int wd = ASSERT_NO_ERRNO_AND_VALUE(
+ InotifyAddWatch(inotify_fd.get(), file.path(), IN_ALL_EVENTS));
+
+ // Just update the access time.
+ struct timespec times[2] = {};
+ times[0].tv_nsec = UTIME_NOW;
+ times[1].tv_nsec = UTIME_OMIT;
+ ASSERT_THAT(RetryEINTR(utimensat)(AT_FDCWD, file.path().c_str(), times, 0),
+ SyscallSucceeds());
+ std::vector<Event> events =
+ ASSERT_NO_ERRNO_AND_VALUE(DrainEvents(inotify_fd.get()));
+ EXPECT_THAT(events, Are({Event(IN_ACCESS, wd)}));
+
+ // Just the modify time.
+ times[0].tv_nsec = UTIME_OMIT;
+ times[1].tv_nsec = UTIME_NOW;
+ ASSERT_THAT(utimensat(AT_FDCWD, file.path().c_str(), times, 0),
+ SyscallSucceeds());
+ events = ASSERT_NO_ERRNO_AND_VALUE(DrainEvents(inotify_fd.get()));
+ EXPECT_THAT(events, Are({Event(IN_MODIFY, wd)}));
+
+ // Both together.
+ times[0].tv_nsec = UTIME_NOW;
+ times[1].tv_nsec = UTIME_NOW;
+ ASSERT_THAT(utimensat(AT_FDCWD, file.path().c_str(), times, 0),
+ SyscallSucceeds());
+ events = ASSERT_NO_ERRNO_AND_VALUE(DrainEvents(inotify_fd.get()));
+ EXPECT_THAT(events, Are({Event(IN_ATTRIB, wd)}));
+}
+
TEST(Inotify, Sendfile) {
SKIP_IF(IsRunningWithVFS1());