Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b9051a3e authored by Hridya Valsaraju's avatar Hridya Valsaraju
Browse files

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
parent 21aa749e
Loading
Loading
Loading
Loading
+10 −5
Original line number Diff line number Diff line
@@ -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() {
+2 −1
Original line number Diff line number Diff line
@@ -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();
+6 −2
Original line number Diff line number Diff line
@@ -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++) {
@@ -1728,10 +1728,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) {