diff options
author | Lorenzo Colitti | 2018-05-11 02:35:20 -0500 |
---|---|---|
committer | Lorenzo Colitti | 2018-05-11 03:02:42 -0500 |
commit | 5f9aec4f541fc72e521b688b1d686a6bc3b4b1cb (patch) | |
tree | 8a05d54b3f68c3110bec2c1511f240c891e9683f /tetheroffload/control | |
parent | 73bfa71121f882493ca63265926b8e7979cde46f (diff) | |
download | platform-hardware-interfaces-5f9aec4f541fc72e521b688b1d686a6bc3b4b1cb.tar.gz platform-hardware-interfaces-5f9aec4f541fc72e521b688b1d686a6bc3b4b1cb.tar.xz platform-hardware-interfaces-5f9aec4f541fc72e521b688b1d686a6bc3b4b1cb.zip |
Add debugging to VtsHalTetherOffloadControl test.
1. Move the detailed failure statements from ALOGI statements to
assertion failure messages.
2. Add SCOPED_TRACEs to AdditionalStopsWithInitReturnFalse.
Bug: 77996655
Test: Builds. Error messages visible in assertions.
Change-Id: Ife0607e792175ab22d1467b1fe2926107fee1e6a
Diffstat (limited to 'tetheroffload/control')
-rw-r--r-- | tetheroffload/control/1.0/vts/functional/VtsHalTetheroffloadControlV1_0TargetTest.cpp | 38 |
1 files changed, 16 insertions, 22 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..2cd98626 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 { | |||
57 | constexpr const char* TEST_IFACE = "rmnet_data0"; | 56 | constexpr 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 | } |
283 | SCOPED_TRACE("Expecting stopOffload to succeed"); | ||
292 | stopOffload(ExpectBoolean::True); // balance out initOffload(true) | 284 | stopOffload(ExpectBoolean::True); // 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 | ||