From c9769ad10b02ef7ec6d981b2c4c33ddaee6eb1e7 Mon Sep 17 00:00:00 2001 From: Sudheer Shanka Date: Thu, 14 Apr 2022 00:43:45 +0000 Subject: [PATCH] Throw an error if a shell command results in an error. Some services will write to the error stream if there is an issue with handling the shell command but these error messages are ignored currently as we are only looking at output stream. So, update it to also consider messages in the error stream and if the content in error stream is not empty, then throw an exception. Bug: 228117528 Test: atest com.android.cts.net.HostsideRestrictBackgroundNetworkTests Change-Id: I935a74b4a689825de414226a2108f6a836b212ab --- .../com/android/cts/net/hostside/NetworkPolicyTestUtils.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/cts/hostside/app/src/com/android/cts/net/hostside/NetworkPolicyTestUtils.java b/tests/cts/hostside/app/src/com/android/cts/net/hostside/NetworkPolicyTestUtils.java index b6218d2acc..56be3e3f16 100644 --- a/tests/cts/hostside/app/src/com/android/cts/net/hostside/NetworkPolicyTestUtils.java +++ b/tests/cts/hostside/app/src/com/android/cts/net/hostside/NetworkPolicyTestUtils.java @@ -25,7 +25,7 @@ import static android.net.NetworkCapabilities.TRANSPORT_WIFI; import static android.net.wifi.WifiConfiguration.METERED_OVERRIDE_METERED; import static android.net.wifi.WifiConfiguration.METERED_OVERRIDE_NONE; -import static com.android.compatibility.common.util.SystemUtil.runShellCommand; +import static com.android.compatibility.common.util.SystemUtil.runShellCommandOrThrow; import static com.android.cts.net.hostside.AbstractRestrictBackgroundNetworkTestCase.TAG; import static org.junit.Assert.assertEquals; @@ -390,7 +390,7 @@ public class NetworkPolicyTestUtils { } public static String executeShellCommand(String command) { - final String result = runShellCommand(command).trim(); + final String result = runShellCommandOrThrow(command).trim(); Log.d(TAG, "Output of '" + command + "': '" + result + "'"); return result; }