# HG changeset patch # User lana # Date 1517540100 0 # Node ID 678e1ec433a05896b74f3ff3e4ea9c980b675a7e # Parent aca813e53416bdf0441275fbcafb071f9137e0b9# Parent d68d95009bdbb5c384e99e9452da4da9d853ee10 Merge diff -r d68d95009bdb -r 678e1ec433a0 test/hotspot/jtreg/serviceability/dcmd/jvmti/DataDumpDcmdTest.java --- a/test/hotspot/jtreg/serviceability/dcmd/jvmti/DataDumpDcmdTest.java Fri Feb 02 01:52:03 2018 +0000 +++ b/test/hotspot/jtreg/serviceability/dcmd/jvmti/DataDumpDcmdTest.java Fri Feb 02 02:55:00 2018 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,6 +27,11 @@ import jdk.test.lib.dcmd.PidJcmdExecutor; import org.testng.annotations.Test; +import java.util.Arrays; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + /* * @test * @bug 8054890 @@ -43,9 +48,19 @@ */ public class DataDumpDcmdTest { public void run(CommandExecutor executor) { - OutputAnalyzer output = executor.execute("JVMTI.data_dump"); + OutputAnalyzer out = executor.execute("JVMTI.data_dump"); - output.stderrShouldBeEmpty(); + // stderr should be empty except for VM warnings. + if (!out.getStderr().isEmpty()) { + List lines = Arrays.asList(out.getStderr().split("(\\r\\n|\\n|\\r)")); + Pattern p = Pattern.compile(".*VM warning.*"); + for (String line : lines) { + Matcher m = p.matcher(line); + if (!m.matches()) { + throw new RuntimeException("Stderr has output other than VM warnings"); + } + } + } } @Test diff -r d68d95009bdb -r 678e1ec433a0 test/hotspot/jtreg/serviceability/dcmd/jvmti/LoadAgentDcmdTest.java --- a/test/hotspot/jtreg/serviceability/dcmd/jvmti/LoadAgentDcmdTest.java Fri Feb 02 01:52:03 2018 +0000 +++ b/test/hotspot/jtreg/serviceability/dcmd/jvmti/LoadAgentDcmdTest.java Fri Feb 02 02:55:00 2018 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -22,10 +22,14 @@ */ import java.io.*; import java.nio.file.*; +import java.util.Arrays; import java.util.jar.Attributes; import java.util.jar.JarEntry; import java.util.jar.JarOutputStream; import java.util.jar.Manifest; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import jdk.test.lib.Platform; import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.dcmd.*; @@ -97,6 +101,20 @@ } } + static void checkWarningsOnly(OutputAnalyzer out) { + // stderr should be empty except for VM warnings. + if (!out.getStderr().isEmpty()) { + List lines = Arrays.asList(out.getStderr().split("(\\r\\n|\\n|\\r)")); + Pattern p = Pattern.compile(".*VM warning.*"); + for (String line : lines) { + Matcher m = p.matcher(line); + if (!m.matches()) { + throw new RuntimeException("Stderr has output other than VM warnings"); + } + } + } + } + public void run(CommandExecutor executor) { try{ @@ -108,22 +126,22 @@ // Test 1: Native agent, no arguments output = executor.execute("JVMTI.agent_load " + libpath + " agent.jar"); - output.stderrShouldBeEmpty(); + checkWarningsOnly(output); // Test 2: Native agent, with arguments output = executor.execute("JVMTI.agent_load " + libpath + " \"agent.jar=foo=bar\""); - output.stderrShouldBeEmpty(); + checkWarningsOnly(output); // Test 3: Java agent, no arguments output = executor.execute("JVMTI.agent_load " + "agent.jar"); - output.stderrShouldBeEmpty(); + checkWarningsOnly(output); // Test 4: Java agent, with arguments output = executor.execute("JVMTI.agent_load " + "\"agent.jar=foo=bar\""); - output.stderrShouldBeEmpty(); + checkWarningsOnly(output); } catch (Exception e) { throw new RuntimeException(e);