diff options
| author | Erik Kline <ek@google.com> | 2017-09-29 16:22:36 +0000 |
|---|---|---|
| committer | android-build-merger <android-build-merger@google.com> | 2017-09-29 16:22:36 +0000 |
| commit | 67fd6d8af8106509b0c80c76d4535f492435acd8 (patch) | |
| tree | 30497bd07721839842478516c2fc5a842a294e8d /tetheroffload | |
| parent | 8b4c5b3b967051c05cb00120c3c5913059411192 (diff) | |
| parent | b451490514160a40962663cce17775aa18a19e06 (diff) | |
| download | android_hardware_interfaces-67fd6d8af8106509b0c80c76d4535f492435acd8.tar.gz android_hardware_interfaces-67fd6d8af8106509b0c80c76d4535f492435acd8.tar.bz2 android_hardware_interfaces-67fd6d8af8106509b0c80c76d4535f492435acd8.zip | |
More tetheroffload VTS fixes for over-specified tests.
am: b451490514
Change-Id: I5aed0b84dd1c19a2ff5cd6eadf89bbc2e12c3ab5
Diffstat (limited to 'tetheroffload')
| -rw-r--r-- | tetheroffload/control/1.0/vts/functional/VtsHalTetheroffloadControlV1_0TargetTest.cpp | 63 |
1 files changed, 48 insertions, 15 deletions
diff --git a/tetheroffload/control/1.0/vts/functional/VtsHalTetheroffloadControlV1_0TargetTest.cpp b/tetheroffload/control/1.0/vts/functional/VtsHalTetheroffloadControlV1_0TargetTest.cpp index a9424bc5a..52dd026a8 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; using android::hardware::Void; using android::sp; +enum class ExpectBoolean { + Ignored = -1, + False = 0, + True = 1, +}; + // We use #defines here so as to get local lamba captures and error message line numbers #define ASSERT_TRUE_CALLBACK \ [&](bool success, std::string errMsg) { \ @@ -112,7 +118,12 @@ class OffloadControlHidlTestBase : public testing::VtsHalHidlTargetTestBase { prepareControlHal(); } - virtual void TearDown() override { stopOffload(false); } + virtual void TearDown() override { + // For good measure, we should try stopOffload() once more. Since we + // don't know where we are in HAL call test cycle we don't know what + // return code to actually expect, so we just ignore it. + stopOffload(ExpectBoolean::Ignored); + } // The IOffloadConfig HAL is tested more thoroughly elsewhere. He we just // setup everything correctly and verify basic readiness. @@ -168,12 +179,21 @@ class OffloadControlHidlTestBase : public testing::VtsHalHidlTargetTestBase { initOffload(true); } - void stopOffload(const bool expected_result) { + void stopOffload(const ExpectBoolean value) { auto cb = [&](bool success, const hidl_string& errMsg) { if (!success) { ALOGI("Error message: %s", errMsg.c_str()); } - ASSERT_EQ(expected_result, success); + switch (value) { + case ExpectBoolean::False: + ASSERT_EQ(false, success); + break; + case ExpectBoolean::True: + ASSERT_EQ(true, success); + break; + case ExpectBoolean::Ignored: + break; + } }; const Return<void> ret = control->stopOffload(cb); ASSERT_TRUE(ret.isOk()); @@ -211,22 +231,22 @@ TEST_F(OffloadControlHidlTestBase, AdditionalInitsWithoutStopReturnFalse) { initOffload(false); initOffload(false); initOffload(false); - stopOffload(true); // balance out initOffload(true) + stopOffload(ExpectBoolean::True); // balance out initOffload(true) } // Check that calling stopOffload() without first having called initOffload() returns false. TEST_F(OffloadControlHidlTestBase, MultipleStopsWithoutInitReturnFalse) { - stopOffload(false); - stopOffload(false); - stopOffload(false); + stopOffload(ExpectBoolean::False); + stopOffload(ExpectBoolean::False); + stopOffload(ExpectBoolean::False); } // Check that calling stopOffload() after a complete init/stop cycle returns false. TEST_F(OffloadControlHidlTestBase, AdditionalStopsWithInitReturnFalse) { initOffload(true); - stopOffload(true); // balance out initOffload(true) - stopOffload(false); - stopOffload(false); + stopOffload(ExpectBoolean::True); // balance out initOffload(true) + stopOffload(ExpectBoolean::False); + stopOffload(ExpectBoolean::False); } // Check that calling setLocalPrefixes() without first having called initOffload() returns false. @@ -307,7 +327,12 @@ class OffloadControlHidlTest : public OffloadControlHidlTestBase { setupControlHal(); } - virtual void TearDown() override { stopOffload(true); } + virtual void TearDown() override { + // For good measure, we should try stopOffload() once more. Since we + // don't know where we are in HAL call test cycle we don't know what + // return code to actually expect, so we just ignore it. + stopOffload(ExpectBoolean::Ignored); + } }; /* @@ -577,16 +602,24 @@ TEST_F(OffloadControlHidlTest, AddDownstreamBogusPrefixFails) { TEST_F(OffloadControlHidlTest, RemoveDownstreamIPv4) { const hidl_string iface("dummy0"); const hidl_string prefix("192.0.2.0/24"); - const Return<void> ret = control->removeDownstream(iface, prefix, ASSERT_TRUE_CALLBACK); - EXPECT_TRUE(ret.isOk()); + // First add the downstream, otherwise removeDownstream logic can reasonably + // return false for downstreams not previously added. + const Return<void> add = control->addDownstream(iface, prefix, ASSERT_TRUE_CALLBACK); + EXPECT_TRUE(add.isOk()); + const Return<void> del = control->removeDownstream(iface, prefix, ASSERT_TRUE_CALLBACK); + EXPECT_TRUE(del.isOk()); } // Test removeDownstream() works given an IPv6 prefix. TEST_F(OffloadControlHidlTest, RemoveDownstreamIPv6) { const hidl_string iface("dummy0"); const hidl_string prefix("2001:db8::/64"); - const Return<void> ret = control->removeDownstream(iface, prefix, ASSERT_TRUE_CALLBACK); - EXPECT_TRUE(ret.isOk()); + // First add the downstream, otherwise removeDownstream logic can reasonably + // return false for downstreams not previously added. + const Return<void> add = control->addDownstream(iface, prefix, ASSERT_TRUE_CALLBACK); + EXPECT_TRUE(add.isOk()); + const Return<void> del = control->removeDownstream(iface, prefix, ASSERT_TRUE_CALLBACK); + EXPECT_TRUE(del.isOk()); } // Test removeDownstream() fails given all empty parameters. |
