Skip to content

Commit

Permalink
fuzzy_fastboot: use 'tcp:' prefix to identify fastboot protocol.
Browse files Browse the repository at this point in the history
The fastbootd over ethernet was implemented with IPv6 link-local
address. An IPv6 address may include many ':'. It will break this fuzzy
test. This new solution uses "tcp:" prefix to identify the fastboot
protocol, like the host fastboot command.

BUG: 158040108
Test: fuzzy_fastboot --serial=tcp:fe80::230:1bff:feba:8128%wlan0 \
      --gtest_filter=*Logical*
Change-Id: I971fd9e25741e18bf7f5907d562556b09db1d624
  • Loading branch information
Hongguang Chen committed Jun 4, 2020
1 parent ff50237 commit 0e743a2
Showing 1 changed file with 10 additions and 15 deletions.
25 changes: 10 additions & 15 deletions fastboot/fuzzy_fastboot/fixtures.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
#include <vector>

#include <android-base/stringprintf.h>
#include <android-base/strings.h>
#include <gtest/gtest.h>

#include "fastboot_driver.h"
Expand Down Expand Up @@ -76,8 +77,7 @@ int FastBootTest::MatchFastboot(usb_ifc_info* info, const std::string& local_ser
}

bool FastBootTest::IsFastbootOverTcp() {
// serial contains ":" is treated as host ip and port number
return (device_serial.find(":") != std::string::npos);
return android::base::StartsWith(device_serial, "tcp:");
}

bool FastBootTest::UsbStillAvailible() {
Expand Down Expand Up @@ -182,19 +182,14 @@ void FastBootTest::TearDownSerial() {
}

void FastBootTest::ConnectTcpFastbootDevice() {
std::size_t found = device_serial.find(":");
if (found != std::string::npos) {
for (int i = 0; i < MAX_TCP_TRIES && !transport; i++) {
std::string error;
std::unique_ptr<Transport> tcp(
tcp::Connect(device_serial.substr(0, found), tcp::kDefaultPort, &error)
.release());
if (tcp)
transport =
std::unique_ptr<TransportSniffer>(new TransportSniffer(std::move(tcp), 0));
if (transport != nullptr) break;
std::this_thread::sleep_for(std::chrono::milliseconds(10));
}
for (int i = 0; i < MAX_TCP_TRIES && !transport; i++) {
std::string error;
std::unique_ptr<Transport> tcp(
tcp::Connect(device_serial.substr(4), tcp::kDefaultPort, &error).release());
if (tcp)
transport = std::unique_ptr<TransportSniffer>(new TransportSniffer(std::move(tcp), 0));
if (transport != nullptr) break;
std::this_thread::sleep_for(std::chrono::milliseconds(10));
}
}

Expand Down

0 comments on commit 0e743a2

Please sign in to comment.