Include shell command in some assertion messages
Adding the shell command to the assertion error should make it
easier to debug.
(This has been on my local branch for no particular reason)
Bug: None
Test: None
Change-Id: Ia66dba755d0f90082dc8ad45e5e374e713330a9f
diff --git a/tests/hostside/helper/java/com/android/microdroid/test/host/MicrodroidHostTestCaseBase.java b/tests/hostside/helper/java/com/android/microdroid/test/host/MicrodroidHostTestCaseBase.java
index 36379af..1a1dbeb 100644
--- a/tests/hostside/helper/java/com/android/microdroid/test/host/MicrodroidHostTestCaseBase.java
+++ b/tests/hostside/helper/java/com/android/microdroid/test/host/MicrodroidHostTestCaseBase.java
@@ -130,14 +130,17 @@
private static String runOnHostWithTimeout(long timeoutMillis, String... cmd) {
assertThat(timeoutMillis).isAtLeast(0);
CommandResult result = RunUtil.getDefault().runTimedCmd(timeoutMillis, cmd);
- assertThat(result).isSuccess();
+ assertWithMessage("Host command `" + join(cmd) + "` did not succeed")
+ .about(command_results())
+ .that(result)
+ .isSuccess();
return result.getStdout().trim();
}
// Run a shell command on Microdroid
public static String runOnMicrodroid(String... cmd) {
CommandResult result = runOnMicrodroidForResult(cmd);
- assertWithMessage("microdroid shell cmd `" + join(cmd) + "`")
+ assertWithMessage("Microdroid command `" + join(cmd) + "` did not succeed")
.about(command_results())
.that(result)
.isSuccess();
@@ -197,7 +200,11 @@
// Asserts the command will fail on Microdroid.
public static void assertFailedOnMicrodroid(String... cmd) {
- assertThat(runOnMicrodroidForResult(cmd)).isFailed();
+ CommandResult result = runOnMicrodroidForResult(cmd);
+ assertWithMessage("Microdroid command `" + join(cmd) + "` did not fail expectedly")
+ .about(command_results())
+ .that(result)
+ .isFailed();
}
private static String join(String... strs) {