summaryrefslogtreecommitdiffstats
path: root/net/netd/1.0/vts/functional/VtsHalNetNetdV1_0TargetTest.cpp
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2017-08-01 07:28:45 +0000
committerandroid-build-team Robot <android-build-team-robot@google.com>2017-08-01 07:28:45 +0000
commitd55c1cc81a33ceaf38fca699d701fcd92e23be07 (patch)
tree9994f6e72408d9c4f5e3d38dd93a5f057a1fab31 /net/netd/1.0/vts/functional/VtsHalNetNetdV1_0TargetTest.cpp
parent3cf827c6a179b868ae131b5a1051eaef6100330a (diff)
parent7e3a96d729324687c4f009c3a6ec75ef023eaad5 (diff)
downloadandroid_system_hardware_interfaces-d55c1cc81a33ceaf38fca699d701fcd92e23be07.tar.gz
android_system_hardware_interfaces-d55c1cc81a33ceaf38fca699d701fcd92e23be07.tar.bz2
android_system_hardware_interfaces-d55c1cc81a33ceaf38fca699d701fcd92e23be07.zip
release-request-b6ab0986-e497-499a-b55d-25aa156be8cf-for-git_oc-dr1-release-4233813 snap-temp-L73000000087867826staging/lineage-15.0_rebase-android-8.0.0_r23
Change-Id: Ieb2de98eee761a8057ffc2ab9ef66673a62bb87b
Diffstat (limited to 'net/netd/1.0/vts/functional/VtsHalNetNetdV1_0TargetTest.cpp')
-rw-r--r--net/netd/1.0/vts/functional/VtsHalNetNetdV1_0TargetTest.cpp65
1 files changed, 65 insertions, 0 deletions
diff --git a/net/netd/1.0/vts/functional/VtsHalNetNetdV1_0TargetTest.cpp b/net/netd/1.0/vts/functional/VtsHalNetNetdV1_0TargetTest.cpp
new file mode 100644
index 0000000..c332c10
--- /dev/null
+++ b/net/netd/1.0/vts/functional/VtsHalNetNetdV1_0TargetTest.cpp
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define LOG_TAG "netd_hidl_test"
+
+#include <VtsHalHidlTargetTestBase.h>
+#include <android/system/net/netd/1.0/INetd.h>
+#include <log/log.h>
+
+using ::android::system::net::netd::V1_0::INetd;
+using ::android::hardware::Return;
+using ::android::sp;
+
+class NetdHidlTest : public ::testing::VtsHalHidlTargetTestBase {
+ public:
+ virtual void SetUp() override {
+ netd = ::testing::VtsHalHidlTargetTestBase::getService<INetd>();
+ ASSERT_NE(nullptr, netd.get()) << "Could not get HIDL instance";
+ }
+
+ sp<INetd> netd;
+};
+
+// positive test. Ensure netd creates an oem network and returns valid netHandle, and destroys it.
+TEST_F(NetdHidlTest, TestCreateAndDestroyOemNetworkOk) {
+ auto cb = [this](uint64_t netHandle, uint32_t packetMark, INetd::StatusCode status) {
+ ASSERT_EQ(INetd::StatusCode::OK, status);
+ ASSERT_NE((uint64_t)0, netHandle);
+ ASSERT_NE((uint32_t)0, packetMark);
+
+ Return<INetd::StatusCode> retStatus = netd->destroyOemNetwork(netHandle);
+ ASSERT_EQ(INetd::StatusCode::OK, retStatus);
+ };
+
+ Return<void> ret = netd->createOemNetwork(cb);
+ ASSERT_TRUE(ret.isOk());
+}
+
+// negative test. Ensure destroy for invalid OEM network fails appropriately
+TEST_F(NetdHidlTest, TestDestroyOemNetworkInvalid) {
+ const uint64_t nh = 0x6600FACADE;
+
+ Return<INetd::StatusCode> retStatus = netd->destroyOemNetwork(nh);
+ ASSERT_EQ(INetd::StatusCode::INVALID_ARGUMENTS, retStatus);
+}
+
+int main(int argc, char** argv) {
+ ::testing::InitGoogleTest(&argc, argv);
+ int status = RUN_ALL_TESTS();
+ ALOGE("Test result with status=%d", status);
+ return status;
+}