Temporarily disable NetworkPermissionDefault in cuttlefish and tiny fix
This test is broken since ab/5604620.
So disable for now, and wait for real solution.
Also a tiny change for fixing wrong result description of NDC command.
(ndc network default set netid)
Bug: 133653863
Bug: 133714377
Test: built, flashed, booted
system/netd/tests/runtests.sh
Run test case "NetworkPermissionDefault" manually in cuttlefish
to verify that the test is skipped.
Change-Id: I37c48f119a7e0293b00582234cf7d716baf08e7a
diff --git a/tests/binder_test.cpp b/tests/binder_test.cpp
index 917bf5d..e42cd02 100644
--- a/tests/binder_test.cpp
+++ b/tests/binder_test.cpp
@@ -41,6 +41,7 @@
#include <android-base/file.h>
#include <android-base/macros.h>
+#include <android-base/properties.h>
#include <android-base/stringprintf.h>
#include <android-base/strings.h>
#include <binder/IPCThreadState.h>
@@ -96,6 +97,11 @@
using android::netdutils::sSyscalls;
using android::netdutils::Stopwatch;
+#define SKIP_IF_CUTTLEFISH \
+ do { \
+ if (isCuttleFish()) return; \
+ } while (0)
+
static const char* IP_RULE_V4 = "-4";
static const char* IP_RULE_V6 = "-6";
static const int TEST_NETID1 = 65501;
@@ -1934,7 +1940,23 @@
EXPECT_TRUE(mNetd->networkDestroy(TEST_NETID1).isOk());
}
+namespace {
+
+constexpr char CUTTLEFISH_PRODUCT_DEVICE[] = "vsoc_x86";
+constexpr char CUTTLEFISH_SYSTEM_NAME[] = "cf_x86_phone";
+
+bool isCuttleFish() {
+ static const std::string sProductDevice = android::base::GetProperty("ro.product.device", "");
+ static const std::string sSystemName = android::base::GetProperty("ro.product.system.name", "");
+ return (sProductDevice.find(CUTTLEFISH_PRODUCT_DEVICE) != std::string::npos) &&
+ (sSystemName.find(CUTTLEFISH_SYSTEM_NAME) != std::string::npos);
+}
+
+} // namespace
+
TEST_F(BinderTest, NetworkPermissionDefault) {
+ SKIP_IF_CUTTLEFISH;
+
// Add test physical network
EXPECT_TRUE(mNetd->networkCreatePhysical(TEST_NETID1, INetd::PERMISSION_NONE).isOk());
EXPECT_TRUE(mNetd->networkAddInterface(TEST_NETID1, sTun.name()).isOk());