Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
8238268: Many SA tests are not running on OSX because they do not att…
…empt to use sudo when available

Reviewed-by: sspitsyn, iignatyev
  • Loading branch information
plummercj committed Mar 18, 2020
1 parent 94a6149 commit a147636157c011dac5d8c7aa6809c3c55f1384fa
Showing with 329 additions and 281 deletions.
  1. +1 −2 test/hotspot/jtreg/TEST.ROOT
  2. +2 −2 test/hotspot/jtreg/compiler/ciReplay/TestSAClient.java
  3. +2 −2 test/hotspot/jtreg/compiler/ciReplay/TestSAServer.java
  4. +6 −3 test/hotspot/jtreg/gc/metaspace/CompressedClassSpaceSizeInJmapHeap.java
  5. +5 −4 test/hotspot/jtreg/resourcehogs/serviceability/sa/TestHeapDumpForLargeArray.java
  6. +4 −3 test/hotspot/jtreg/serviceability/sa/CDSJMapClstats.java
  7. +18 −22 test/hotspot/jtreg/serviceability/sa/ClhsdbFindPC.java
  8. +4 −3 test/hotspot/jtreg/serviceability/sa/ClhsdbJstackXcompStress.java
  9. +2 −25 test/hotspot/jtreg/serviceability/sa/ClhsdbLauncher.java
  10. +5 −7 test/hotspot/jtreg/serviceability/sa/DeadlockDetectionTest.java
  11. +4 −4 test/hotspot/jtreg/serviceability/sa/JhsdbThreadInfoTest.java
  12. +6 −2 test/hotspot/jtreg/serviceability/sa/TestClassDump.java
  13. +1 −1 test/hotspot/jtreg/serviceability/sa/TestClhsdbJstackLock.java
  14. +5 −2 test/hotspot/jtreg/serviceability/sa/TestCpoolForInvokeDynamic.java
  15. +5 −3 test/hotspot/jtreg/serviceability/sa/TestDefaultMethods.java
  16. +4 −1 test/hotspot/jtreg/serviceability/sa/TestG1HeapRegion.java
  17. +5 −5 test/hotspot/jtreg/serviceability/sa/TestHeapDumpForInvokeDynamic.java
  18. +6 −4 test/hotspot/jtreg/serviceability/sa/TestInstanceKlassSize.java
  19. +5 −2 test/hotspot/jtreg/serviceability/sa/TestInstanceKlassSizeForInterface.java
  20. +1 −1 test/hotspot/jtreg/serviceability/sa/TestIntConstant.java
  21. +4 −4 test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackLock.java
  22. +4 −4 test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackMixed.java
  23. +1 −2 test/hotspot/jtreg/serviceability/sa/TestPrintMdo.java
  24. +4 −1 test/hotspot/jtreg/serviceability/sa/TestRevPtrsForInvokeDynamic.java
  25. +1 −1 test/hotspot/jtreg/serviceability/sa/TestType.java
  26. +1 −1 test/hotspot/jtreg/serviceability/sa/TestUniverse.java
  27. +5 −4 test/hotspot/jtreg/serviceability/sa/jmap-hprof/JMapHProfLargeHeapTest.java
  28. +5 −3 test/hotspot/jtreg/serviceability/sa/sadebugd/DebugdConnectTest.java
  29. +21 −4 test/hotspot/jtreg/serviceability/sa/sadebugd/SADebugDTest.java
  30. +1 −1 test/hotspot/jtreg/testlibrary_tests/TestMutuallyExclusivePlatformPredicates.java
  31. +0 −1 test/jdk/TEST.ROOT
  32. +6 −11 test/jdk/sun/tools/jhsdb/BasicLauncherTest.java
  33. +6 −6 test/jdk/sun/tools/jhsdb/HeapDumpTest.java
  34. +2 −2 test/jdk/sun/tools/jhsdb/HeapDumpTestWithActiveProcess.java
  35. +6 −4 test/jdk/sun/tools/jhsdb/JShellHeapDumpTest.java
  36. +3 −2 test/jdk/sun/tools/jhsdb/heapconfig/JMapHeapConfigTest.java
  37. +3 −2 test/jdk/sun/tools/jhsdb/heapconfig/TmtoolTestScenario.java
  38. +7 −9 test/jdk/sun/tools/jstack/DeadlockDetectionTest.java
  39. +1 −17 test/jtreg-ext/requires/VMProps.java
  40. +6 −76 test/lib/jdk/test/lib/Platform.java
  41. +151 −28 test/lib/jdk/test/lib/SA/SATestUtils.java
@@ -1,5 +1,5 @@
#
# Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2005, 2020, 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
@@ -55,7 +55,6 @@ requires.properties= \
vm.cpu.features \
vm.debug \
vm.hasSA \
vm.hasSAandCanAttach \
vm.hasJFR \
vm.rtm.cpu \
vm.rtm.compiler \
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2020, 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
@@ -26,7 +26,7 @@
* @bug 8011675
* @library / /test/lib
* @summary testing of ciReplay with using generated by SA replay.txt
* @requires vm.hasSAandCanAttach & vm.flightRecorder != true & vm.compMode != "Xint" & vm.debug == true & vm.flavor == "client"
* @requires vm.hasSA & vm.flightRecorder != true & vm.compMode != "Xint" & vm.debug == true & vm.flavor == "client"
* @modules java.base/jdk.internal.misc
* @build sun.hotspot.WhiteBox
* @run driver ClassFileInstaller sun.hotspot.WhiteBox
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2020, 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
@@ -26,7 +26,7 @@
* @bug 8011675
* @library / /test/lib
* @summary testing of ciReplay with using generated by SA replay.txt
* @requires vm.hasSAandCanAttach & vm.flightRecorder != true & vm.compMode != "Xint" & vm.debug == true & vm.flavor == "server"
* @requires vm.hasSA & vm.flightRecorder != true & vm.compMode != "Xint" & vm.debug == true & vm.flavor == "server"
* @modules java.base/jdk.internal.misc
* @build sun.hotspot.WhiteBox
* @run driver ClassFileInstaller sun.hotspot.WhiteBox
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2020, 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,7 +27,7 @@
* @test CompressedClassSpaceSizeInJmapHeap
* @bug 8004924
* @summary Checks that jmap -heap contains the flag CompressedClassSpaceSize
* @requires vm.hasSAandCanAttach
* @requires vm.hasSA
* @requires vm.bits == 64 & vm.opt.final.UseCompressedOops == true
* @library /test/lib
* @modules java.base/jdk.internal.misc
@@ -39,6 +39,7 @@
import jdk.test.lib.Platform;
import jdk.test.lib.process.OutputAnalyzer;
import jdk.test.lib.process.ProcessTools;
import jdk.test.lib.SA.SATestUtils;
import java.nio.file.*;
import java.io.File;
import java.nio.charset.Charset;
@@ -47,6 +48,8 @@
public class CompressedClassSpaceSizeInJmapHeap {
// Note that on some platforms it may require root privileges to run this test.
public static void main(String[] args) throws Exception {
SATestUtils.skipIfCannotAttach(); // throws SkippedException if attach not expected to work.

if (!Platform.is64bit()) {
// Compressed Class Space is only available on 64-bit JVMs
return;
@@ -59,7 +62,7 @@ public static void main(String[] args) throws Exception {
.addToolArg("--heap")
.addToolArg("--pid")
.addToolArg(pid);
ProcessBuilder pb = new ProcessBuilder(jmap.getCommand());
ProcessBuilder pb = SATestUtils.createProcessBuilder(jmap);

File out = new File("CompressedClassSpaceSizeInJmapHeap.stdout.txt");
pb.redirectOutput(out);
@@ -34,19 +34,20 @@
import sun.jvm.hotspot.debugger.*;

import jdk.test.lib.apps.LingeredApp;
import jdk.test.lib.Asserts;
import jdk.test.lib.JDKToolLauncher;
import jdk.test.lib.JDKToolFinder;
import jdk.test.lib.Platform;
import jdk.test.lib.process.ProcessTools;
import jdk.test.lib.process.OutputAnalyzer;
import jdk.test.lib.SA.SATestUtils;
import jdk.test.lib.Utils;
import jdk.test.lib.Asserts;

/**
* @test
* @library /test/lib
* @bug 8171084
* @requires vm.hasSAandCanAttach & (vm.bits == "64" & os.maxMemory > 8g)
* @requires vm.hasSA & (vm.bits == "64" & os.maxMemory > 8g)
* @modules java.base/jdk.internal.misc
* jdk.hotspot.agent/sun.jvm.hotspot
* jdk.hotspot.agent/sun.jvm.hotspot.utilities
@@ -70,8 +71,7 @@ private static void attachAndDump(String heapDumpFileName,
launcher.addToolArg("--pid");
launcher.addToolArg(Long.toString(lingeredAppPid));

ProcessBuilder processBuilder = new ProcessBuilder();
processBuilder.command(launcher.getCommand());
ProcessBuilder processBuilder = SATestUtils.createProcessBuilder(launcher);
System.out.println(
processBuilder.command().stream().collect(Collectors.joining(" ")));

@@ -86,6 +86,7 @@ private static void attachAndDump(String heapDumpFileName,
}

public static void main (String... args) throws Exception {
SATestUtils.skipIfCannotAttach(); // throws SkippedException if attach not expected to work.

String heapDumpFileName = "LargeArrayHeapDump.bin";

@@ -25,7 +25,7 @@
* @test
* @bug 8204308
* @summary Test the jhsdb jmap -clstats command with CDS enabled
* @requires vm.hasSAandCanAttach & vm.cds
* @requires vm.hasSA & vm.cds
* @library /test/lib
* @run main/othervm/timeout=2400 CDSJMapClstats
*/
@@ -39,6 +39,7 @@
import jdk.test.lib.process.OutputAnalyzer;
import jdk.test.lib.process.ProcessTools;
import jdk.test.lib.JDKToolLauncher;
import jdk.test.lib.SA.SATestUtils;

public class CDSJMapClstats {

@@ -50,8 +51,7 @@ private static void runClstats(long lingeredAppPid) throws Exception {
launcher.addToolArg("--pid");
launcher.addToolArg(Long.toString(lingeredAppPid));

ProcessBuilder processBuilder = new ProcessBuilder();
processBuilder.command(launcher.getCommand());
ProcessBuilder processBuilder = SATestUtils.createProcessBuilder(launcher);
System.out.println(
processBuilder.command().stream().collect(Collectors.joining(" ")));

@@ -64,6 +64,7 @@ private static void runClstats(long lingeredAppPid) throws Exception {

public static void main(String[] args) throws Exception {
System.out.println("Starting CDSJMapClstats test");
SATestUtils.skipIfCannotAttach(); // throws SkippedException if attach not expected to work.
String sharedArchiveName = "ArchiveForCDSJMapClstats.jsa";
LingeredApp theApp = null;

@@ -68,36 +68,32 @@ private static void testFindPC(boolean withXcomp) throws Exception {
// the 'jstack -v' command
cmds = new ArrayList<String>();

// Output could be null if the test was skipped due to
// attach permission issues.
if (output != null) {
String cmdStr = null;
String[] parts = output.split("LingeredAppWithTrivialMain.main");
String[] tokens = parts[1].split(" ");
for (String token : tokens) {
if (token.contains("pc")) {
String[] address = token.split("=");
// address[1] represents the address of the Method
cmdStr = "findpc " + address[1].replace(",","");
cmds.add(cmdStr);
break;
}
String cmdStr = null;
String[] parts = output.split("LingeredAppWithTrivialMain.main");
String[] tokens = parts[1].split(" ");
for (String token : tokens) {
if (token.contains("pc")) {
String[] address = token.split("=");
// address[1] represents the address of the Method
cmdStr = "findpc " + address[1].replace(",","");
cmds.add(cmdStr);
break;
}
}

Map<String, List<String>> expStrMap = new HashMap<>();
if (withXcomp) {
expStrMap.put(cmdStr, List.of(
Map<String, List<String>> expStrMap = new HashMap<>();
if (withXcomp) {
expStrMap.put(cmdStr, List.of(
"In code in NMethod for LingeredAppWithTrivialMain.main",
"content:",
"oops:",
"frame size:"));
} else {
expStrMap.put(cmdStr, List.of(
} else {
expStrMap.put(cmdStr, List.of(
"In interpreter codelet"));
}

test.run(theApp.getPid(), cmds, expStrMap, null);
}

test.run(theApp.getPid(), cmds, expStrMap, null);
} catch (SkippedException se) {
throw se;
} catch (Exception ex) {
@@ -30,14 +30,15 @@
import java.util.stream.Collectors;

import jdk.test.lib.JDKToolLauncher;
import jdk.test.lib.SA.SATestUtils;
import jdk.test.lib.Utils;
import jdk.test.lib.apps.LingeredApp;
import jdk.test.lib.process.OutputAnalyzer;

/**
* @test
* @bug 8196969
* @requires vm.hasSAandCanAttach
* @requires vm.hasSA
* @library /test/lib
* @run main/othervm ClhsdbJstackXcompStress
*/
@@ -63,8 +64,7 @@ private static void runJstackInLoop(LingeredApp app) throws Exception {
launcher.addToolArg("--pid");
launcher.addToolArg(Long.toString(app.getPid()));

ProcessBuilder pb = new ProcessBuilder();
pb.command(launcher.getCommand());
ProcessBuilder pb = SATestUtils.createProcessBuilder(launcher);
Process jhsdb = pb.start();
OutputAnalyzer out = new OutputAnalyzer(jhsdb);

@@ -88,6 +88,7 @@ private static void runJstackInLoop(LingeredApp app) throws Exception {
}

public static void main(String... args) throws Exception {
SATestUtils.skipIfCannotAttach(); // throws SkippedException if attach not expected to work.
LingeredApp app = null;
try {
app = new LingeredAppWithRecComputation();
@@ -33,8 +33,6 @@
import jdk.test.lib.JDKToolFinder;
import jdk.test.lib.process.OutputAnalyzer;
import jdk.test.lib.SA.SATestUtils;
import jtreg.SkippedException;


/**
* This is a framework to run 'jhsdb clhsdb' commands.
@@ -45,11 +43,9 @@
public class ClhsdbLauncher {

private Process toolProcess;
private boolean needPrivileges;

public ClhsdbLauncher() {
toolProcess = null;
needPrivileges = false;
}

/**
@@ -66,11 +62,7 @@ private void attach(long lingeredAppPid)
System.out.println("Starting clhsdb against " + lingeredAppPid);
}

List<String> cmdStringList = Arrays.asList(launcher.getCommand());
if (needPrivileges) {
cmdStringList = SATestUtils.addPrivileges(cmdStringList);
}
ProcessBuilder processBuilder = new ProcessBuilder(cmdStringList);
ProcessBuilder processBuilder = SATestUtils.createProcessBuilder(launcher);
toolProcess = processBuilder.start();
}

@@ -203,22 +195,7 @@ public String run(long lingeredAppPid,
Map<String, List<String>> unExpectedStrMap)
throws Exception {

if (!Platform.shouldSAAttach()) {
if (Platform.isOSX()) {
if (Platform.isSignedOSX()) {
throw new SkippedException("SA attach not expected to work. JDK is signed.");
} else if (SATestUtils.canAddPrivileges()) {
needPrivileges = true;
}
}
if (!needPrivileges) {
// Skip the test if we don't have enough permissions to attach
// and cannot add privileges.
throw new SkippedException(
"SA attach not expected to work. Insufficient privileges.");
}
}

SATestUtils.skipIfCannotAttach(); // throws SkippedException if attach not expected to work.
attach(lingeredAppPid);
return runCmd(commands, expectedStrMap, unExpectedStrMap);
}
@@ -24,8 +24,7 @@
/**
* @test
* @summary Test deadlock detection
* @requires vm.hasSAandCanAttach
* @requires os.family != "mac"
* @requires vm.hasSA
* @library /test/lib
* @modules java.base/jdk.internal.misc
* @modules java.management
@@ -38,18 +37,17 @@

import jdk.test.lib.apps.LingeredApp;
import jdk.test.lib.apps.LingeredAppWithDeadlock;

import jdk.test.lib.Utils;
import jdk.test.lib.JDKToolLauncher;
import jdk.test.lib.process.OutputAnalyzer;
import jdk.test.lib.process.ProcessTools;
import jdk.test.lib.SA.SATestUtils;
import jdk.test.lib.Utils;

import jtreg.SkippedException;

public class DeadlockDetectionTest {

private static LingeredAppWithDeadlock theApp = null;
private static ProcessBuilder processBuilder = new ProcessBuilder();

private static OutputAnalyzer jstack(String... toolArgs) throws Exception {
JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("jhsdb");
@@ -60,7 +58,7 @@ private static OutputAnalyzer jstack(String... toolArgs) throws Exception {
}
}

processBuilder.command(launcher.getCommand());
ProcessBuilder processBuilder = SATestUtils.createProcessBuilder(launcher);
System.out.println(processBuilder.command().stream().collect(Collectors.joining(" ")));
OutputAnalyzer output = ProcessTools.executeProcess(processBuilder);
System.out.println(output.getOutput());
@@ -69,6 +67,7 @@ private static OutputAnalyzer jstack(String... toolArgs) throws Exception {
}

public static void main(String[] args) throws Exception {
SATestUtils.skipIfCannotAttach(); // throws SkippedException if attach not expected to work.
System.out.println("Starting DeadlockDetectionTest");

if (!LingeredApp.isLastModifiedWorking()) {
@@ -91,7 +90,6 @@ public static void main(String[] args) throws Exception {
output.shouldHaveExitValue(0);
output.shouldContain("Found a total of 1 deadlock.");
}

} finally {
LingeredApp.stopApp(theApp);
}

0 comments on commit a147636

Please sign in to comment.