summaryrefslogtreecommitdiffstats
path: root/fastboot/fuzzy_fastboot/fixtures.cpp
diff options
context:
space:
mode:
authorHridya Valsaraju <hridya@google.com>2019-04-10 16:31:31 -0700
committerHridya Valsaraju <hridya@google.com>2019-04-12 17:13:24 +0000
commitc18cccc227d7fdccfa5a60e4e8d20951d1f6ed89 (patch)
treeaeea716f821a6d44af8a637b2918188666529a05 /fastboot/fuzzy_fastboot/fixtures.cpp
parent1e30c33a1a364d5064e3b916d34f0d480516d790 (diff)
downloadsystem_core-c18cccc227d7fdccfa5a60e4e8d20951d1f6ed89.tar.gz
system_core-c18cccc227d7fdccfa5a60e4e8d20951d1f6ed89.tar.bz2
system_core-c18cccc227d7fdccfa5a60e4e8d20951d1f6ed89.zip
Allow fuzzy_fastboot number to run for a specific device serial number
Test: ./fuzzy_fastboot --serial=826X003L --gtest_filter=*Logical* Bug: 117181762 Change-Id: I9dec510aa604b7994f25ce26edb87d7f6ec3e875 Merged-In: I9dec510aa604b7994f25ce26edb87d7f6ec3e875 (cherry picked from commit b9051a3e6559b14759015d679c97d0e9e5fad9a4)
Diffstat (limited to 'fastboot/fuzzy_fastboot/fixtures.cpp')
-rw-r--r--fastboot/fuzzy_fastboot/fixtures.cpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/fastboot/fuzzy_fastboot/fixtures.cpp b/fastboot/fuzzy_fastboot/fixtures.cpp
index c23da01a2..bc13a8c4e 100644
--- a/fastboot/fuzzy_fastboot/fixtures.cpp
+++ b/fastboot/fuzzy_fastboot/fixtures.cpp
@@ -59,7 +59,7 @@ using namespace std::literals::chrono_literals;
namespace fastboot {
-int FastBootTest::MatchFastboot(usb_ifc_info* info, const char* local_serial) {
+int FastBootTest::MatchFastboot(usb_ifc_info* info, const std::string& local_serial) {
if (info->ifc_class != 0xff || info->ifc_subclass != 0x42 || info->ifc_protocol != 0x03) {
return -1;
}
@@ -68,8 +68,8 @@ int FastBootTest::MatchFastboot(usb_ifc_info* info, const char* local_serial) {
// require matching serial number or device path if requested
// at the command line with the -s option.
- if (local_serial && (strcmp(local_serial, info->serial_number) != 0 &&
- strcmp(local_serial, info->device_path) != 0))
+ if (!local_serial.empty() && local_serial != info->serial_number &&
+ local_serial != info->device_path)
return -1;
return 0;
}
@@ -113,7 +113,9 @@ void FastBootTest::SetUp() {
ASSERT_TRUE(UsbStillAvailible()); // The device disconnected
}
- const auto matcher = [](usb_ifc_info* info) -> int { return MatchFastboot(info, nullptr); };
+ const auto matcher = [](usb_ifc_info* info) -> int {
+ return MatchFastboot(info, device_serial);
+ };
for (int i = 0; i < MAX_USB_TRIES && !transport; i++) {
std::unique_ptr<UsbTransport> usb(usb_open(matcher, USB_TIMEOUT));
if (usb)
@@ -172,7 +174,9 @@ void FastBootTest::ReconnectFastbootDevice() {
;
printf("WAITING FOR DEVICE\n");
// Need to wait for device
- const auto matcher = [](usb_ifc_info* info) -> int { return MatchFastboot(info, nullptr); };
+ const auto matcher = [](usb_ifc_info* info) -> int {
+ return MatchFastboot(info, device_serial);
+ };
while (!transport) {
std::unique_ptr<UsbTransport> usb(usb_open(matcher, USB_TIMEOUT));
if (usb) {
@@ -238,6 +242,7 @@ std::string FastBootTest::device_path = "";
std::string FastBootTest::cb_scratch = "";
std::string FastBootTest::initial_slot = "";
int FastBootTest::serial_port = 0;
+std::string FastBootTest::device_serial = "";
template <bool UNLOCKED>
void ModeTest<UNLOCKED>::SetUp() {