diff options
author | sirius.wang <sirius.wang@mediatek.corp-partner.google.com> | 2020-07-17 11:28:06 +0800 |
---|---|---|
committer | Elliott Hughes <enh@google.com> | 2020-08-25 17:33:17 +0000 |
commit | 767fe1515a45099c3e792f586738408391cd892b (patch) | |
tree | 746003d159c058d4f7f60d68170a888936f83c6c | |
parent | b085db746a628ab4afa5bb2b74dc6798167f6f25 (diff) | |
download | core-767fe1515a45099c3e792f586738408391cd892b.tar.gz |
fuzzy_fastboot: use 'tcp:' prefix to identify fastboot protocol.
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: 157887327
Test: fuzzy_fastboot --serial=tcp:fe80::230:1bff:feba:8128%wlan0 \
--gtest_filter=*Logical*
Bug: http://b/166279510
Change-Id: I8fe7e6e3ade94a26e05a31ac20ed9ab3839dd342
Merged-In: I971fd9e25741e18bf7f5907d562556b09db1d624
-rw-r--r-- | fastboot/fuzzy_fastboot/fixtures.cpp | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/fastboot/fuzzy_fastboot/fixtures.cpp b/fastboot/fuzzy_fastboot/fixtures.cpp index bd76ff4ee..9b5e5f7bd 100644 --- a/fastboot/fuzzy_fastboot/fixtures.cpp +++ b/fastboot/fuzzy_fastboot/fixtures.cpp @@ -45,6 +45,7 @@ #include <vector> #include <android-base/stringprintf.h> +#include <android-base/strings.h> #include <gtest/gtest.h> #include "fastboot_driver.h" @@ -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() { @@ -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)); } } |