diff options
author | Xin Li | 2017-11-14 14:08:38 -0600 |
---|---|---|
committer | Xin Li | 2017-11-14 14:08:38 -0600 |
commit | bb9e38fef95b7bc932ebcad18508e03228f9f7d3 (patch) | |
tree | 29e859e08879c87f591507de0f370abd1ec66fe2 /tetheroffload/control | |
parent | b86b2d2881d53219c59a5eb85a3d73cb45942661 (diff) | |
parent | 1a06284b24f5eb7bb9c1fea0817da8898b3b1bff (diff) | |
download | platform-hardware-interfaces-bb9e38fef95b7bc932ebcad18508e03228f9f7d3.tar.gz platform-hardware-interfaces-bb9e38fef95b7bc932ebcad18508e03228f9f7d3.tar.xz platform-hardware-interfaces-bb9e38fef95b7bc932ebcad18508e03228f9f7d3.zip |
Merge commit '1a06284b24f5eb7bb9c1fea0817da8898b3b1bff' from
oc-mr1-dev-plus-aosp into stage-aosp-master
Change-Id: I2a044eb8c9981d0a8198ffe2df55559afbd76341
Merged-In: I4fb9f18884f7ef21162015a0032c4431444f7025
Diffstat (limited to 'tetheroffload/control')
-rw-r--r-- | tetheroffload/control/1.0/vts/functional/Android.bp | 15 | ||||
-rw-r--r-- | tetheroffload/control/1.0/vts/functional/VtsHalTetheroffloadControlV1_0TargetTest.cpp | 76 |
2 files changed, 61 insertions, 30 deletions
diff --git a/tetheroffload/control/1.0/vts/functional/Android.bp b/tetheroffload/control/1.0/vts/functional/Android.bp index 69fac6e5..c6216a2f 100644 --- a/tetheroffload/control/1.0/vts/functional/Android.bp +++ b/tetheroffload/control/1.0/vts/functional/Android.bp | |||
@@ -14,21 +14,10 @@ | |||
14 | 14 | ||
15 | cc_test { | 15 | cc_test { |
16 | name: "VtsHalTetheroffloadControlV1_0TargetTest", | 16 | name: "VtsHalTetheroffloadControlV1_0TargetTest", |
17 | defaults: ["hidl_defaults"], | 17 | defaults: ["VtsHalTargetTestDefaults"], |
18 | srcs: ["VtsHalTetheroffloadControlV1_0TargetTest.cpp"], | 18 | srcs: ["VtsHalTetheroffloadControlV1_0TargetTest.cpp"], |
19 | shared_libs: [ | 19 | static_libs: [ |
20 | "android.hardware.tetheroffload.config@1.0", | 20 | "android.hardware.tetheroffload.config@1.0", |
21 | "android.hardware.tetheroffload.control@1.0", | 21 | "android.hardware.tetheroffload.control@1.0", |
22 | "libbase", | ||
23 | "libcutils", | ||
24 | "libhidlbase", | ||
25 | "libhidltransport", | ||
26 | "liblog", | ||
27 | "libutils", | ||
28 | ], | ||
29 | static_libs: ["VtsHalHidlTargetTestBase"], | ||
30 | cflags: [ | ||
31 | "-O0", | ||
32 | "-g", | ||
33 | ], | 22 | ], |
34 | } | 23 | } |
diff --git a/tetheroffload/control/1.0/vts/functional/VtsHalTetheroffloadControlV1_0TargetTest.cpp b/tetheroffload/control/1.0/vts/functional/VtsHalTetheroffloadControlV1_0TargetTest.cpp index 3059eac0..c009af5d 100644 --- a/tetheroffload/control/1.0/vts/functional/VtsHalTetheroffloadControlV1_0TargetTest.cpp +++ b/tetheroffload/control/1.0/vts/functional/VtsHalTetheroffloadControlV1_0TargetTest.cpp | |||
@@ -46,6 +46,12 @@ using android::hardware::tetheroffload::control::V1_0::NetworkProtocol; | |||
46 | using android::hardware::Void; | 46 | using android::hardware::Void; |
47 | using android::sp; | 47 | using android::sp; |
48 | 48 | ||
49 | enum class ExpectBoolean { | ||
50 | Ignored = -1, | ||
51 | False = 0, | ||
52 | True = 1, | ||
53 | }; | ||
54 | |||
49 | // We use #defines here so as to get local lamba captures and error message line numbers | 55 | // We use #defines here so as to get local lamba captures and error message line numbers |
50 | #define ASSERT_TRUE_CALLBACK \ | 56 | #define ASSERT_TRUE_CALLBACK \ |
51 | [&](bool success, std::string errMsg) { \ | 57 | [&](bool success, std::string errMsg) { \ |
@@ -112,7 +118,12 @@ class OffloadControlHidlTestBase : public testing::VtsHalHidlTargetTestBase { | |||
112 | prepareControlHal(); | 118 | prepareControlHal(); |
113 | } | 119 | } |
114 | 120 | ||
115 | virtual void TearDown() override { stopOffload(false); } | 121 | virtual void TearDown() override { |
122 | // For good measure, we should try stopOffload() once more. Since we | ||
123 | // don't know where we are in HAL call test cycle we don't know what | ||
124 | // return code to actually expect, so we just ignore it. | ||
125 | stopOffload(ExpectBoolean::Ignored); | ||
126 | } | ||
116 | 127 | ||
117 | // The IOffloadConfig HAL is tested more thoroughly elsewhere. He we just | 128 | // The IOffloadConfig HAL is tested more thoroughly elsewhere. He we just |
118 | // setup everything correctly and verify basic readiness. | 129 | // setup everything correctly and verify basic readiness. |
@@ -127,7 +138,8 @@ class OffloadControlHidlTestBase : public testing::VtsHalHidlTargetTestBase { | |||
127 | } | 138 | } |
128 | native_handle_t* const nativeHandle1 = native_handle_create(1, 0); | 139 | native_handle_t* const nativeHandle1 = native_handle_create(1, 0); |
129 | nativeHandle1->data[0] = fd1.release(); | 140 | nativeHandle1->data[0] = fd1.release(); |
130 | hidl_handle h1 = hidl_handle(nativeHandle1); | 141 | hidl_handle h1; |
142 | h1.setTo(nativeHandle1, true); | ||
131 | 143 | ||
132 | unique_fd fd2(conntrackSocket(NFNLGRP_CONNTRACK_UPDATE | NFNLGRP_CONNTRACK_DESTROY)); | 144 | unique_fd fd2(conntrackSocket(NFNLGRP_CONNTRACK_UPDATE | NFNLGRP_CONNTRACK_DESTROY)); |
133 | if (fd2.get() < 0) { | 145 | if (fd2.get() < 0) { |
@@ -136,7 +148,8 @@ class OffloadControlHidlTestBase : public testing::VtsHalHidlTargetTestBase { | |||
136 | } | 148 | } |
137 | native_handle_t* const nativeHandle2 = native_handle_create(1, 0); | 149 | native_handle_t* const nativeHandle2 = native_handle_create(1, 0); |
138 | nativeHandle2->data[0] = fd2.release(); | 150 | nativeHandle2->data[0] = fd2.release(); |
139 | hidl_handle h2 = hidl_handle(nativeHandle2); | 151 | hidl_handle h2; |
152 | h2.setTo(nativeHandle2, true); | ||
140 | 153 | ||
141 | const Return<void> ret = config->setHandles(h1, h2, ASSERT_TRUE_CALLBACK); | 154 | const Return<void> ret = config->setHandles(h1, h2, ASSERT_TRUE_CALLBACK); |
142 | ASSERT_TRUE(ret.isOk()); | 155 | ASSERT_TRUE(ret.isOk()); |
@@ -166,12 +179,21 @@ class OffloadControlHidlTestBase : public testing::VtsHalHidlTargetTestBase { | |||
166 | initOffload(true); | 179 | initOffload(true); |
167 | } | 180 | } |
168 | 181 | ||
169 | void stopOffload(const bool expected_result) { | 182 | void stopOffload(const ExpectBoolean value) { |
170 | auto cb = [&](bool success, const hidl_string& errMsg) { | 183 | auto cb = [&](bool success, const hidl_string& errMsg) { |
171 | if (!success) { | 184 | if (!success) { |
172 | ALOGI("Error message: %s", errMsg.c_str()); | 185 | ALOGI("Error message: %s", errMsg.c_str()); |
173 | } | 186 | } |
174 | ASSERT_EQ(expected_result, success); | 187 | switch (value) { |
188 | case ExpectBoolean::False: | ||
189 | ASSERT_EQ(false, success); | ||
190 | break; | ||
191 | case ExpectBoolean::True: | ||
192 | ASSERT_EQ(true, success); | ||
193 | break; | ||
194 | case ExpectBoolean::Ignored: | ||
195 | break; | ||
196 | } | ||
175 | }; | 197 | }; |
176 | const Return<void> ret = control->stopOffload(cb); | 198 | const Return<void> ret = control->stopOffload(cb); |
177 | ASSERT_TRUE(ret.isOk()); | 199 | ASSERT_TRUE(ret.isOk()); |
@@ -209,22 +231,29 @@ TEST_F(OffloadControlHidlTestBase, AdditionalInitsWithoutStopReturnFalse) { | |||
209 | initOffload(false); | 231 | initOffload(false); |
210 | initOffload(false); | 232 | initOffload(false); |
211 | initOffload(false); | 233 | initOffload(false); |
212 | stopOffload(true); // balance out initOffload(true) | ||
213 | } | 234 | } |
214 | 235 | ||
215 | // Check that calling stopOffload() without first having called initOffload() returns false. | 236 | // Check that calling stopOffload() without first having called initOffload() returns false. |
216 | TEST_F(OffloadControlHidlTestBase, MultipleStopsWithoutInitReturnFalse) { | 237 | TEST_F(OffloadControlHidlTestBase, MultipleStopsWithoutInitReturnFalse) { |
217 | stopOffload(false); | 238 | stopOffload(ExpectBoolean::False); |
218 | stopOffload(false); | 239 | stopOffload(ExpectBoolean::False); |
219 | stopOffload(false); | 240 | stopOffload(ExpectBoolean::False); |
220 | } | 241 | } |
221 | 242 | ||
222 | // Check that calling stopOffload() after a complete init/stop cycle returns false. | 243 | // Check that calling stopOffload() after a complete init/stop cycle returns false. |
223 | TEST_F(OffloadControlHidlTestBase, AdditionalStopsWithInitReturnFalse) { | 244 | TEST_F(OffloadControlHidlTestBase, AdditionalStopsWithInitReturnFalse) { |
224 | initOffload(true); | 245 | initOffload(true); |
225 | stopOffload(true); // balance out initOffload(true) | 246 | // Call setUpstreamParameters() so that "offload" can be reasonably said |
226 | stopOffload(false); | 247 | // to be both requested and operational. |
227 | stopOffload(false); | 248 | const hidl_string v4Addr("192.0.0.2"); |
249 | const hidl_string v4Gw("192.0.0.1"); | ||
250 | const vector<hidl_string> v6Gws{hidl_string("fe80::db8:1"), hidl_string("fe80::db8:2")}; | ||
251 | const Return<void> upstream = | ||
252 | control->setUpstreamParameters("rmnet_data0", v4Addr, v4Gw, v6Gws, ASSERT_TRUE_CALLBACK); | ||
253 | EXPECT_TRUE(upstream.isOk()); | ||
254 | stopOffload(ExpectBoolean::True); // balance out initOffload(true) | ||
255 | stopOffload(ExpectBoolean::False); | ||
256 | stopOffload(ExpectBoolean::False); | ||
228 | } | 257 | } |
229 | 258 | ||
230 | // Check that calling setLocalPrefixes() without first having called initOffload() returns false. | 259 | // Check that calling setLocalPrefixes() without first having called initOffload() returns false. |
@@ -305,7 +334,12 @@ class OffloadControlHidlTest : public OffloadControlHidlTestBase { | |||
305 | setupControlHal(); | 334 | setupControlHal(); |
306 | } | 335 | } |
307 | 336 | ||
308 | virtual void TearDown() override { stopOffload(true); } | 337 | virtual void TearDown() override { |
338 | // For good measure, we should try stopOffload() once more. Since we | ||
339 | // don't know where we are in HAL call test cycle we don't know what | ||
340 | // return code to actually expect, so we just ignore it. | ||
341 | stopOffload(ExpectBoolean::Ignored); | ||
342 | } | ||
309 | }; | 343 | }; |
310 | 344 | ||
311 | /* | 345 | /* |
@@ -575,16 +609,24 @@ TEST_F(OffloadControlHidlTest, AddDownstreamBogusPrefixFails) { | |||
575 | TEST_F(OffloadControlHidlTest, RemoveDownstreamIPv4) { | 609 | TEST_F(OffloadControlHidlTest, RemoveDownstreamIPv4) { |
576 | const hidl_string iface("dummy0"); | 610 | const hidl_string iface("dummy0"); |
577 | const hidl_string prefix("192.0.2.0/24"); | 611 | const hidl_string prefix("192.0.2.0/24"); |
578 | const Return<void> ret = control->removeDownstream(iface, prefix, ASSERT_TRUE_CALLBACK); | 612 | // First add the downstream, otherwise removeDownstream logic can reasonably |
579 | EXPECT_TRUE(ret.isOk()); | 613 | // return false for downstreams not previously added. |
614 | const Return<void> add = control->addDownstream(iface, prefix, ASSERT_TRUE_CALLBACK); | ||
615 | EXPECT_TRUE(add.isOk()); | ||
616 | const Return<void> del = control->removeDownstream(iface, prefix, ASSERT_TRUE_CALLBACK); | ||
617 | EXPECT_TRUE(del.isOk()); | ||
580 | } | 618 | } |
581 | 619 | ||
582 | // Test removeDownstream() works given an IPv6 prefix. | 620 | // Test removeDownstream() works given an IPv6 prefix. |
583 | TEST_F(OffloadControlHidlTest, RemoveDownstreamIPv6) { | 621 | TEST_F(OffloadControlHidlTest, RemoveDownstreamIPv6) { |
584 | const hidl_string iface("dummy0"); | 622 | const hidl_string iface("dummy0"); |
585 | const hidl_string prefix("2001:db8::/64"); | 623 | const hidl_string prefix("2001:db8::/64"); |
586 | const Return<void> ret = control->removeDownstream(iface, prefix, ASSERT_TRUE_CALLBACK); | 624 | // First add the downstream, otherwise removeDownstream logic can reasonably |
587 | EXPECT_TRUE(ret.isOk()); | 625 | // return false for downstreams not previously added. |
626 | const Return<void> add = control->addDownstream(iface, prefix, ASSERT_TRUE_CALLBACK); | ||
627 | EXPECT_TRUE(add.isOk()); | ||
628 | const Return<void> del = control->removeDownstream(iface, prefix, ASSERT_TRUE_CALLBACK); | ||
629 | EXPECT_TRUE(del.isOk()); | ||
588 | } | 630 | } |
589 | 631 | ||
590 | // Test removeDownstream() fails given all empty parameters. | 632 | // Test removeDownstream() fails given all empty parameters. |