Merge changes I8e26cf11,I9edbe1d5,Ia7129eca

* changes:
  Start netd before running tests on Buildbot devices.
  Ignore failures on O devices in JDWP tests.
  Ignore failures on O devices in some network-related libcore tests.
diff --git a/tools/libcore_network_failures.txt b/tools/libcore_network_failures.txt
new file mode 100644
index 0000000..e7e31db
--- /dev/null
+++ b/tools/libcore_network_failures.txt
@@ -0,0 +1,92 @@
+/*
+ * This file contains extra expectations for ART's buildbot regarding network tests.
+ * The script that uses this file is art/tools/run-libcore-tests.sh.
+ */
+
+[
+{
+  description: "Ignore failure of network-related tests on new devices running Android O",
+  result: EXEC_FAILED,
+  bug: 74725685,
+  modes: [device],
+  names: ["libcore.libcore.io.OsTest#test_byteBufferPositions_sendto_recvfrom_af_inet",
+          "libcore.libcore.net.NetworkSecurityPolicyTest#testCleartextTrafficPolicyWithFtpURLConnection",
+          "libcore.libcore.net.NetworkSecurityPolicyTest#testCleartextTrafficPolicyWithHttpURLConnection",
+          "libcore.libcore.net.NetworkSecurityPolicyTest#testCleartextTrafficPolicyWithJarFtpURLConnection",
+          "libcore.libcore.net.NetworkSecurityPolicyTest#testCleartextTrafficPolicyWithJarHttpURLConnection",
+          "libcore.libcore.net.NetworkSecurityPolicyTest#testCleartextTrafficPolicyWithLoggingSocketHandler",
+          "org.apache.harmony.tests.java.util.ScannerTest#test_40555",
+          "org.apache.harmony.tests.java.util.ScannerTest#test_ConstructorLjava_io_File",
+          "org.apache.harmony.tests.java.util.ScannerTest#test_ConstructorLjava_io_FileLjava_lang_String",
+          "org.apache.harmony.tests.java.util.ScannerTest#test_ConstructorLjava_io_InputStream",
+          "org.apache.harmony.tests.java.util.ScannerTest#test_ConstructorLjava_io_InputStreamLjava_lang_String",
+          "org.apache.harmony.tests.java.util.ScannerTest#test_ConstructorLjava_lang_Readable",
+          "org.apache.harmony.tests.java.util.ScannerTest#test_ConstructorLjava_lang_String",
+          "org.apache.harmony.tests.java.util.ScannerTest#test_ConstructorLjava_nio_channels_ReadableByteChannel",
+          "org.apache.harmony.tests.java.util.ScannerTest#test_ConstructorLjava_nio_channels_ReadableByteChannelLjava_lang_String",
+          "org.apache.harmony.tests.java.util.ScannerTest#test_ConstructorLjava_nio_file_Path",
+          "org.apache.harmony.tests.java.util.ScannerTest#test_ConstructorLjava_nio_file_PathLjava_lang_String",
+          "org.apache.harmony.tests.java.util.ScannerTest#test_ConstructorLjava_nio_file_PathLjava_lang_String_Exception",
+          "org.apache.harmony.tests.java.util.ScannerTest#test_ConstructorLjava_nio_file_Path_Exception",
+          "org.apache.harmony.tests.java.util.ScannerTest#test_close",
+          "org.apache.harmony.tests.java.util.ScannerTest#test_delimiter",
+          "org.apache.harmony.tests.java.util.ScannerTest#test_findInLine_LPattern",
+          "org.apache.harmony.tests.java.util.ScannerTest#test_findInLine_LString",
+          "org.apache.harmony.tests.java.util.ScannerTest#test_findInLine_LString_NPEs",
+          "org.apache.harmony.tests.java.util.ScannerTest#test_findWithinHorizon_LPatternI",
+          "org.apache.harmony.tests.java.util.ScannerTest#test_hasNext",
+          "org.apache.harmony.tests.java.util.ScannerTest#test_hasNextBigDecimal",
+          "org.apache.harmony.tests.java.util.ScannerTest#test_hasNextBigInteger",
+          "org.apache.harmony.tests.java.util.ScannerTest#test_hasNextBigIntegerI",
+          "org.apache.harmony.tests.java.util.ScannerTest#test_hasNextBigIntegerI_cache",
+          "org.apache.harmony.tests.java.util.ScannerTest#test_hasNextBoolean",
+          "org.apache.harmony.tests.java.util.ScannerTest#test_hasNextByte",
+          "org.apache.harmony.tests.java.util.ScannerTest#test_hasNextByteI",
+          "org.apache.harmony.tests.java.util.ScannerTest#test_hasNextByteI_cache",
+          "org.apache.harmony.tests.java.util.ScannerTest#test_hasNextDouble",
+          "org.apache.harmony.tests.java.util.ScannerTest#test_hasNextFloat",
+          "org.apache.harmony.tests.java.util.ScannerTest#test_hasNextInt",
+          "org.apache.harmony.tests.java.util.ScannerTest#test_hasNextIntI",
+          "org.apache.harmony.tests.java.util.ScannerTest#test_hasNextIntI_cache",
+          "org.apache.harmony.tests.java.util.ScannerTest#test_hasNextLPattern",
+          "org.apache.harmony.tests.java.util.ScannerTest#test_hasNextLString",
+          "org.apache.harmony.tests.java.util.ScannerTest#test_hasNextLine",
+          "org.apache.harmony.tests.java.util.ScannerTest#test_hasNextLine_sequence",
+          "org.apache.harmony.tests.java.util.ScannerTest#test_hasNextLong",
+          "org.apache.harmony.tests.java.util.ScannerTest#test_hasNextLongI",
+          "org.apache.harmony.tests.java.util.ScannerTest#test_hasNextLongI_cache",
+          "org.apache.harmony.tests.java.util.ScannerTest#test_hasNextShort",
+          "org.apache.harmony.tests.java.util.ScannerTest#test_hasNextShortI",
+          "org.apache.harmony.tests.java.util.ScannerTest#test_hasNextShortI_cache",
+          "org.apache.harmony.tests.java.util.ScannerTest#test_ioException",
+          "org.apache.harmony.tests.java.util.ScannerTest#test_locale",
+          "org.apache.harmony.tests.java.util.ScannerTest#test_match",
+          "org.apache.harmony.tests.java.util.ScannerTest#test_next",
+          "org.apache.harmony.tests.java.util.ScannerTest#test_nextBigDecimal",
+          "org.apache.harmony.tests.java.util.ScannerTest#test_nextBigInteger",
+          "org.apache.harmony.tests.java.util.ScannerTest#test_nextBigIntegerI",
+          "org.apache.harmony.tests.java.util.ScannerTest#test_nextBoolean",
+          "org.apache.harmony.tests.java.util.ScannerTest#test_nextByte",
+          "org.apache.harmony.tests.java.util.ScannerTest#test_nextByteI",
+          "org.apache.harmony.tests.java.util.ScannerTest#test_nextDouble",
+          "org.apache.harmony.tests.java.util.ScannerTest#test_nextFloat",
+          "org.apache.harmony.tests.java.util.ScannerTest#test_nextInt",
+          "org.apache.harmony.tests.java.util.ScannerTest#test_nextIntI",
+          "org.apache.harmony.tests.java.util.ScannerTest#test_nextLPattern",
+          "org.apache.harmony.tests.java.util.ScannerTest#test_nextLString",
+          "org.apache.harmony.tests.java.util.ScannerTest#test_nextLine",
+          "org.apache.harmony.tests.java.util.ScannerTest#test_nextLong",
+          "org.apache.harmony.tests.java.util.ScannerTest#test_nextLongI",
+          "org.apache.harmony.tests.java.util.ScannerTest#test_nextShort",
+          "org.apache.harmony.tests.java.util.ScannerTest#test_nextShortI",
+          "org.apache.harmony.tests.java.util.ScannerTest#test_radix",
+          "org.apache.harmony.tests.java.util.ScannerTest#test_remove",
+          "org.apache.harmony.tests.java.util.ScannerTest#test_skip_LPattern",
+          "org.apache.harmony.tests.java.util.ScannerTest#test_skip_LString",
+          "org.apache.harmony.tests.java.util.ScannerTest#test_toString",
+          "org.apache.harmony.tests.java.util.ScannerTest#test_useDelimiter_LPattern",
+          "org.apache.harmony.tests.java.util.ScannerTest#test_useDelimiter_String",
+          "org.apache.harmony.tests.java.util.ScannerTest#test_useLocale_LLocale",
+          "org.apache.harmony.tests.java.util.ScannerTest#test_useRadix_I"]
+}
+]
diff --git a/tools/run-jdwp-tests.sh b/tools/run-jdwp-tests.sh
index de07a47..21ddcbc 100755
--- a/tools/run-jdwp-tests.sh
+++ b/tools/run-jdwp-tests.sh
@@ -19,6 +19,16 @@
   exit 1
 fi
 
+# Prevent JDWP tests from running on the following devices running
+# Android O (they are failing because of a network-related issue), as
+# a workaround for b/74725685:
+# - FA7BN1A04406 (walleye device testing configuration aosp-poison/volantis-armv7-poison-debug)
+# - FA7BN1A04412 (walleye device testing configuration aosp-poison/volantis-armv8-poison-ndebug)
+# - FA7BN1A04433 (walleye device testing configuration aosp-poison/volantis-armv8-poison-debug)
+case "$ANDROID_SERIAL" in
+  (FA7BN1A04406|FA7BN1A04412|FA7BN1A04433) exit 0;;
+esac
+
 source build/envsetup.sh >&/dev/null # for get_build_var, setpaths
 setpaths # include platform prebuilt java, javac, etc in $PATH.
 
diff --git a/tools/run-libcore-tests.sh b/tools/run-libcore-tests.sh
index 2b7c624..7f0383d 100755
--- a/tools/run-libcore-tests.sh
+++ b/tools/run-libcore-tests.sh
@@ -161,6 +161,16 @@
   fi
 fi
 
+# Disable network-related libcore tests that are failing on the following
+# devices running Android O, as a workaround for b/74725685:
+# - FA7BN1A04406 (walleye device testing configuration aosp-poison/volantis-armv7-poison-debug)
+# - FA7BN1A04412 (walleye device testing configuration aosp-poison/volantis-armv8-poison-ndebug)
+# - FA7BN1A04433 (walleye device testing configuration aosp-poison/volantis-armv8-poison-debug)
+case "$ANDROID_SERIAL" in
+  (FA7BN1A04406|FA7BN1A04412|FA7BN1A04433)
+    expectations="$expectations --expectations art/tools/libcore_network_failures.txt";;
+esac
+
 # Run the tests using vogar.
 echo "Running tests for the following test packages:"
 echo ${working_packages[@]} | tr " " "\n"
diff --git a/tools/setup-buildbot-device.sh b/tools/setup-buildbot-device.sh
index 9373c69..5ce7f52 100755
--- a/tools/setup-buildbot-device.sh
+++ b/tools/setup-buildbot-device.sh
@@ -57,14 +57,19 @@
 adb shell ifconfig lo up
 adb shell ifconfig
 
-# When netd is running, some libcore and JDWP tests fail with this
-# exception (b/74725685):
+# Ensure netd is running, as otherwise the logcat would be spammed
+# with the following messages on devices running Android O:
 #
-#   android.system.ErrnoException: connect failed: EBADMSG (Not a data message)
+#   E NetdConnector: Communications error: java.io.IOException: No such file or directory
+#   E mDnsConnector: Communications error: java.io.IOException: No such file or directory
 #
-# Turn it off to make these tests pass.
-echo -e "${green}Turning off netd${nc}"
-adb shell stop netd
+# Netd was initially disabled as an attempt to solve issues with
+# network-related libcore and JDWP tests failing on devices running
+# Android O (MR1) (see b/74725685). These tests are currently
+# disabled. When a better solution has been found, we should remove
+# the following lines.
+echo -e "${green}Turning on netd${nc}"
+adb shell start netd
 adb shell getprop init.svc.netd
 
 echo -e "${green}List properties${nc}"