summaryrefslogtreecommitdiffstats
path: root/boot
diff options
context:
space:
mode:
authorConnor O'Brien2018-02-21 18:35:48 -0600
committerConnor O'Brien2018-02-23 15:54:53 -0600
commitbb7ce50918a1851ec53b383fb26522d16c43b880 (patch)
treea019637ecc7322f3c8887c706d3c77be3a740093 /boot
parent9be06304d6ee75730bc8e8e9dd991658efae0090 (diff)
downloadplatform-hardware-interfaces-bb7ce50918a1851ec53b383fb26522d16c43b880.tar.gz
platform-hardware-interfaces-bb7ce50918a1851ec53b383fb26522d16c43b880.tar.xz
platform-hardware-interfaces-bb7ce50918a1851ec53b383fb26522d16c43b880.zip
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 <connoro@google.com>
Diffstat (limited to 'boot')
-rw-r--r--boot/1.0/vts/functional/VtsHalBootV1_0TargetTest.cpp13
1 files 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 d1d7f73b..2f2052c8 100644
--- a/boot/1.0/vts/functional/VtsHalBootV1_0TargetTest.cpp
+++ b/boot/1.0/vts/functional/VtsHalBootV1_0TargetTest.cpp
@@ -24,6 +24,8 @@
24#include <VtsHalHidlTargetTestBase.h> 24#include <VtsHalHidlTargetTestBase.h>
25#include <VtsHalHidlTargetTestEnvBase.h> 25#include <VtsHalHidlTargetTestEnvBase.h>
26 26
27#include <unordered_set>
28
27using ::android::hardware::boot::V1_0::IBootControl; 29using ::android::hardware::boot::V1_0::IBootControl;
28using ::android::hardware::boot::V1_0::CommandResult; 30using ::android::hardware::boot::V1_0::CommandResult;
29using ::android::hardware::boot::V1_0::BoolResult; 31using ::android::hardware::boot::V1_0::BoolResult;
@@ -32,6 +34,7 @@ using ::android::hardware::hidl_string;
32using ::android::hardware::Return; 34using ::android::hardware::Return;
33using ::android::sp; 35using ::android::sp;
34using std::string; 36using std::string;
37using std::unordered_set;
35using std::vector; 38using std::vector;
36 39
37// Test environment for Boot HIDL HAL. 40// Test environment for Boot HIDL HAL.
@@ -168,14 +171,18 @@ TEST_F(BootHidlTest, IsSlotMarkedSuccessful) {
168// Sanity check Boot::getSuffix() on good and bad inputs. 171// Sanity check Boot::getSuffix() on good and bad inputs.
169TEST_F(BootHidlTest, GetSuffix) { 172TEST_F(BootHidlTest, GetSuffix) {
170 string suffixStr; 173 string suffixStr;
171 vector<string> correctSuffixes = {"_a", "_b"}; 174 unordered_set<string> suffixes;
172 auto cb = [&](hidl_string suffix) { suffixStr = suffix.c_str(); }; 175 auto cb = [&](hidl_string suffix) { suffixStr = suffix.c_str(); };
173 for (Slot i = 0; i < 2; i++) { 176 for (Slot i = 0; i < boot->getNumberSlots(); i++) {
174 CommandResult cr; 177 CommandResult cr;
175 Return<void> result = boot->getSuffix(i, cb); 178 Return<void> result = boot->getSuffix(i, cb);
176 EXPECT_TRUE(result.isOk()); 179 EXPECT_TRUE(result.isOk());
177 ASSERT_EQ(0, suffixStr.compare(correctSuffixes[i])); 180 ASSERT_EQ('_', suffixStr[0]);
181 ASSERT_LE((unsigned)2, suffixStr.size());
182 suffixes.insert(suffixStr);
178 } 183 }
184 // All suffixes should be unique
185 ASSERT_EQ(boot->getNumberSlots(), suffixes.size());
179 { 186 {
180 string emptySuffix = ""; 187 string emptySuffix = "";
181 Return<void> result = boot->getSuffix(boot->getNumberSlots(), cb); 188 Return<void> result = boot->getSuffix(boot->getNumberSlots(), cb);