8199874: [TESTBUG] runtime/Thread/ThreadPriorities.java fails with "expected 0 to equal 10"

Reviewed-by: lfoltan, ccheung
This commit is contained in:
David Holmes 2018-09-06 02:01:20 -04:00
parent c201a7f8c9
commit 0d9f615e92

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -30,7 +30,8 @@
* @library /test/lib * @library /test/lib
* @modules java.base/jdk.internal.misc * @modules java.base/jdk.internal.misc
* java.management * java.management
* @run main ThreadPriorities * @comment Use othervm mode so that we don't capture unrelated threads created by other tests
* @run main/othervm ThreadPriorities
*/ */
import java.util.ArrayList; import java.util.ArrayList;
@ -75,7 +76,7 @@ public class ThreadPriorities {
JDKToolFinder.getJDKTool("jstack"), JDKToolFinder.getJDKTool("jstack"),
String.valueOf(ProcessTools.getProcessId())); String.valueOf(ProcessTools.getProcessId()));
String[] output = new OutputAnalyzer(pb.start()).getOutput().split("\\n+"); String[] output = new OutputAnalyzer(pb.start()).getOutput().split("\\R");
Pattern pattern = Pattern.compile( Pattern pattern = Pattern.compile(
"\\\"Priority=(\\d+)\\\".* prio=(\\d+).*"); "\\\"Priority=(\\d+)\\\".* prio=(\\d+).*");
@ -93,8 +94,20 @@ public class ThreadPriorities {
barrier.await(); // 2nd barrier.await(); // 2nd
barrier.reset(); barrier.reset();
assertEquals(matches, NUMBER_OF_JAVA_PRIORITIES); boolean success = false;
assertTrue(failed.isEmpty(), failed.size() + ":" + failed); try {
assertEquals(matches, NUMBER_OF_JAVA_PRIORITIES);
assertTrue(failed.isEmpty(), failed.size() + ":" + failed);
success = true;
}
finally {
if (!success) {
System.out.println("Failure detected - dumping jstack output:");
for (String line : output) {
System.out.println(line);
}
}
}
} }
} }