Include full logs when we get unexpected denials
Pull all the VM logs, check them for SELinux denials, and if we find
any report the complete log rather than just the denials - to give us
a chance to figure out where they come from.
Bug: 328753027
Test: atest MicrodrdoidHostTestCases
Run on my slightly broken test device which is showing denials
See logs
Change-Id: I6d9ed4ba3e46450acd65e17ce81c48e2d7e35a8e
diff --git a/tests/hostside/java/com/android/microdroid/test/MicrodroidHostTests.java b/tests/hostside/java/com/android/microdroid/test/MicrodroidHostTests.java
index 4f502ab..6dd3afe 100644
--- a/tests/hostside/java/com/android/microdroid/test/MicrodroidHostTests.java
+++ b/tests/hostside/java/com/android/microdroid/test/MicrodroidHostTests.java
@@ -793,12 +793,11 @@
assertWithMessage("Incorrect ABI list").that(abis).hasLength(1);
// Check that no denials have happened so far
+ String logText =
+ getDevice().pullFileContents(CONSOLE_PATH) + getDevice().pullFileContents(LOG_PATH);
assertWithMessage("Unexpected denials during VM boot")
- .that(android.tryRun("egrep", "'avc:[[:space:]]{1,2}denied'", LOG_PATH))
- .isNull();
- assertWithMessage("Unexpected denials during VM boot")
- .that(android.tryRun("egrep", "'avc:[[:space:]]{1,2}denied'", CONSOLE_PATH))
- .isNull();
+ .that(logText)
+ .doesNotContainMatch("avc:\s+denied");
assertThat(getDeviceNumCpus(microdroid)).isEqualTo(getDeviceNumCpus(android));