From bb7ce50918a1851ec53b383fb26522d16c43b880 Mon Sep 17 00:00:00 2001 From: Connor O'Brien Date: Wed, 21 Feb 2018 16:35:48 -0800 Subject: [PATCH] Fix boot VTS GetSuffix test Rather than requiring "_a" and "_b" specifically, check format and uniqueness of each suffix. Bug: 69795155 Test: vts-tradefed run vts -m VtsHalBootV1_0Target Change-Id: Iaf626a31b499ef74fd3c21b0a0757424a0def457 Signed-off-by: Connor O'Brien --- .../1.0/vts/functional/VtsHalBootV1_0TargetTest.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/boot/1.0/vts/functional/VtsHalBootV1_0TargetTest.cpp b/boot/1.0/vts/functional/VtsHalBootV1_0TargetTest.cpp index d1d7f73b6e..2f2052c830 100644 --- a/boot/1.0/vts/functional/VtsHalBootV1_0TargetTest.cpp +++ b/boot/1.0/vts/functional/VtsHalBootV1_0TargetTest.cpp @@ -24,6 +24,8 @@ #include #include +#include + using ::android::hardware::boot::V1_0::IBootControl; using ::android::hardware::boot::V1_0::CommandResult; using ::android::hardware::boot::V1_0::BoolResult; @@ -32,6 +34,7 @@ using ::android::hardware::hidl_string; using ::android::hardware::Return; using ::android::sp; using std::string; +using std::unordered_set; using std::vector; // Test environment for Boot HIDL HAL. @@ -168,14 +171,18 @@ TEST_F(BootHidlTest, IsSlotMarkedSuccessful) { // Sanity check Boot::getSuffix() on good and bad inputs. TEST_F(BootHidlTest, GetSuffix) { string suffixStr; - vector correctSuffixes = {"_a", "_b"}; + unordered_set suffixes; auto cb = [&](hidl_string suffix) { suffixStr = suffix.c_str(); }; - for (Slot i = 0; i < 2; i++) { + for (Slot i = 0; i < boot->getNumberSlots(); i++) { CommandResult cr; Return result = boot->getSuffix(i, cb); EXPECT_TRUE(result.isOk()); - ASSERT_EQ(0, suffixStr.compare(correctSuffixes[i])); + ASSERT_EQ('_', suffixStr[0]); + ASSERT_LE((unsigned)2, suffixStr.size()); + suffixes.insert(suffixStr); } + // All suffixes should be unique + ASSERT_EQ(boot->getNumberSlots(), suffixes.size()); { string emptySuffix = ""; Return result = boot->getSuffix(boot->getNumberSlots(), cb);