e.toString(), mRemoteDevice.getSerialNumber() ) ); mParser.handleTestRunFailed( String.format( "Failed to receive adb shell test output within %1$d ms. " + "Test may have timed out, or adb connection to device became unresponsive",
@Test public void commandExecution_ShellCommandUnresponsive() { FakeDevice fakeDevice = FakeDevice.fromDeviceSpec("id1", DeviceState.ONLINE, lDeviceWithLocales("en-US")); fakeDevice.injectShellCommandOutput( "getprop", () -> { throw new ShellCommandUnresponsiveException(); }); AdbShellCommandTask task = new AdbShellCommandTask(fakeDevice, "getprop"); Throwable e = assertThrows(CommandExecutionException.class, () -> task.execute()); assertThat(e).hasMessageThat().contains("Unresponsive shell command while executing adb shell"); assertThat(e).hasCauseThat().isInstanceOf(ShellCommandUnresponsiveException.class); }
private String executeShellCommand(String command) { CollectingOutputReceiver output = new CollectingOutputReceiver(); try { device.executeShellCommand(command, output, 0); } catch (TimeoutException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (AdbCommandRejectedException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (ShellCommandUnresponsiveException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return output.getOutput(); }
timeToResponseCount += wait; if (maxTimeToOutputMs > 0 && timeToResponseCount > maxTimeToOutputMs) { throw new ShellCommandUnresponsiveException();
e.toString(), jarFile, mRemoteDevice.getSerialNumber() ) ); mParser.handleTestRunFailed( String.format( "Failed to receive adb shell test output within %1$d ms. " + "Test may have timed out, or adb connection to device became unresponsive",
if (maxTimeToOutputResponse > 0 && timeToResponseCount > maxTimeToOutputResponse) { throw new ShellCommandUnresponsiveException();
Log.w(LOG_TAG, String.format( "ShellCommandUnresponsiveException %1$s when running tests %2$s on %3$s", e.toString(), getPackageName(), mRemoteDevice.getSerialNumber())); mParser.handleTestRunFailed(String.format( "Failed to receive adb shell test output within %1$d ms. " +
Log.w(LOG_TAG, String.format( "ShellCommandUnresponsiveException %1$s when running tests %2$s on %3$s", e.toString(), getPackageName(), mRemoteDevice.getName())); mParser.handleTestRunFailed(String.format( "Failed to receive adb shell test output within %1$d ms. " +