summaryrefslogtreecommitdiff
path: root/fastboot/tcp_test.cpp
diff options
context:
space:
mode:
authorDavid Pursell <dpursell@google.com>2016-02-17 10:00:09 -0800
committerDavid Pursell <dpursell@google.com>2016-02-17 10:00:09 -0800
commitaad72a533f97e8be5114e127fb681ee1596bdc89 (patch)
tree910a27ee2a76a93e9b23eefef13f29fc13286766 /fastboot/tcp_test.cpp
parent8c09555aac6f00cb7fa7d62cb5c356e2f07a268b (diff)
fastboot: fix TCP protocol version check.
Currently the TCP handshake fails if the device TCP protocol version doesn't match the host exactly, but the protocol is supposed to allow for forwards compatibility by accepting any protocol version >= itself. That way the other side can potentially lower its protocol to match and keep going. This CL fixes the protocol version check and adds corresponding unit tests. Bug: http://b/27220700 Change-Id: Ib17f0a55eb910105a27609bc94bf76a30442e92e
Diffstat (limited to 'fastboot/tcp_test.cpp')
-rw-r--r--fastboot/tcp_test.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/fastboot/tcp_test.cpp b/fastboot/tcp_test.cpp
index 7d80d76f5..6e867ae85 100644
--- a/fastboot/tcp_test.cpp
+++ b/fastboot/tcp_test.cpp
@@ -42,6 +42,16 @@ TEST(TcpConnectTest, TestSuccess) {
EXPECT_EQ("", error);
}
+TEST(TcpConnectTest, TestNewerVersionSuccess) {
+ std::unique_ptr<SocketMock> mock(new SocketMock);
+ mock->ExpectSend("FB01");
+ mock->AddReceive("FB99");
+
+ std::string error;
+ EXPECT_NE(nullptr, tcp::internal::Connect(std::move(mock), &error));
+ EXPECT_EQ("", error);
+}
+
TEST(TcpConnectTest, TestSendFailure) {
std::unique_ptr<SocketMock> mock(new SocketMock);
mock->ExpectSendFailure("FB01");
@@ -74,11 +84,11 @@ TEST(TcpConnectTest, TestBadResponseFailure) {
TEST(TcpConnectTest, TestUnknownVersionFailure) {
std::unique_ptr<SocketMock> mock(new SocketMock);
mock->ExpectSend("FB01");
- mock->AddReceive("FB02");
+ mock->AddReceive("FB00");
std::string error;
EXPECT_EQ(nullptr, tcp::internal::Connect(std::move(mock), &error));
- EXPECT_EQ("Unknown TCP protocol version 02 (host version 01)", error);
+ EXPECT_EQ("Unknown TCP protocol version 00 (host version 01)", error);
}
// Fixture to configure a SocketMock for a successful TCP connection.