diff options
author | Elliott Hughes <enh@google.com> | 2015-01-29 17:37:21 -0800 |
---|---|---|
committer | Elliott Hughes <enh@google.com> | 2015-01-29 17:37:21 -0800 |
commit | 14f694589bb5944e7f3e6862600ba25b15a37d18 (patch) | |
tree | 8ff22e2509e0589373888d17ef81854521144949 /harmony-tests/src/test/java | |
parent | 1a11432d5e0bbe320f69603efb01730fb748305d (diff) | |
download | libcore-14f694589bb5944e7f3e6862600ba25b15a37d18.zip libcore-14f694589bb5944e7f3e6862600ba25b15a37d18.tar.gz libcore-14f694589bb5944e7f3e6862600ba25b15a37d18.tar.bz2 |
Remove flakiness from ProcessTest.
If run as root, ps(1) will list far too many processes, some of which
might coincidentally be zombies.
Note that we wanted "ps S" to show the STAT field, not "ps s" to
show the signal masks which also shows the STAT field as a side-effect.
Change-Id: Iedbcb45b871b1207248cb59c3a5fae9be5b0b3e2
Diffstat (limited to 'harmony-tests/src/test/java')
-rw-r--r-- | harmony-tests/src/test/java/org/apache/harmony/tests/java/lang/ProcessTest.java | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/harmony-tests/src/test/java/org/apache/harmony/tests/java/lang/ProcessTest.java b/harmony-tests/src/test/java/org/apache/harmony/tests/java/lang/ProcessTest.java index 1a73719..c7a6e71 100644 --- a/harmony-tests/src/test/java/org/apache/harmony/tests/java/lang/ProcessTest.java +++ b/harmony-tests/src/test/java/org/apache/harmony/tests/java/lang/ProcessTest.java @@ -22,9 +22,10 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.ArrayList; +import libcore.io.Libcore; public class ProcessTest extends junit.framework.TestCase { - + // Test that failures to exec don't leave zombies lying around. public void test_55017() throws Exception { ArrayList<Process> children = new ArrayList<Process>(); for (int i = 0; i < 256; ++i) { @@ -36,13 +37,15 @@ public class ProcessTest extends junit.framework.TestCase { } assertEquals(0, children.size()); + String pid = Integer.toString(Libcore.os.getpid()); boolean onDevice = new File("/system/bin").exists(); - String[] psCommand = onDevice ? new String[] { "ps" } : new String[] { "ps", "s" }; + String[] psCommand = onDevice ? new String[] { "ps", "--ppid", pid } + : new String[] { "ps", "S", "--ppid", pid }; Process ps = Runtime.getRuntime().exec(psCommand, null, null); int zombieCount = 0; for (String line : readAndCloseStream(ps.getInputStream()).split("\n")) { if (line.contains(" Z ") || line.contains(" Z+ ")) { - ++zombieCount; + ++zombieCount; } } assertEquals(0, zombieCount); |