diff options
author | Nick Kralevich <nnk@google.com> | 2014-03-19 17:37:27 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2014-03-19 17:37:27 +0000 |
commit | 4e1d7d8e5b6dcfea726216a0dd5d40e9c2a9392f (patch) | |
tree | 117fe8c19f7ae4c73267060da2b68ce4a3a67e83 | |
parent | 6dcc15bb6181c3e2754a80b243c9acee712b2631 (diff) | |
parent | 57e6fc1f1a52418aaf6e8d7dffd51d94d88c01db (diff) | |
download | cts-4e1d7d8e5b6dcfea726216a0dd5d40e9c2a9392f.tar.gz |
Merge "cts: Update SELinuxDomain tests"
-rw-r--r-- | tests/tests/security/src/android/security/cts/SELinuxDomainTest.java | 52 |
1 files changed, 44 insertions, 8 deletions
diff --git a/tests/tests/security/src/android/security/cts/SELinuxDomainTest.java b/tests/tests/security/src/android/security/cts/SELinuxDomainTest.java index a227109be95..5aea1667e36 100644 --- a/tests/tests/security/src/android/security/cts/SELinuxDomainTest.java +++ b/tests/tests/security/src/android/security/cts/SELinuxDomainTest.java @@ -45,7 +45,9 @@ public class SELinuxDomainTest extends TestCase { */ private void assertDomainEmpty(String domain) throws FileNotFoundException { List<ProcessDetails> procs = ProcessDetails.getProcessMap().get(domain); - assertNull(procs); + String msg = "Expected no processes in SELinux domain \"" + domain + "\"" + + " Found: \"" + procs + "\""; + assertNull(msg, procs); } /** @@ -59,9 +61,14 @@ public class SELinuxDomainTest extends TestCase { */ private void assertDomainOne(String domain, String executable) throws FileNotFoundException { List<ProcessDetails> procs = ProcessDetails.getProcessMap().get(domain); - assertNotNull(procs); - assertEquals(1, procs.size()); - assertEquals(executable, procs.get(0).procTitle); + String msg = "Expected 1 process in SELinux domain \"" + domain + "\"" + + " Found \"" + procs + "\""; + assertNotNull(msg, procs); + assertEquals(msg, 1, procs.size()); + + msg = "Expected executable \"" + executable + "\" in SELinux domain \"" + domain + "\"" + + "Found: \"" + procs + "\""; + assertEquals(msg, executable, procs.get(0).procTitle); } /** @@ -81,8 +88,37 @@ public class SELinuxDomainTest extends TestCase { /* not on all devices */ return; } - assertEquals(1, procs.size()); - assertEquals(executable, procs.get(0).procTitle); + + String msg = "Expected 1 process in SELinux domain \"" + domain + "\"" + + " Found: \"" + procs + "\""; + assertEquals(msg, 1, procs.size()); + + msg = "Expected executable \"" + executable + "\" in SELinux domain \"" + domain + "\"" + + "Found: \"" + procs.get(0) + "\""; + assertEquals(msg, executable, procs.get(0).procTitle); + } + + /** + * Asserts that a domain must exist, and that the cardinality is greater + * than or equal to 1. + * + * @param domain + * The domain or SELinux context to check. + * @param executable + * The path of the executable or application package name. + */ + private void assertDomainN(String domain, String executable) + throws FileNotFoundException { + List<ProcessDetails> procs = ProcessDetails.getProcessMap().get(domain); + String msg = "Expected 1 or more processes in SELinux domain \"" + domain + "\"" + + " Found \"" + procs + "\""; + assertNotNull(msg, procs); + + for(ProcessDetails p : procs) { + msg = "Expected executable \"" + executable + "\" in SELinux domain \"" + domain + "\"" + + "Found: \"" + p + "\""; + assertEquals(msg, executable, p.procTitle); + } } /* Init is always there */ @@ -137,7 +173,7 @@ public class SELinuxDomainTest extends TestCase { /* Media server is always running */ public void testMediaserverDomain() throws FileNotFoundException { - assertDomainOne("u:r:mediaserver:s0", "/system/bin/mediaserver"); + assertDomainN("u:r:mediaserver:s0", "/system/bin/mediaserver"); } /* Installd is always running */ @@ -203,7 +239,7 @@ public class SELinuxDomainTest extends TestCase { List<ProcessDetails> procs = ProcessDetails.getProcessMap().get(domain); assertNotNull(procs); for (ProcessDetails p : procs) { - assertTrue("Non Kernel thread \"" + p.procTitle + "\" found!", p.isKernel()); + assertTrue("Non Kernel thread \"" + p + "\" found!", p.isKernel()); } } |