Skip to content

Commit

Permalink
8217473: SA: Tests using ClhsdbLauncher fail on SAP docker containers
Browse files Browse the repository at this point in the history
Skip the test with jtreg.SkippedException if Platform.shouldSAAttach() returns false

Reviewed-by: mdoerr
Backport-of: 5536994
  • Loading branch information
GoeLin committed Mar 18, 2022
1 parent ca21a70 commit 8f3308a
Show file tree
Hide file tree
Showing 20 changed files with 68 additions and 61 deletions.
5 changes: 4 additions & 1 deletion test/hotspot/jtreg/serviceability/sa/ClhsdbAttach.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2019, 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
Expand All @@ -26,6 +26,7 @@
import java.util.Map;

import jdk.test.lib.apps.LingeredApp;
import jtreg.SkippedException;

/**
* @test
Expand Down Expand Up @@ -68,6 +69,8 @@ public static void main(String[] args) throws Exception {
"longConstant markOopDesc::locked_value"));

test.run(-1, cmds, expStrMap, null);
} catch (SkippedException se) {
throw se;
} catch (Exception ex) {
throw new RuntimeException("Test ERROR " + ex, ex);
} finally {
Expand Down
5 changes: 4 additions & 1 deletion test/hotspot/jtreg/serviceability/sa/ClhsdbField.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2019, 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
Expand All @@ -25,6 +25,7 @@
import java.util.List;
import java.util.Map;
import jdk.test.lib.apps.LingeredApp;
import jtreg.SkippedException;

/**
* @test
Expand Down Expand Up @@ -63,6 +64,8 @@ public static void main(String[] args) throws Exception {
"field nmethod _entry_bci int",
"field Universe _collectedHeap CollectedHeap"));
test.run(theApp.getPid(), cmds, expStrMap, null);
} catch (SkippedException se) {
throw se;
} catch (Exception ex) {
throw new RuntimeException("Test ERROR " + ex, ex);
} finally {
Expand Down
4 changes: 4 additions & 0 deletions test/hotspot/jtreg/serviceability/sa/ClhsdbFindPC.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
import java.util.ArrayList;

import jdk.test.lib.apps.LingeredApp;
import jtreg.SkippedException;

/**
* @test
* @bug 8193124
Expand Down Expand Up @@ -96,6 +98,8 @@ private static void testFindPC(boolean withXcomp) throws Exception {

test.run(theApp.getPid(), cmds, expStrMap, null);
}
} catch (SkippedException se) {
throw se;
} catch (Exception ex) {
throw new RuntimeException("Test ERROR " + ex, ex);
} finally {
Expand Down
3 changes: 3 additions & 0 deletions test/hotspot/jtreg/serviceability/sa/ClhsdbFlags.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

import jdk.test.lib.apps.LingeredApp;
import jdk.test.lib.Utils;
import jtreg.SkippedException;

/**
* @test
Expand Down Expand Up @@ -80,6 +81,8 @@ public static void main(String[] args) throws Exception {
"MaxJavaStackTraceDepth = 1024"));

test.run(theApp.getPid(), cmds, expStrMap, null);
} catch (SkippedException se) {
throw se;
} catch (Exception ex) {
throw new RuntimeException("Test ERROR " + ex, ex);
} finally {
Expand Down
7 changes: 0 additions & 7 deletions test/hotspot/jtreg/serviceability/sa/ClhsdbInspect.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,6 @@ public static void main(String[] args) throws Exception {

String jstackOutput = test.run(theApp.getPid(), cmds, null, null);

if (jstackOutput == null) {
// Output could be null due to attach permission issues
// and if we are skipping this.
LingeredApp.stopApp(theApp);
throw new SkippedException("attach permission issues");
}

Map<String, String> tokensMap = new HashMap<>();
tokensMap.put("(a java.lang.Class for LingeredAppWithLock)",
"instance of Oop for java/lang/Class");
Expand Down
7 changes: 1 addition & 6 deletions test/hotspot/jtreg/serviceability/sa/ClhsdbJdis.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2019, 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
Expand Down Expand Up @@ -57,11 +57,6 @@ public static void main(String[] args) 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) {
throw new SkippedException("attach permission issues");
}
String cmdStr = null;
String[] parts = output.split("LingeredApp.main");
String[] tokens = parts[1].split(" ");
Expand Down
5 changes: 4 additions & 1 deletion test/hotspot/jtreg/serviceability/sa/ClhsdbJhisto.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2019, 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
Expand Down Expand Up @@ -28,6 +28,7 @@

import jdk.test.lib.apps.LingeredApp;
import jdk.test.lib.Utils;
import jtreg.SkippedException;

/**
* @test
Expand Down Expand Up @@ -67,6 +68,8 @@ public static void main(String[] args) throws Exception {
"ParselTongue"));

test.run(theApp.getPid(), cmds, expStrMap, null);
} catch (SkippedException se) {
throw se;
} catch (Exception ex) {
throw new RuntimeException("Test ERROR " + ex, ex);
} finally {
Expand Down
3 changes: 3 additions & 0 deletions test/hotspot/jtreg/serviceability/sa/ClhsdbJstack.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.util.Map;

import jdk.test.lib.apps.LingeredApp;
import jtreg.SkippedException;

/**
* @test
Expand Down Expand Up @@ -63,6 +64,8 @@ private static void testJstack(boolean withXcomp) throws Exception {
"LingeredApp.main"));

test.run(theApp.getPid(), cmds, expStrMap, null);
} catch (SkippedException se) {
throw se;
} catch (Exception ex) {
throw new RuntimeException("Test ERROR (with -Xcomp=" + withXcomp + ") " + ex, ex);
} finally {
Expand Down
23 changes: 10 additions & 13 deletions test/hotspot/jtreg/serviceability/sa/ClhsdbLauncher.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import jdk.test.lib.JDKToolFinder;
import jdk.test.lib.process.OutputAnalyzer;
import jdk.test.lib.SA.SATestUtils;
import jtreg.SkippedException;


/**
Expand Down Expand Up @@ -177,22 +178,18 @@ public String run(long lingeredAppPid,
List<String> commands,
Map<String, List<String>> expectedStrMap,
Map<String, List<String>> unExpectedStrMap)
throws IOException, InterruptedException {
throws Exception {

if (!Platform.shouldSAAttach()) {
if (Platform.isOSX()) {
if (!SATestUtils.canAddPrivileges()) {
// Skip the test if we don't have enough permissions to attach
// and cannot add privileges.
System.out.println("SA attach not expected to work - test skipped.");
return null;
} else {
needPrivileges = true;
}
} else {
System.out.println("SA attach not expected to work. Insufficient privileges.");
throw new Error("Cannot attach.");
if (Platform.isOSX() && SATestUtils.canAddPrivileges()) {
needPrivileges = true;
}
else {
// 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.");
}
}

attach(lingeredAppPid);
Expand Down
5 changes: 1 addition & 4 deletions test/hotspot/jtreg/serviceability/sa/ClhsdbLongConstant.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2019, 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
Expand Down Expand Up @@ -75,9 +75,6 @@ public static void main(String[] args) throws Exception {

String longConstantOutput = test.run(theApp.getPid(), cmds, expStrMap, unExpStrMap);

if (longConstantOutput == null) {
throw new SkippedException("attach permission issues");
}
checkForTruncation(longConstantOutput);
} catch (SkippedException e) {
throw e;
Expand Down
5 changes: 4 additions & 1 deletion test/hotspot/jtreg/serviceability/sa/ClhsdbPmap.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2019, 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
Expand All @@ -26,6 +26,7 @@
import java.util.Map;

import jdk.test.lib.apps.LingeredApp;
import jtreg.SkippedException;

/**
* @test
Expand Down Expand Up @@ -56,6 +57,8 @@ public static void main(String[] args) throws Exception {
"jimage", "zip", "verify"));

test.run(theApp.getPid(), cmds, expStrMap, null);
} catch (SkippedException se) {
throw se;
} catch (Exception ex) {
throw new RuntimeException("Test ERROR " + ex, ex);
} finally {
Expand Down
5 changes: 4 additions & 1 deletion test/hotspot/jtreg/serviceability/sa/ClhsdbPrintAll.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2019, 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
Expand All @@ -25,6 +25,7 @@
import java.util.List;
import java.util.Map;
import jdk.test.lib.apps.LingeredApp;
import jtreg.SkippedException;

/**
* @test
Expand Down Expand Up @@ -68,6 +69,8 @@ public static void main(String[] args) throws Exception {
unExpStrMap.put("printall", List.of(
"cannot be cast to"));
test.run(theApp.getPid(), cmds, expStrMap, unExpStrMap);
} catch (SkippedException se) {
throw se;
} catch (Exception ex) {
throw new RuntimeException("Test ERROR " + ex, ex);
} finally {
Expand Down
7 changes: 1 addition & 6 deletions test/hotspot/jtreg/serviceability/sa/ClhsdbPrintAs.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2019, 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
Expand Down Expand Up @@ -55,11 +55,6 @@ public static void main(String[] args) throws Exception {

String jstackOutput = test.run(theApp.getPid(), cmds, null, null);

if (jstackOutput == null) {
LingeredApp.stopApp(theApp);
throw new SkippedException("attach permission issues");
}

String[] snippets = jstackOutput.split("LingeredApp.main");
String addressString = null;

Expand Down
5 changes: 4 additions & 1 deletion test/hotspot/jtreg/serviceability/sa/ClhsdbPrintStatics.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2019, 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
Expand All @@ -26,6 +26,7 @@
import java.util.Map;

import jdk.test.lib.apps.LingeredApp;
import jtreg.SkippedException;

/**
* @test
Expand Down Expand Up @@ -83,6 +84,8 @@ public static void main(String[] args) throws Exception {
"bool JvmtiExport::_can_post_on_exceptions"));

test.run(theApp.getPid(), cmds, expStrMap, null);
} catch (SkippedException se) {
throw se;
} catch (Exception ex) {
throw new RuntimeException("Test ERROR " + ex, ex);
} finally {
Expand Down
5 changes: 4 additions & 1 deletion test/hotspot/jtreg/serviceability/sa/ClhsdbPstack.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2019, 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
Expand All @@ -26,6 +26,7 @@
import java.util.Map;

import jdk.test.lib.apps.LingeredApp;
import jtreg.SkippedException;

/**
* @test
Expand Down Expand Up @@ -57,6 +58,8 @@ public static void main(String[] args) throws Exception {
"Reference Handler", "Finalizer", "main"));

test.run(theApp.getPid(), cmds, expStrMap, null);
} catch (SkippedException se) {
throw se;
} catch (Exception ex) {
throw new RuntimeException("Test ERROR " + ex, ex);
} finally {
Expand Down
7 changes: 1 addition & 6 deletions test/hotspot/jtreg/serviceability/sa/ClhsdbScanOops.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2019, 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
Expand Down Expand Up @@ -58,11 +58,6 @@ private static void testWithGcType(String gc) throws Exception {

String universeOutput = test.run(theApp.getPid(), cmds, null, null);

if (universeOutput == null) {
LingeredApp.stopApp(theApp);
throw new SkippedException("attach permission issues");
}

cmds = new ArrayList<String>();
Map<String, List<String>> expStrMap = new HashMap<>();
Map<String, List<String>> unExpStrMap = new HashMap<>();
Expand Down
5 changes: 4 additions & 1 deletion test/hotspot/jtreg/serviceability/sa/ClhsdbSource.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2019, 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
Expand Down Expand Up @@ -29,6 +29,7 @@
import java.util.Map;

import jdk.test.lib.apps.LingeredApp;
import jtreg.SkippedException;

/**
* @test
Expand Down Expand Up @@ -74,6 +75,8 @@ public static void main(String[] args) throws Exception {

test.run(theApp.getPid(), cmds, expStrMap, unExpStrMap);
Files.delete(file);
} catch (SkippedException se) {
throw se;
} catch (Exception ex) {
throw new RuntimeException("Test ERROR " + ex, ex);
} finally {
Expand Down
Loading

1 comment on commit 8f3308a

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.