summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorandroid-build-team Robot2018-05-14 02:22:59 -0500
committerandroid-build-team Robot2018-05-14 02:22:59 -0500
commit4a4181c363f970a2e009abe7b7537f6d643aba82 (patch)
treed98565f18bae958801740a5c4f79570e4e95aafe
parent5753b07c0ad86dfbe4eec97632b04c3e1cf6335a (diff)
parent5acc0b1fa3b2793a85465d4342388c5c81664810 (diff)
downloadplatform-hardware-interfaces-4a4181c363f970a2e009abe7b7537f6d643aba82.tar.gz
platform-hardware-interfaces-4a4181c363f970a2e009abe7b7537f6d643aba82.tar.xz
platform-hardware-interfaces-4a4181c363f970a2e009abe7b7537f6d643aba82.zip
Snap for 4779114 from 5acc0b1fa3b2793a85465d4342388c5c81664810 to pi-release
Change-Id: I5bc95aee3c7ec5faae4805d83223d43c27ff4341
-rw-r--r--tetheroffload/control/1.0/vts/functional/VtsHalTetheroffloadControlV1_0TargetTest.cpp40
1 files changed, 17 insertions, 23 deletions
diff --git a/tetheroffload/control/1.0/vts/functional/VtsHalTetheroffloadControlV1_0TargetTest.cpp b/tetheroffload/control/1.0/vts/functional/VtsHalTetheroffloadControlV1_0TargetTest.cpp
index 4eef4ec6..03b6406d 100644
--- a/tetheroffload/control/1.0/vts/functional/VtsHalTetheroffloadControlV1_0TargetTest.cpp
+++ b/tetheroffload/control/1.0/vts/functional/VtsHalTetheroffloadControlV1_0TargetTest.cpp
@@ -26,7 +26,6 @@
26#include <android/hardware/tetheroffload/control/1.0/types.h> 26#include <android/hardware/tetheroffload/control/1.0/types.h>
27#include <linux/netfilter/nfnetlink.h> 27#include <linux/netfilter/nfnetlink.h>
28#include <linux/netlink.h> 28#include <linux/netlink.h>
29#include <log/log.h>
30#include <net/if.h> 29#include <net/if.h>
31#include <sys/socket.h> 30#include <sys/socket.h>
32#include <unistd.h> 31#include <unistd.h>
@@ -57,20 +56,16 @@ enum class ExpectBoolean {
57constexpr const char* TEST_IFACE = "rmnet_data0"; 56constexpr const char* TEST_IFACE = "rmnet_data0";
58 57
59// We use #defines here so as to get local lamba captures and error message line numbers 58// We use #defines here so as to get local lamba captures and error message line numbers
60#define ASSERT_TRUE_CALLBACK \ 59#define ASSERT_TRUE_CALLBACK \
61 [&](bool success, std::string errMsg) { \ 60 [&](bool success, std::string errMsg) { \
62 if (!success) { \ 61 std::string msg = StringPrintf("unexpected error: %s", errMsg.c_str()); \
63 ALOGI("Error message: %s", errMsg.c_str()); \ 62 ASSERT_TRUE(success) << msg; \
64 } \
65 ASSERT_TRUE(success); \
66 } 63 }
67 64
68#define ASSERT_FALSE_CALLBACK \ 65#define ASSERT_FALSE_CALLBACK \
69 [&](bool success, std::string errMsg) { \ 66 [&](bool success, std::string errMsg) { \
70 if (!success) { \ 67 std::string msg = StringPrintf("expected error: %s", errMsg.c_str()); \
71 ALOGI("Error message: %s", errMsg.c_str()); \ 68 ASSERT_FALSE(success) << msg; \
72 } \
73 ASSERT_FALSE(success); \
74 } 69 }
75 70
76#define ASSERT_ZERO_BYTES_CALLBACK \ 71#define ASSERT_ZERO_BYTES_CALLBACK \
@@ -188,10 +183,9 @@ class OffloadControlHidlTestBase : public testing::VtsHalHidlTargetTestBase {
188 183
189 void initOffload(const bool expected_result) { 184 void initOffload(const bool expected_result) {
190 auto init_cb = [&](bool success, std::string errMsg) { 185 auto init_cb = [&](bool success, std::string errMsg) {
191 if (!success) { 186 std::string msg = StringPrintf("Unexpectedly %s to init offload: %s",
192 ALOGI("Error message: %s", errMsg.c_str()); 187 success ? "succeeded" : "failed", errMsg.c_str());
193 } 188 ASSERT_EQ(expected_result, success) << msg;
194 ASSERT_EQ(expected_result, success);
195 }; 189 };
196 const Return<void> ret = control->initOffload(control_cb, init_cb); 190 const Return<void> ret = control->initOffload(control_cb, init_cb);
197 ASSERT_TRUE(ret.isOk()); 191 ASSERT_TRUE(ret.isOk());
@@ -204,15 +198,12 @@ class OffloadControlHidlTestBase : public testing::VtsHalHidlTargetTestBase {
204 198
205 void stopOffload(const ExpectBoolean value) { 199 void stopOffload(const ExpectBoolean value) {
206 auto cb = [&](bool success, const hidl_string& errMsg) { 200 auto cb = [&](bool success, const hidl_string& errMsg) {
207 if (!success) {
208 ALOGI("Error message: %s", errMsg.c_str());
209 }
210 switch (value) { 201 switch (value) {
211 case ExpectBoolean::False: 202 case ExpectBoolean::False:
212 ASSERT_EQ(false, success); 203 ASSERT_EQ(false, success) << "Unexpectedly able to stop offload: " << errMsg;
213 break; 204 break;
214 case ExpectBoolean::True: 205 case ExpectBoolean::True:
215 ASSERT_EQ(true, success); 206 ASSERT_EQ(true, success) << "Unexpectedly failed to stop offload: " << errMsg;
216 break; 207 break;
217 case ExpectBoolean::Ignored: 208 case ExpectBoolean::Ignored:
218 break; 209 break;
@@ -289,8 +280,11 @@ TEST_F(OffloadControlHidlTestBase, AdditionalStopsWithInitReturnFalse) {
289 if (!interfaceIsUp(TEST_IFACE)) { 280 if (!interfaceIsUp(TEST_IFACE)) {
290 return; 281 return;
291 } 282 }
292 stopOffload(ExpectBoolean::True); // balance out initOffload(true) 283 SCOPED_TRACE("Expecting stopOffload to succeed");
284 stopOffload(ExpectBoolean::Ignored); // balance out initOffload(true)
285 SCOPED_TRACE("Expecting stopOffload to fail the first time");
293 stopOffload(ExpectBoolean::False); 286 stopOffload(ExpectBoolean::False);
287 SCOPED_TRACE("Expecting stopOffload to fail the second time");
294 stopOffload(ExpectBoolean::False); 288 stopOffload(ExpectBoolean::False);
295} 289}
296 290