summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorandroid-build-team Robot2017-10-27 09:50:01 -0500
committerandroid-build-team Robot2017-10-27 09:50:01 -0500
commit3d522614ec13d9d3911a81789c6776332b82cb43 (patch)
tree37c6f008c944c7b379545bf749796644af5b8377
parent6f11e984b1373c22a1601d95b4fe647271479929 (diff)
parent7d47ed708ea3f2d372347584925a3ab6a8b20852 (diff)
downloadplatform-hardware-interfaces-android-cts-8.1_r2.tar.gz
platform-hardware-interfaces-android-cts-8.1_r2.tar.xz
platform-hardware-interfaces-android-cts-8.1_r2.zip
Merge cherrypicks of [3134552, 3130583, 3131953, 3131954, 3131955, 3131956, 3131957, 3131958, 3131959, 3132062, 3132336, 3131074, 3133939, 3131024, 3131025, 3131026, 3130584, 3130879, 3130880] into oc-mr1-releaseandroid-cts-8.1_r2android-cts-8.1_r1android-8.1.0_r6android-8.1.0_r5android-8.1.0_r4android-8.1.0_r3android-8.1.0_r1
Change-Id: I06faeaf1e282dbf73aaa082e2944c5ea563f45fa
-rw-r--r--tetheroffload/control/1.0/vts/functional/VtsHalTetheroffloadControlV1_0TargetTest.cpp68
1 files changed, 43 insertions, 25 deletions
diff --git a/tetheroffload/control/1.0/vts/functional/VtsHalTetheroffloadControlV1_0TargetTest.cpp b/tetheroffload/control/1.0/vts/functional/VtsHalTetheroffloadControlV1_0TargetTest.cpp
index d572728e..d2fa92db 100644
--- a/tetheroffload/control/1.0/vts/functional/VtsHalTetheroffloadControlV1_0TargetTest.cpp
+++ b/tetheroffload/control/1.0/vts/functional/VtsHalTetheroffloadControlV1_0TargetTest.cpp
@@ -26,6 +26,7 @@
26#include <linux/netfilter/nfnetlink.h> 26#include <linux/netfilter/nfnetlink.h>
27#include <linux/netlink.h> 27#include <linux/netlink.h>
28#include <log/log.h> 28#include <log/log.h>
29#include <net/if.h>
29#include <sys/socket.h> 30#include <sys/socket.h>
30#include <unistd.h> 31#include <unistd.h>
31#include <set> 32#include <set>
@@ -52,6 +53,8 @@ enum class ExpectBoolean {
52 True = 1, 53 True = 1,
53}; 54};
54 55
56constexpr const char* TEST_IFACE = "rmnet_data0";
57
55// 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
56#define ASSERT_TRUE_CALLBACK \ 59#define ASSERT_TRUE_CALLBACK \
57 [&](bool success, std::string errMsg) { \ 60 [&](bool success, std::string errMsg) { \
@@ -240,6 +243,18 @@ TEST_F(OffloadControlHidlTestBase, MultipleStopsWithoutInitReturnFalse) {
240 stopOffload(ExpectBoolean::False); 243 stopOffload(ExpectBoolean::False);
241} 244}
242 245
246// Check whether the specified interface is up.
247bool interfaceIsUp(const char* name) {
248 if (name == nullptr) return false;
249 struct ifreq ifr = {};
250 strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
251 int sock = socket(AF_INET6, SOCK_DGRAM, 0);
252 if (sock == -1) return false;
253 int ret = ioctl(sock, SIOCGIFFLAGS, &ifr, sizeof(ifr));
254 close(sock);
255 return (ret == 0) && (ifr.ifr_flags & IFF_UP);
256}
257
243// Check that calling stopOffload() after a complete init/stop cycle returns false. 258// Check that calling stopOffload() after a complete init/stop cycle returns false.
244TEST_F(OffloadControlHidlTestBase, AdditionalStopsWithInitReturnFalse) { 259TEST_F(OffloadControlHidlTestBase, AdditionalStopsWithInitReturnFalse) {
245 initOffload(true); 260 initOffload(true);
@@ -249,8 +264,11 @@ TEST_F(OffloadControlHidlTestBase, AdditionalStopsWithInitReturnFalse) {
249 const hidl_string v4Gw("192.0.0.1"); 264 const hidl_string v4Gw("192.0.0.1");
250 const vector<hidl_string> v6Gws{hidl_string("fe80::db8:1"), hidl_string("fe80::db8:2")}; 265 const vector<hidl_string> v6Gws{hidl_string("fe80::db8:1"), hidl_string("fe80::db8:2")};
251 const Return<void> upstream = 266 const Return<void> upstream =
252 control->setUpstreamParameters("rmnet_data0", v4Addr, v4Gw, v6Gws, ASSERT_TRUE_CALLBACK); 267 control->setUpstreamParameters(TEST_IFACE, v4Addr, v4Gw, v6Gws, ASSERT_TRUE_CALLBACK);
253 EXPECT_TRUE(upstream.isOk()); 268 EXPECT_TRUE(upstream.isOk());
269 if (!interfaceIsUp(TEST_IFACE)) {
270 return;
271 }
254 stopOffload(ExpectBoolean::True); // balance out initOffload(true) 272 stopOffload(ExpectBoolean::True); // balance out initOffload(true)
255 stopOffload(ExpectBoolean::False); 273 stopOffload(ExpectBoolean::False);
256 stopOffload(ExpectBoolean::False); 274 stopOffload(ExpectBoolean::False);
@@ -266,14 +284,14 @@ TEST_F(OffloadControlHidlTestBase, SetLocalPrefixesWithoutInitReturnsFalse) {
266// Check that calling getForwardedStats() without first having called initOffload() 284// Check that calling getForwardedStats() without first having called initOffload()
267// returns zero bytes statistics. 285// returns zero bytes statistics.
268TEST_F(OffloadControlHidlTestBase, GetForwardedStatsWithoutInitReturnsZeroValues) { 286TEST_F(OffloadControlHidlTestBase, GetForwardedStatsWithoutInitReturnsZeroValues) {
269 const hidl_string upstream("rmnet_data0"); 287 const hidl_string upstream(TEST_IFACE);
270 const Return<void> ret = control->getForwardedStats(upstream, ASSERT_ZERO_BYTES_CALLBACK); 288 const Return<void> ret = control->getForwardedStats(upstream, ASSERT_ZERO_BYTES_CALLBACK);
271 EXPECT_TRUE(ret.isOk()); 289 EXPECT_TRUE(ret.isOk());
272} 290}
273 291
274// Check that calling setDataLimit() without first having called initOffload() returns false. 292// Check that calling setDataLimit() without first having called initOffload() returns false.
275TEST_F(OffloadControlHidlTestBase, SetDataLimitWithoutInitReturnsFalse) { 293TEST_F(OffloadControlHidlTestBase, SetDataLimitWithoutInitReturnsFalse) {
276 const hidl_string upstream("rmnet_data0"); 294 const hidl_string upstream(TEST_IFACE);
277 const uint64_t limit = 5000ULL; 295 const uint64_t limit = 5000ULL;
278 const Return<void> ret = control->setDataLimit(upstream, limit, ASSERT_FALSE_CALLBACK); 296 const Return<void> ret = control->setDataLimit(upstream, limit, ASSERT_FALSE_CALLBACK);
279 EXPECT_TRUE(ret.isOk()); 297 EXPECT_TRUE(ret.isOk());
@@ -282,7 +300,7 @@ TEST_F(OffloadControlHidlTestBase, SetDataLimitWithoutInitReturnsFalse) {
282// Check that calling setUpstreamParameters() without first having called initOffload() 300// Check that calling setUpstreamParameters() without first having called initOffload()
283// returns false. 301// returns false.
284TEST_F(OffloadControlHidlTestBase, SetUpstreamParametersWithoutInitReturnsFalse) { 302TEST_F(OffloadControlHidlTestBase, SetUpstreamParametersWithoutInitReturnsFalse) {
285 const hidl_string iface("rmnet_data0"); 303 const hidl_string iface(TEST_IFACE);
286 const hidl_string v4Addr("192.0.2.0/24"); 304 const hidl_string v4Addr("192.0.2.0/24");
287 const hidl_string v4Gw("192.0.2.1"); 305 const hidl_string v4Gw("192.0.2.1");
288 const vector<hidl_string> v6Gws{hidl_string("fe80::db8:1")}; 306 const vector<hidl_string> v6Gws{hidl_string("fe80::db8:1")};
@@ -294,7 +312,7 @@ TEST_F(OffloadControlHidlTestBase, SetUpstreamParametersWithoutInitReturnsFalse)
294// Check that calling addDownstream() with an IPv4 prefix without first having called 312// Check that calling addDownstream() with an IPv4 prefix without first having called
295// initOffload() returns false. 313// initOffload() returns false.
296TEST_F(OffloadControlHidlTestBase, AddIPv4DownstreamWithoutInitReturnsFalse) { 314TEST_F(OffloadControlHidlTestBase, AddIPv4DownstreamWithoutInitReturnsFalse) {
297 const hidl_string iface("rmnet_data0"); 315 const hidl_string iface(TEST_IFACE);
298 const hidl_string prefix("192.0.2.0/24"); 316 const hidl_string prefix("192.0.2.0/24");
299 const Return<void> ret = control->addDownstream(iface, prefix, ASSERT_FALSE_CALLBACK); 317 const Return<void> ret = control->addDownstream(iface, prefix, ASSERT_FALSE_CALLBACK);
300 EXPECT_TRUE(ret.isOk()); 318 EXPECT_TRUE(ret.isOk());
@@ -303,7 +321,7 @@ TEST_F(OffloadControlHidlTestBase, AddIPv4DownstreamWithoutInitReturnsFalse) {
303// Check that calling addDownstream() with an IPv6 prefix without first having called 321// Check that calling addDownstream() with an IPv6 prefix without first having called
304// initOffload() returns false. 322// initOffload() returns false.
305TEST_F(OffloadControlHidlTestBase, AddIPv6DownstreamWithoutInitReturnsFalse) { 323TEST_F(OffloadControlHidlTestBase, AddIPv6DownstreamWithoutInitReturnsFalse) {
306 const hidl_string iface("rmnet_data0"); 324 const hidl_string iface(TEST_IFACE);
307 const hidl_string prefix("2001:db8::/64"); 325 const hidl_string prefix("2001:db8::/64");
308 const Return<void> ret = control->addDownstream(iface, prefix, ASSERT_FALSE_CALLBACK); 326 const Return<void> ret = control->addDownstream(iface, prefix, ASSERT_FALSE_CALLBACK);
309 EXPECT_TRUE(ret.isOk()); 327 EXPECT_TRUE(ret.isOk());
@@ -312,7 +330,7 @@ TEST_F(OffloadControlHidlTestBase, AddIPv6DownstreamWithoutInitReturnsFalse) {
312// Check that calling removeDownstream() with an IPv4 prefix without first having called 330// Check that calling removeDownstream() with an IPv4 prefix without first having called
313// initOffload() returns false. 331// initOffload() returns false.
314TEST_F(OffloadControlHidlTestBase, RemoveIPv4DownstreamWithoutInitReturnsFalse) { 332TEST_F(OffloadControlHidlTestBase, RemoveIPv4DownstreamWithoutInitReturnsFalse) {
315 const hidl_string iface("rmnet_data0"); 333 const hidl_string iface(TEST_IFACE);
316 const hidl_string prefix("192.0.2.0/24"); 334 const hidl_string prefix("192.0.2.0/24");
317 const Return<void> ret = control->removeDownstream(iface, prefix, ASSERT_FALSE_CALLBACK); 335 const Return<void> ret = control->removeDownstream(iface, prefix, ASSERT_FALSE_CALLBACK);
318 EXPECT_TRUE(ret.isOk()); 336 EXPECT_TRUE(ret.isOk());
@@ -321,7 +339,7 @@ TEST_F(OffloadControlHidlTestBase, RemoveIPv4DownstreamWithoutInitReturnsFalse)
321// Check that calling removeDownstream() with an IPv6 prefix without first having called 339// Check that calling removeDownstream() with an IPv6 prefix without first having called
322// initOffload() returns false. 340// initOffload() returns false.
323TEST_F(OffloadControlHidlTestBase, RemoveIPv6DownstreamWithoutInitReturnsFalse) { 341TEST_F(OffloadControlHidlTestBase, RemoveIPv6DownstreamWithoutInitReturnsFalse) {
324 const hidl_string iface("rmnet_data0"); 342 const hidl_string iface(TEST_IFACE);
325 const hidl_string prefix("2001:db8::/64"); 343 const hidl_string prefix("2001:db8::/64");
326 const Return<void> ret = control->removeDownstream(iface, prefix, ASSERT_FALSE_CALLBACK); 344 const Return<void> ret = control->removeDownstream(iface, prefix, ASSERT_FALSE_CALLBACK);
327 EXPECT_TRUE(ret.isOk()); 345 EXPECT_TRUE(ret.isOk());
@@ -394,10 +412,10 @@ TEST_F(OffloadControlHidlTest, GetForwardedStatsInvalidUpstreamIface) {
394 EXPECT_TRUE(ret.isOk()); 412 EXPECT_TRUE(ret.isOk());
395} 413}
396 414
397// The "rmnet_data0" is presumed to exist on the device and be up. No packets 415// TEST_IFACE is presumed to exist on the device and be up. No packets
398// are ever actually caused to be forwarded. 416// are ever actually caused to be forwarded.
399TEST_F(OffloadControlHidlTest, GetForwardedStatsDummyIface) { 417TEST_F(OffloadControlHidlTest, GetForwardedStatsDummyIface) {
400 const hidl_string upstream("rmnet_data0"); 418 const hidl_string upstream(TEST_IFACE);
401 const Return<void> ret = control->getForwardedStats(upstream, ASSERT_ZERO_BYTES_CALLBACK); 419 const Return<void> ret = control->getForwardedStats(upstream, ASSERT_ZERO_BYTES_CALLBACK);
402 EXPECT_TRUE(ret.isOk()); 420 EXPECT_TRUE(ret.isOk());
403} 421}
@@ -414,19 +432,19 @@ TEST_F(OffloadControlHidlTest, SetDataLimitEmptyUpstreamIfaceFails) {
414 EXPECT_TRUE(ret.isOk()); 432 EXPECT_TRUE(ret.isOk());
415} 433}
416 434
417// The "rmnet_data0" is presumed to exist on the device and be up. No packets 435// TEST_IFACE is presumed to exist on the device and be up. No packets
418// are ever actually caused to be forwarded. 436// are ever actually caused to be forwarded.
419TEST_F(OffloadControlHidlTest, SetDataLimitNonZeroOk) { 437TEST_F(OffloadControlHidlTest, SetDataLimitNonZeroOk) {
420 const hidl_string upstream("rmnet_data0"); 438 const hidl_string upstream(TEST_IFACE);
421 const uint64_t limit = 5000ULL; 439 const uint64_t limit = 5000ULL;
422 const Return<void> ret = control->setDataLimit(upstream, limit, ASSERT_TRUE_CALLBACK); 440 const Return<void> ret = control->setDataLimit(upstream, limit, ASSERT_TRUE_CALLBACK);
423 EXPECT_TRUE(ret.isOk()); 441 EXPECT_TRUE(ret.isOk());
424} 442}
425 443
426// The "rmnet_data0" is presumed to exist on the device and be up. No packets 444// TEST_IFACE is presumed to exist on the device and be up. No packets
427// are ever actually caused to be forwarded. 445// are ever actually caused to be forwarded.
428TEST_F(OffloadControlHidlTest, SetDataLimitZeroOk) { 446TEST_F(OffloadControlHidlTest, SetDataLimitZeroOk) {
429 const hidl_string upstream("rmnet_data0"); 447 const hidl_string upstream(TEST_IFACE);
430 const uint64_t limit = 0ULL; 448 const uint64_t limit = 0ULL;
431 const Return<void> ret = control->setDataLimit(upstream, limit, ASSERT_TRUE_CALLBACK); 449 const Return<void> ret = control->setDataLimit(upstream, limit, ASSERT_TRUE_CALLBACK);
432 EXPECT_TRUE(ret.isOk()); 450 EXPECT_TRUE(ret.isOk());
@@ -436,10 +454,10 @@ TEST_F(OffloadControlHidlTest, SetDataLimitZeroOk) {
436 * Tests for IOffloadControl::setUpstreamParameters(). 454 * Tests for IOffloadControl::setUpstreamParameters().
437 */ 455 */
438 456
439// The "rmnet_data0" is presumed to exist on the device and be up. No packets 457// TEST_IFACE is presumed to exist on the device and be up. No packets
440// are ever actually caused to be forwarded. 458// are ever actually caused to be forwarded.
441TEST_F(OffloadControlHidlTest, SetUpstreamParametersIPv6OnlyOk) { 459TEST_F(OffloadControlHidlTest, SetUpstreamParametersIPv6OnlyOk) {
442 const hidl_string iface("rmnet_data0"); 460 const hidl_string iface(TEST_IFACE);
443 const hidl_string v4Addr(""); 461 const hidl_string v4Addr("");
444 const hidl_string v4Gw(""); 462 const hidl_string v4Gw("");
445 const vector<hidl_string> v6Gws{hidl_string("fe80::db8:1"), hidl_string("fe80::db8:2")}; 463 const vector<hidl_string> v6Gws{hidl_string("fe80::db8:1"), hidl_string("fe80::db8:2")};
@@ -448,10 +466,10 @@ TEST_F(OffloadControlHidlTest, SetUpstreamParametersIPv6OnlyOk) {
448 EXPECT_TRUE(ret.isOk()); 466 EXPECT_TRUE(ret.isOk());
449} 467}
450 468
451// The "rmnet_data0" is presumed to exist on the device and be up. No packets 469// TEST_IFACE is presumed to exist on the device and be up. No packets
452// are ever actually caused to be forwarded. 470// are ever actually caused to be forwarded.
453TEST_F(OffloadControlHidlTest, SetUpstreamParametersAlternateIPv6OnlyOk) { 471TEST_F(OffloadControlHidlTest, SetUpstreamParametersAlternateIPv6OnlyOk) {
454 const hidl_string iface("rmnet_data0"); 472 const hidl_string iface(TEST_IFACE);
455 const hidl_string v4Addr; 473 const hidl_string v4Addr;
456 const hidl_string v4Gw; 474 const hidl_string v4Gw;
457 const vector<hidl_string> v6Gws{hidl_string("fe80::db8:1"), hidl_string("fe80::db8:3")}; 475 const vector<hidl_string> v6Gws{hidl_string("fe80::db8:1"), hidl_string("fe80::db8:3")};
@@ -460,10 +478,10 @@ TEST_F(OffloadControlHidlTest, SetUpstreamParametersAlternateIPv6OnlyOk) {
460 EXPECT_TRUE(ret.isOk()); 478 EXPECT_TRUE(ret.isOk());
461} 479}
462 480
463// The "rmnet_data0" is presumed to exist on the device and be up. No packets 481// TEST_IFACE is presumed to exist on the device and be up. No packets
464// are ever actually caused to be forwarded. 482// are ever actually caused to be forwarded.
465TEST_F(OffloadControlHidlTest, SetUpstreamParametersIPv4OnlyOk) { 483TEST_F(OffloadControlHidlTest, SetUpstreamParametersIPv4OnlyOk) {
466 const hidl_string iface("rmnet_data0"); 484 const hidl_string iface(TEST_IFACE);
467 const hidl_string v4Addr("192.0.2.2"); 485 const hidl_string v4Addr("192.0.2.2");
468 const hidl_string v4Gw("192.0.2.1"); 486 const hidl_string v4Gw("192.0.2.1");
469 const vector<hidl_string> v6Gws{}; 487 const vector<hidl_string> v6Gws{};
@@ -472,10 +490,10 @@ TEST_F(OffloadControlHidlTest, SetUpstreamParametersIPv4OnlyOk) {
472 EXPECT_TRUE(ret.isOk()); 490 EXPECT_TRUE(ret.isOk());
473} 491}
474 492
475// The "rmnet_data0" is presumed to exist on the device and be up. No packets 493// TEST_IFACE is presumed to exist on the device and be up. No packets
476// are ever actually caused to be forwarded. 494// are ever actually caused to be forwarded.
477TEST_F(OffloadControlHidlTest, SetUpstreamParametersIPv4v6Ok) { 495TEST_F(OffloadControlHidlTest, SetUpstreamParametersIPv4v6Ok) {
478 const hidl_string iface("rmnet_data0"); 496 const hidl_string iface(TEST_IFACE);
479 const hidl_string v4Addr("192.0.2.2"); 497 const hidl_string v4Addr("192.0.2.2");
480 const hidl_string v4Gw("192.0.2.1"); 498 const hidl_string v4Gw("192.0.2.1");
481 const vector<hidl_string> v6Gws{hidl_string("fe80::db8:1"), hidl_string("fe80::db8:2")}; 499 const vector<hidl_string> v6Gws{hidl_string("fe80::db8:1"), hidl_string("fe80::db8:2")};
@@ -511,7 +529,7 @@ TEST_F(OffloadControlHidlTest, SetUpstreamParametersBogusIfaceFails) {
511 529
512// Test that setUpstreamParameters() fails when given unparseable IPv4 addresses. 530// Test that setUpstreamParameters() fails when given unparseable IPv4 addresses.
513TEST_F(OffloadControlHidlTest, SetUpstreamParametersInvalidIPv4AddrFails) { 531TEST_F(OffloadControlHidlTest, SetUpstreamParametersInvalidIPv4AddrFails) {
514 const hidl_string iface("rmnet_data0"); 532 const hidl_string iface(TEST_IFACE);
515 const hidl_string v4Gw("192.0.2.1"); 533 const hidl_string v4Gw("192.0.2.1");
516 const vector<hidl_string> v6Gws{hidl_string("fe80::db8:1")}; 534 const vector<hidl_string> v6Gws{hidl_string("fe80::db8:1")};
517 for (const auto& bogus : {"invalid", "192.0.2"}) { 535 for (const auto& bogus : {"invalid", "192.0.2"}) {
@@ -525,7 +543,7 @@ TEST_F(OffloadControlHidlTest, SetUpstreamParametersInvalidIPv4AddrFails) {
525 543
526// Test that setUpstreamParameters() fails when given unparseable IPv4 gateways. 544// Test that setUpstreamParameters() fails when given unparseable IPv4 gateways.
527TEST_F(OffloadControlHidlTest, SetUpstreamParametersInvalidIPv4GatewayFails) { 545TEST_F(OffloadControlHidlTest, SetUpstreamParametersInvalidIPv4GatewayFails) {
528 const hidl_string iface("rmnet_data0"); 546 const hidl_string iface(TEST_IFACE);
529 const hidl_string v4Addr("192.0.2.2"); 547 const hidl_string v4Addr("192.0.2.2");
530 const vector<hidl_string> v6Gws{hidl_string("fe80::db8:1")}; 548 const vector<hidl_string> v6Gws{hidl_string("fe80::db8:1")};
531 for (const auto& bogus : {"invalid", "192.0.2"}) { 549 for (const auto& bogus : {"invalid", "192.0.2"}) {
@@ -539,7 +557,7 @@ TEST_F(OffloadControlHidlTest, SetUpstreamParametersInvalidIPv4GatewayFails) {
539 557
540// Test that setUpstreamParameters() fails when given unparseable IPv6 gateways. 558// Test that setUpstreamParameters() fails when given unparseable IPv6 gateways.
541TEST_F(OffloadControlHidlTest, SetUpstreamParametersBadIPv6GatewaysFail) { 559TEST_F(OffloadControlHidlTest, SetUpstreamParametersBadIPv6GatewaysFail) {
542 const hidl_string iface("rmnet_data0"); 560 const hidl_string iface(TEST_IFACE);
543 const hidl_string v4Addr("192.0.2.2"); 561 const hidl_string v4Addr("192.0.2.2");
544 const hidl_string v4Gw("192.0.2.1"); 562 const hidl_string v4Gw("192.0.2.1");
545 for (const auto& bogus : {"", "invalid", "fe80::bogus", "192.0.2.66"}) { 563 for (const auto& bogus : {"", "invalid", "fe80::bogus", "192.0.2.66"}) {