system/core
Révision | c18cccc227d7fdccfa5a60e4e8d20951d1f6ed89 (tree) |
---|---|
l'heure | 2019-04-13 02:13:24 |
Auteur | Hridya Valsaraju <hridya@goog...> |
Commiter | Hridya Valsaraju |
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)
@@ -59,7 +59,7 @@ using namespace std::literals::chrono_literals; | ||
59 | 59 | |
60 | 60 | namespace fastboot { |
61 | 61 | |
62 | -int FastBootTest::MatchFastboot(usb_ifc_info* info, const char* local_serial) { | |
62 | +int FastBootTest::MatchFastboot(usb_ifc_info* info, const std::string& local_serial) { | |
63 | 63 | if (info->ifc_class != 0xff || info->ifc_subclass != 0x42 || info->ifc_protocol != 0x03) { |
64 | 64 | return -1; |
65 | 65 | } |
@@ -68,8 +68,8 @@ int FastBootTest::MatchFastboot(usb_ifc_info* info, const char* local_serial) { | ||
68 | 68 | |
69 | 69 | // require matching serial number or device path if requested |
70 | 70 | // at the command line with the -s option. |
71 | - if (local_serial && (strcmp(local_serial, info->serial_number) != 0 && | |
72 | - strcmp(local_serial, info->device_path) != 0)) | |
71 | + if (!local_serial.empty() && local_serial != info->serial_number && | |
72 | + local_serial != info->device_path) | |
73 | 73 | return -1; |
74 | 74 | return 0; |
75 | 75 | } |
@@ -113,7 +113,9 @@ void FastBootTest::SetUp() { | ||
113 | 113 | ASSERT_TRUE(UsbStillAvailible()); // The device disconnected |
114 | 114 | } |
115 | 115 | |
116 | - const auto matcher = [](usb_ifc_info* info) -> int { return MatchFastboot(info, nullptr); }; | |
116 | + const auto matcher = [](usb_ifc_info* info) -> int { | |
117 | + return MatchFastboot(info, device_serial); | |
118 | + }; | |
117 | 119 | for (int i = 0; i < MAX_USB_TRIES && !transport; i++) { |
118 | 120 | std::unique_ptr<UsbTransport> usb(usb_open(matcher, USB_TIMEOUT)); |
119 | 121 | if (usb) |
@@ -172,7 +174,9 @@ void FastBootTest::ReconnectFastbootDevice() { | ||
172 | 174 | ; |
173 | 175 | printf("WAITING FOR DEVICE\n"); |
174 | 176 | // Need to wait for device |
175 | - const auto matcher = [](usb_ifc_info* info) -> int { return MatchFastboot(info, nullptr); }; | |
177 | + const auto matcher = [](usb_ifc_info* info) -> int { | |
178 | + return MatchFastboot(info, device_serial); | |
179 | + }; | |
176 | 180 | while (!transport) { |
177 | 181 | std::unique_ptr<UsbTransport> usb(usb_open(matcher, USB_TIMEOUT)); |
178 | 182 | if (usb) { |
@@ -238,6 +242,7 @@ std::string FastBootTest::device_path = ""; | ||
238 | 242 | std::string FastBootTest::cb_scratch = ""; |
239 | 243 | std::string FastBootTest::initial_slot = ""; |
240 | 244 | int FastBootTest::serial_port = 0; |
245 | +std::string FastBootTest::device_serial = ""; | |
241 | 246 | |
242 | 247 | template <bool UNLOCKED> |
243 | 248 | void ModeTest<UNLOCKED>::SetUp() { |
@@ -43,9 +43,10 @@ constexpr char USB_PORT_GONE[] = | ||
43 | 43 | class FastBootTest : public testing::Test { |
44 | 44 | public: |
45 | 45 | static int serial_port; |
46 | + static std::string device_serial; | |
46 | 47 | static constexpr int MAX_USB_TRIES = 10; |
47 | 48 | |
48 | - static int MatchFastboot(usb_ifc_info* info, const char* local_serial = nullptr); | |
49 | + static int MatchFastboot(usb_ifc_info* info, const std::string& local_serial = ""); | |
49 | 50 | bool UsbStillAvailible(); |
50 | 51 | bool UserSpaceFastboot(); |
51 | 52 | void ReconnectFastbootDevice(); |
@@ -162,7 +162,7 @@ const auto not_allowed = [](char c) -> int { | ||
162 | 162 | // Test that USB even works |
163 | 163 | TEST(USBFunctionality, USBConnect) { |
164 | 164 | const auto matcher = [](usb_ifc_info* info) -> int { |
165 | - return FastBootTest::MatchFastboot(info, nullptr); | |
165 | + return FastBootTest::MatchFastboot(info, fastboot::FastBootTest::device_serial); | |
166 | 166 | }; |
167 | 167 | Transport* transport = nullptr; |
168 | 168 | for (int i = 0; i < FastBootTest::MAX_USB_TRIES && !transport; i++) { |
@@ -1738,10 +1738,14 @@ int main(int argc, char** argv) { | ||
1738 | 1738 | fastboot::GenerateXmlTests(fastboot::config); |
1739 | 1739 | } |
1740 | 1740 | |
1741 | + if (args.find("serial") != args.end()) { | |
1742 | + fastboot::FastBootTest::device_serial = args.at("serial"); | |
1743 | + } | |
1744 | + | |
1741 | 1745 | setbuf(stdout, NULL); // no buffering |
1742 | 1746 | printf("<Waiting for Device>\n"); |
1743 | 1747 | const auto matcher = [](usb_ifc_info* info) -> int { |
1744 | - return fastboot::FastBootTest::MatchFastboot(info, nullptr); | |
1748 | + return fastboot::FastBootTest::MatchFastboot(info, fastboot::FastBootTest::device_serial); | |
1745 | 1749 | }; |
1746 | 1750 | Transport* transport = nullptr; |
1747 | 1751 | while (!transport) { |