Loading fastboot/fuzzy_fastboot/fixtures.cpp +10 −5 Original line number Diff line number Diff line Loading @@ -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; } Loading @@ -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; } Loading Loading @@ -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) Loading Loading @@ -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) { Loading Loading @@ -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() { Loading fastboot/fuzzy_fastboot/fixtures.h +2 −1 Original line number Diff line number Diff line Loading @@ -43,9 +43,10 @@ constexpr char USB_PORT_GONE[] = class FastBootTest : public testing::Test { public: static int serial_port; static std::string device_serial; static constexpr int MAX_USB_TRIES = 10; static int MatchFastboot(usb_ifc_info* info, const char* local_serial = nullptr); static int MatchFastboot(usb_ifc_info* info, const std::string& local_serial = ""); bool UsbStillAvailible(); bool UserSpaceFastboot(); void ReconnectFastbootDevice(); Loading fastboot/fuzzy_fastboot/main.cpp +6 −2 Original line number Diff line number Diff line Loading @@ -162,7 +162,7 @@ const auto not_allowed = [](char c) -> int { // Test that USB even works TEST(USBFunctionality, USBConnect) { const auto matcher = [](usb_ifc_info* info) -> int { return FastBootTest::MatchFastboot(info, nullptr); return FastBootTest::MatchFastboot(info, fastboot::FastBootTest::device_serial); }; Transport* transport = nullptr; for (int i = 0; i < FastBootTest::MAX_USB_TRIES && !transport; i++) { Loading Loading @@ -1738,10 +1738,14 @@ int main(int argc, char** argv) { fastboot::GenerateXmlTests(fastboot::config); } if (args.find("serial") != args.end()) { fastboot::FastBootTest::device_serial = args.at("serial"); } setbuf(stdout, NULL); // no buffering printf("<Waiting for Device>\n"); const auto matcher = [](usb_ifc_info* info) -> int { return fastboot::FastBootTest::MatchFastboot(info, nullptr); return fastboot::FastBootTest::MatchFastboot(info, fastboot::FastBootTest::device_serial); }; Transport* transport = nullptr; while (!transport) { Loading Loading
fastboot/fuzzy_fastboot/fixtures.cpp +10 −5 Original line number Diff line number Diff line Loading @@ -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; } Loading @@ -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; } Loading Loading @@ -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) Loading Loading @@ -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) { Loading Loading @@ -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() { Loading
fastboot/fuzzy_fastboot/fixtures.h +2 −1 Original line number Diff line number Diff line Loading @@ -43,9 +43,10 @@ constexpr char USB_PORT_GONE[] = class FastBootTest : public testing::Test { public: static int serial_port; static std::string device_serial; static constexpr int MAX_USB_TRIES = 10; static int MatchFastboot(usb_ifc_info* info, const char* local_serial = nullptr); static int MatchFastboot(usb_ifc_info* info, const std::string& local_serial = ""); bool UsbStillAvailible(); bool UserSpaceFastboot(); void ReconnectFastbootDevice(); Loading
fastboot/fuzzy_fastboot/main.cpp +6 −2 Original line number Diff line number Diff line Loading @@ -162,7 +162,7 @@ const auto not_allowed = [](char c) -> int { // Test that USB even works TEST(USBFunctionality, USBConnect) { const auto matcher = [](usb_ifc_info* info) -> int { return FastBootTest::MatchFastboot(info, nullptr); return FastBootTest::MatchFastboot(info, fastboot::FastBootTest::device_serial); }; Transport* transport = nullptr; for (int i = 0; i < FastBootTest::MAX_USB_TRIES && !transport; i++) { Loading Loading @@ -1738,10 +1738,14 @@ int main(int argc, char** argv) { fastboot::GenerateXmlTests(fastboot::config); } if (args.find("serial") != args.end()) { fastboot::FastBootTest::device_serial = args.at("serial"); } setbuf(stdout, NULL); // no buffering printf("<Waiting for Device>\n"); const auto matcher = [](usb_ifc_info* info) -> int { return fastboot::FastBootTest::MatchFastboot(info, nullptr); return fastboot::FastBootTest::MatchFastboot(info, fastboot::FastBootTest::device_serial); }; Transport* transport = nullptr; while (!transport) { Loading