mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-20 11:04:34 +02:00
8153319: new test serviceability/tmtools/jstack/JstackThreadTest.java fails
Reviewed-by: dsamersoff, lmesnik
This commit is contained in:
parent
a9a7c55767
commit
3a4f4362a6
1 changed files with 15 additions and 9 deletions
|
@ -25,6 +25,8 @@ import java.util.Arrays;
|
||||||
import jdk.test.lib.JDKToolLauncher;
|
import jdk.test.lib.JDKToolLauncher;
|
||||||
import jdk.test.lib.OutputAnalyzer;
|
import jdk.test.lib.OutputAnalyzer;
|
||||||
import jdk.test.lib.ProcessTools;
|
import jdk.test.lib.ProcessTools;
|
||||||
|
import utils.Utils;
|
||||||
|
import java.util.concurrent.CountDownLatch;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @test JstackThreadTest
|
* @test JstackThreadTest
|
||||||
|
@ -32,23 +34,22 @@ import jdk.test.lib.ProcessTools;
|
||||||
* @summary jstack doesn't close quotation marks properly with threads' name greater than 1996 characters
|
* @summary jstack doesn't close quotation marks properly with threads' name greater than 1996 characters
|
||||||
* @library /testlibrary
|
* @library /testlibrary
|
||||||
* @build jdk.test.lib.*
|
* @build jdk.test.lib.*
|
||||||
* @ignore 8153319
|
|
||||||
* @run main JstackThreadTest
|
* @run main JstackThreadTest
|
||||||
*/
|
*/
|
||||||
public class JstackThreadTest {
|
public class JstackThreadTest {
|
||||||
static class NamedThread extends Thread {
|
static class NamedThread extends Thread {
|
||||||
NamedThread(String name) {
|
CountDownLatch latch;
|
||||||
|
NamedThread(String name, CountDownLatch latch) {
|
||||||
|
this.latch = latch;
|
||||||
setName(name);
|
setName(name);
|
||||||
|
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
latch.countDown();
|
||||||
Thread.sleep(2000);
|
Utils.sleep();
|
||||||
} catch(Exception e){
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
|
@ -60,8 +61,11 @@ public class JstackThreadTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void testWithName(String name) throws Exception {
|
private static void testWithName(String name) throws Exception {
|
||||||
|
//parent thread countDown latch
|
||||||
|
CountDownLatch latch = new CountDownLatch(1);
|
||||||
// Start a thread with a long thread name
|
// Start a thread with a long thread name
|
||||||
NamedThread thread = new NamedThread(name);
|
NamedThread thread = new NamedThread(name, latch);
|
||||||
|
thread.setDaemon(true);
|
||||||
thread.start();
|
thread.start();
|
||||||
ProcessBuilder processBuilder = new ProcessBuilder();
|
ProcessBuilder processBuilder = new ProcessBuilder();
|
||||||
JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("jstack");
|
JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("jstack");
|
||||||
|
@ -69,6 +73,8 @@ public class JstackThreadTest {
|
||||||
launcher.addToolArg(Long.toString(ProcessTools.getProcessId()));
|
launcher.addToolArg(Long.toString(ProcessTools.getProcessId()));
|
||||||
processBuilder.command(launcher.getCommand());
|
processBuilder.command(launcher.getCommand());
|
||||||
System.out.println(Arrays.toString(processBuilder.command().toArray()).replace(",", ""));
|
System.out.println(Arrays.toString(processBuilder.command().toArray()).replace(",", ""));
|
||||||
|
// Ensuring that Jstack will always run after NamedThread
|
||||||
|
latch.await();
|
||||||
OutputAnalyzer output = ProcessTools.executeProcess(processBuilder);
|
OutputAnalyzer output = ProcessTools.executeProcess(processBuilder);
|
||||||
System.out.println(output.getOutput());
|
System.out.println(output.getOutput());
|
||||||
output.shouldContain("\""+ name + "\"");
|
output.shouldContain("\""+ name + "\"");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue