From bdc14294540e49b7750272c39927edbf5b3e661b Mon Sep 17 00:00:00 2001 From: Hridya Valsaraju Date: Wed, 3 Oct 2018 17:08:32 -0700 Subject: [PATCH] Allow Conformance tests to verify userspace fastboot. Bug: 117220134 Test: ./fuzzy_fastboot --gtest_filter=Conformance.* Change-Id: Iab04fdff71e7e90a56d53d24cf14e94c81131009 --- fastboot/fuzzy_fastboot/fixtures.cpp | 12 ++++++++++++ fastboot/fuzzy_fastboot/fixtures.h | 1 + fastboot/fuzzy_fastboot/main.cpp | 10 ++++++++++ 3 files changed, 23 insertions(+) diff --git a/fastboot/fuzzy_fastboot/fixtures.cpp b/fastboot/fuzzy_fastboot/fixtures.cpp index c18af1d8d..280cfb691 100644 --- a/fastboot/fuzzy_fastboot/fixtures.cpp +++ b/fastboot/fuzzy_fastboot/fixtures.cpp @@ -86,6 +86,12 @@ bool FastBootTest::UsbStillAvailible() { return true; } +bool FastBootTest::UserSpaceFastboot() { + std::string value; + fb->GetVar("is-userspace", &value); + return value == "yes"; +} + RetCode FastBootTest::DownloadCommand(uint32_t size, std::string* response, std::vector* info) { return fb->DownloadCommand(size, response, info); @@ -158,6 +164,12 @@ void FastBootTest::SetLockState(bool unlock, bool assert_change) { return; } + // User space fastboot implementations are not allowed to communicate to + // secure hardware and hence cannot lock/unlock the device. + if (UserSpaceFastboot()) { + return; + } + std::string resp; std::vector info; // To avoid risk of bricking device, make sure unlock ability is set to 1 diff --git a/fastboot/fuzzy_fastboot/fixtures.h b/fastboot/fuzzy_fastboot/fixtures.h index e47d0fd80..e0f829e48 100644 --- a/fastboot/fuzzy_fastboot/fixtures.h +++ b/fastboot/fuzzy_fastboot/fixtures.h @@ -47,6 +47,7 @@ class FastBootTest : public testing::Test { static int MatchFastboot(usb_ifc_info* info, const char* local_serial = nullptr); bool UsbStillAvailible(); + bool UserSpaceFastboot(); protected: RetCode DownloadCommand(uint32_t size, std::string* response = nullptr, diff --git a/fastboot/fuzzy_fastboot/main.cpp b/fastboot/fuzzy_fastboot/main.cpp index 90a2e74ee..e2076f5bb 100644 --- a/fastboot/fuzzy_fastboot/main.cpp +++ b/fastboot/fuzzy_fastboot/main.cpp @@ -289,6 +289,12 @@ TEST_F(Conformance, GetVarAll) { TEST_F(Conformance, UnlockAbility) { std::string resp; std::vector info; + // Userspace fastboot implementations do not have a way to get this + // information. + if (UserSpaceFastboot()) { + GTEST_LOG_(INFO) << "This test is skipped for userspace fastboot."; + return; + } EXPECT_EQ(fb->RawCommand("flashing get_unlock_ability", &resp, &info), SUCCESS) << "'flashing get_unlock_ability' failed"; // There are two ways this can be reported, through info or the actual response @@ -412,6 +418,10 @@ TEST_F(Conformance, LockAndUnlockPrompt) { ASSERT_TRUE(resp == "yes" || resp == "no") << "Device did not respond with 'yes' or 'no' for getvar:unlocked"; bool curr = resp == "yes"; + if (UserSpaceFastboot()) { + GTEST_LOG_(INFO) << "This test is skipped for userspace fastboot."; + return; + } for (int i = 0; i < 2; i++) { std::string action = !curr ? "unlock" : "lock";