diff options
author | Mithun Iyer <iyerm@google.com> | 2020-06-11 19:45:06 -0700 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2020-06-11 19:46:49 -0700 |
commit | 61d6c059ac3434ddf0c206975a116a09d0838338 (patch) | |
tree | 5af3a2116c5ca2610f8af95dab9cb1154f335642 | |
parent | 8ea99d58ffd708aa7a26be58d89cb817d8eceec6 (diff) |
Replace use of %v in packetimpact tests
PiperOrigin-RevId: 316027588
6 files changed, 22 insertions, 22 deletions
diff --git a/test/packetimpact/tests/ipv4_id_uniqueness_test.go b/test/packetimpact/tests/ipv4_id_uniqueness_test.go index 4efb9829c..7db7ae02d 100644 --- a/test/packetimpact/tests/ipv4_id_uniqueness_test.go +++ b/test/packetimpact/tests/ipv4_id_uniqueness_test.go @@ -37,7 +37,7 @@ func recvTCPSegment(conn *testbench.TCPIPv4, expect *testbench.TCP, expectPayloa return 0, fmt.Errorf("failed to receive TCP segment: %s", err) } if len(layers) < 2 { - return 0, fmt.Errorf("got packet with layers: %v, expected to have at least 2 layers (link and network)", layers) + return 0, fmt.Errorf("got packet with layers: %s, expected to have at least 2 layers (link and network)", layers) } ipv4, ok := layers[1].(*testbench.IPv4) if !ok { diff --git a/test/packetimpact/tests/tcp_retransmits_test.go b/test/packetimpact/tests/tcp_retransmits_test.go index e51409b66..6940eb7fb 100644 --- a/test/packetimpact/tests/tcp_retransmits_test.go +++ b/test/packetimpact/tests/tcp_retransmits_test.go @@ -49,7 +49,7 @@ func TestRetransmits(t *testing.T) { dut.Send(acceptFd, sampleData, 0) if _, err := conn.ExpectData(&testbench.TCP{}, samplePayload, time.Second); err != nil { - t.Fatalf("expected a packet with payload %v: %s", samplePayload, err) + t.Fatalf("expected payload was not received: %s", err) } // Give a chance for the dut to estimate RTO with RTT from the DATA-ACK. // TODO(gvisor.dev/issue/2685) Estimate RTO during handshake, after which @@ -62,13 +62,13 @@ func TestRetransmits(t *testing.T) { dut.Send(acceptFd, sampleData, 0) seq := testbench.Uint32(uint32(*conn.RemoteSeqNum())) if _, err := conn.ExpectData(&testbench.TCP{SeqNum: seq}, samplePayload, startRTO); err != nil { - t.Fatalf("expected a packet with payload %v: %s", samplePayload, err) + t.Fatalf("expected payload was not received: %s", err) } // Expect retransmits of the same segment. for i := 0; i < 5; i++ { start := time.Now() if _, err := conn.ExpectData(&testbench.TCP{SeqNum: seq}, samplePayload, 2*current); err != nil { - t.Fatalf("expected a packet with payload %v: %s loop %d", samplePayload, err, i) + t.Fatalf("expected payload was not received: %s loop %d", err, i) } if i == 0 { startRTO = time.Now().Sub(first) @@ -77,7 +77,7 @@ func TestRetransmits(t *testing.T) { } // Check if the probes came at exponentially increasing intervals. if p := time.Since(start); p < current-startRTO { - t.Fatalf("retransmit came sooner interval %d probe %d\n", p, i) + t.Fatalf("retransmit came sooner interval %d probe %d", p, i) } current *= 2 } diff --git a/test/packetimpact/tests/tcp_window_shrink_test.go b/test/packetimpact/tests/tcp_window_shrink_test.go index 576ec1a8b..e78d04756 100644 --- a/test/packetimpact/tests/tcp_window_shrink_test.go +++ b/test/packetimpact/tests/tcp_window_shrink_test.go @@ -47,17 +47,17 @@ func TestWindowShrink(t *testing.T) { dut.Send(acceptFd, sampleData, 0) if _, err := conn.ExpectData(&testbench.TCP{}, samplePayload, time.Second); err != nil { - t.Fatalf("expected a packet with payload %v: %s", samplePayload, err) + t.Fatalf("expected payload was not received: %s", err) } conn.Send(testbench.TCP{Flags: testbench.Uint8(header.TCPFlagAck)}) dut.Send(acceptFd, sampleData, 0) dut.Send(acceptFd, sampleData, 0) if _, err := conn.ExpectData(&testbench.TCP{}, samplePayload, time.Second); err != nil { - t.Fatalf("expected a packet with payload %v: %s", samplePayload, err) + t.Fatalf("expected payload was not received: %s", err) } if _, err := conn.ExpectData(&testbench.TCP{}, samplePayload, time.Second); err != nil { - t.Fatalf("expected a packet with payload %v: %s", samplePayload, err) + t.Fatalf("expected payload was not received: %s", err) } // We close our receiving window here conn.Send(testbench.TCP{Flags: testbench.Uint8(header.TCPFlagAck), WindowSize: testbench.Uint16(0)}) @@ -68,6 +68,6 @@ func TestWindowShrink(t *testing.T) { // the following lines. expectedRemoteSeqNum := *conn.RemoteSeqNum() - 1 if _, err := conn.ExpectData(&testbench.TCP{SeqNum: testbench.Uint32(uint32(expectedRemoteSeqNum))}, nil, time.Second); err != nil { - t.Fatalf("expected a packet with sequence number %v: %s", expectedRemoteSeqNum, err) + t.Fatalf("expected a packet with sequence number %d: %s", expectedRemoteSeqNum, err) } } diff --git a/test/packetimpact/tests/tcp_zero_window_probe_retransmit_test.go b/test/packetimpact/tests/tcp_zero_window_probe_retransmit_test.go index 54cee138f..5ab193181 100644 --- a/test/packetimpact/tests/tcp_zero_window_probe_retransmit_test.go +++ b/test/packetimpact/tests/tcp_zero_window_probe_retransmit_test.go @@ -50,11 +50,11 @@ func TestZeroWindowProbeRetransmit(t *testing.T) { // Send and receive sample data to the dut. dut.Send(acceptFd, sampleData, 0) if _, err := conn.ExpectData(&testbench.TCP{}, samplePayload, time.Second); err != nil { - t.Fatalf("expected a packet with payload %v: %s", samplePayload, err) + t.Fatalf("expected payload was not received: %s", err) } conn.Send(testbench.TCP{Flags: testbench.Uint8(header.TCPFlagAck | header.TCPFlagPsh)}, samplePayload) if _, err := conn.ExpectData(&testbench.TCP{Flags: testbench.Uint8(header.TCPFlagAck)}, nil, time.Second); err != nil { - t.Fatalf("expected a packet with sequence number %s", err) + t.Fatalf("expected packet was not received: %s", err) } // Check for the dut to keep the connection alive as long as the zero window @@ -80,7 +80,7 @@ func TestZeroWindowProbeRetransmit(t *testing.T) { // first retransmission time. The retransmission times is supposed to // exponentially increase. if _, err := conn.ExpectData(&testbench.TCP{SeqNum: probeSeq}, nil, 2*current); err != nil { - t.Fatalf("expected a probe with sequence number %v: loop %d", probeSeq, i) + t.Fatalf("expected a probe with sequence number %d: loop %d", probeSeq, i) } if i == 0 { startProbeDuration = time.Now().Sub(first) @@ -100,6 +100,6 @@ func TestZeroWindowProbeRetransmit(t *testing.T) { // Expect the dut to recover and transmit data. if _, err := conn.ExpectData(&testbench. TCP{SeqNum: ackProbe}, samplePayload, time.Second); err != nil { - t.Fatalf("expected a packet with payload %v: %s", samplePayload, err) + t.Fatalf("expected payload was not received: %s", err) } } diff --git a/test/packetimpact/tests/tcp_zero_window_probe_test.go b/test/packetimpact/tests/tcp_zero_window_probe_test.go index c9b3b7af2..649fd5699 100644 --- a/test/packetimpact/tests/tcp_zero_window_probe_test.go +++ b/test/packetimpact/tests/tcp_zero_window_probe_test.go @@ -51,12 +51,12 @@ func TestZeroWindowProbe(t *testing.T) { // Send and receive sample data to the dut. dut.Send(acceptFd, sampleData, 0) if _, err := conn.ExpectData(&testbench.TCP{}, samplePayload, time.Second); err != nil { - t.Fatalf("expected a packet with payload %v: %s", samplePayload, err) + t.Fatalf("expected payload was not received: %s", err) } sendTime := time.Now().Sub(start) conn.Send(testbench.TCP{Flags: testbench.Uint8(header.TCPFlagAck | header.TCPFlagPsh)}, samplePayload) if _, err := conn.ExpectData(&testbench.TCP{Flags: testbench.Uint8(header.TCPFlagAck)}, nil, time.Second); err != nil { - t.Fatalf("expected a packet with sequence number %s", err) + t.Fatalf("expected packet was not received: %s", err) } // Test 1: Check for receive of a zero window probe, record the duration for @@ -73,7 +73,7 @@ func TestZeroWindowProbe(t *testing.T) { // Expect there are no zero-window probes sent until there is data to be sent out // from the dut. if _, err := conn.ExpectData(&testbench.TCP{SeqNum: probeSeq}, nil, 2*time.Second); err == nil { - t.Fatalf("unexpected a packet with sequence number %v: %s", probeSeq, err) + t.Fatalf("unexpected packet with sequence number %d: %s", probeSeq, err) } start = time.Now() @@ -81,13 +81,13 @@ func TestZeroWindowProbe(t *testing.T) { dut.Send(acceptFd, sampleData, 0) // Expect zero-window probe from the dut. if _, err := conn.ExpectData(&testbench.TCP{SeqNum: probeSeq}, nil, time.Second); err != nil { - t.Fatalf("expected a packet with sequence number %v: %s", probeSeq, err) + t.Fatalf("expected a packet with sequence number %d: %s", probeSeq, err) } // Expect the probe to be sent after some time. Compare against the previous // time recorded when the dut immediately sends out data on receiving the // send command. if startProbeDuration := time.Now().Sub(start); startProbeDuration <= sendTime { - t.Fatalf("expected the first probe to be sent out after retransmission interval, got %v want > %v\n", startProbeDuration, sendTime) + t.Fatalf("expected the first probe to be sent out after retransmission interval, got %s want > %s", startProbeDuration, sendTime) } // Test 2: Check if the dut recovers on advertizing non-zero receive window. @@ -97,7 +97,7 @@ func TestZeroWindowProbe(t *testing.T) { conn.Send(testbench.TCP{AckNum: ackProbe, Flags: testbench.Uint8(header.TCPFlagAck)}) // Expect the dut to recover and transmit data. if _, err := conn.ExpectData(&testbench.TCP{SeqNum: ackProbe}, samplePayload, time.Second); err != nil { - t.Fatalf("expected a packet with payload %v: %s", samplePayload, err) + t.Fatalf("expected payload was not received: %s", err) } // Test 3: Sanity check for dut's processing of a similar probe it sent. diff --git a/test/packetimpact/tests/tcp_zero_window_probe_usertimeout_test.go b/test/packetimpact/tests/tcp_zero_window_probe_usertimeout_test.go index 749281d9d..3c467b14f 100644 --- a/test/packetimpact/tests/tcp_zero_window_probe_usertimeout_test.go +++ b/test/packetimpact/tests/tcp_zero_window_probe_usertimeout_test.go @@ -50,11 +50,11 @@ func TestZeroWindowProbeUserTimeout(t *testing.T) { // Send and receive sample data to the dut. dut.Send(acceptFd, sampleData, 0) if _, err := conn.ExpectData(&testbench.TCP{}, samplePayload, time.Second); err != nil { - t.Fatalf("expected a packet with payload %v: %s", samplePayload, err) + t.Fatalf("expected payload was not received: %s", err) } conn.Send(testbench.TCP{Flags: testbench.Uint8(header.TCPFlagAck | header.TCPFlagPsh)}, samplePayload) if _, err := conn.ExpectData(&testbench.TCP{Flags: testbench.Uint8(header.TCPFlagAck)}, nil, time.Second); err != nil { - t.Fatalf("expected a packet with sequence number %s", err) + t.Fatalf("expected packet was not received: %s", err) } // Test 1: Check for receive of a zero window probe, record the duration for @@ -70,7 +70,7 @@ func TestZeroWindowProbeUserTimeout(t *testing.T) { dut.Send(acceptFd, sampleData, 0) // Expect zero-window probe from the dut. if _, err := conn.ExpectData(&testbench.TCP{SeqNum: probeSeq}, nil, time.Second); err != nil { - t.Fatalf("expected a packet with sequence number %v: %s", probeSeq, err) + t.Fatalf("expected a packet with sequence number %d: %s", probeSeq, err) } // Record the duration for first probe, the dut sends the zero window probe after // a retransmission time interval. |