summaryrefslogtreecommitdiff
path: root/client/NetdClientTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'client/NetdClientTest.cpp')
-rw-r--r--client/NetdClientTest.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/client/NetdClientTest.cpp b/client/NetdClientTest.cpp
index b523ccc9..126c7fd1 100644
--- a/client/NetdClientTest.cpp
+++ b/client/NetdClientTest.cpp
@@ -74,3 +74,21 @@ TEST(NetdClientTest, getNetworkForDns) {
unsigned* testNull = nullptr;
EXPECT_EQ(-EFAULT, getNetworkForDns(testNull));
}
+
+TEST(NetdClientTest, protectFromVpnBadFd) {
+ EXPECT_EQ(-EBADF, protectFromVpn(-1));
+}
+
+TEST(NetdClientTest, protectFromVpnUnixStream) {
+ int s = socket(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0);
+ ASSERT_GE(s, 3);
+ EXPECT_EQ(-EAFNOSUPPORT, protectFromVpn(s));
+ close(s);
+}
+
+TEST(NetdClientTest, protectFromVpnTcp6) {
+ int s = socket(AF_INET6, SOCK_STREAM | SOCK_CLOEXEC, 0);
+ ASSERT_GE(s, 3);
+ EXPECT_EQ(0, protectFromVpn(s));
+ close(s);
+}