8217473: SA: Tests using ClhsdbLauncher fail on SAP docker containers

Skip the test with jtreg.SkippedException if Platform.shouldSAAttach() returns false

Reviewed-by: dholmes, goetz
This commit is contained in:
Jini George 2019-02-01 11:29:31 +05:30
parent ac3711e9cd
commit 55369945b9
21 changed files with 69 additions and 67 deletions

@ -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
@ -26,6 +26,7 @@ import java.util.List;
import java.util.Map;
import jdk.test.lib.apps.LingeredApp;
import jtreg.SkippedException;
/**
* @test
@ -68,6 +69,8 @@ public class ClhsdbAttach {
"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 {

@ -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
@ -25,6 +25,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import jdk.test.lib.apps.LingeredApp;
import jtreg.SkippedException;
/**
* @test
@ -63,6 +64,8 @@ public class ClhsdbField {
"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 {

@ -27,6 +27,8 @@ import java.util.Map;
import java.util.ArrayList;
import jdk.test.lib.apps.LingeredApp;
import jtreg.SkippedException;
/**
* @test
* @bug 8193124
@ -91,6 +93,8 @@ public class ClhsdbFindPC {
test.run(theApp.getPid(), cmds, expStrMap, null);
}
} catch (SkippedException se) {
throw se;
} catch (Exception ex) {
throw new RuntimeException("Test ERROR " + ex, ex);
} finally {

@ -29,6 +29,7 @@ import java.util.Map;
import jdk.test.lib.apps.LingeredApp;
import jdk.test.lib.Platform;
import jdk.test.lib.Utils;
import jtreg.SkippedException;
/**
* @test
@ -82,6 +83,8 @@ public class ClhsdbFlags {
"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 {

@ -57,13 +57,6 @@ public class ClhsdbInspect {
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");

@ -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
@ -57,11 +57,6 @@ public class ClhsdbJdis {
// 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(" ");

@ -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
@ -28,6 +28,7 @@ import java.util.Map;
import jdk.test.lib.apps.LingeredApp;
import jdk.test.lib.Utils;
import jtreg.SkippedException;
/**
* @test
@ -68,6 +69,8 @@ public class ClhsdbJhisto {
"ParselTongue"));
test.run(theApp.getPid(), cmds, expStrMap, null);
} catch (SkippedException se) {
throw se;
} catch (Exception ex) {
throw new RuntimeException("Test ERROR " + ex, ex);
} finally {

@ -27,6 +27,7 @@ import java.util.Map;
import jdk.test.lib.apps.LingeredApp;
import jdk.test.lib.Platform;
import jtreg.SkippedException;
/**
* @test
@ -64,6 +65,8 @@ public class ClhsdbJstack {
"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 {

@ -33,6 +33,7 @@ import jdk.test.lib.JDKToolLauncher;
import jdk.test.lib.JDKToolFinder;
import jdk.test.lib.process.OutputAnalyzer;
import jdk.test.lib.SA.SATestUtils;
import jtreg.SkippedException;
/**
@ -177,22 +178,18 @@ public class ClhsdbLauncher {
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);

@ -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
@ -75,9 +75,6 @@ public class ClhsdbLongConstant {
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;

@ -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
@ -27,6 +27,7 @@ import java.util.Map;
import jdk.test.lib.apps.LingeredApp;
import jdk.test.lib.Platform;
import jtreg.SkippedException;
/**
* @test
@ -57,6 +58,8 @@ public class ClhsdbPmap {
"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 {

@ -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
@ -25,6 +25,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import jdk.test.lib.apps.LingeredApp;
import jtreg.SkippedException;
/**
* @test
@ -68,6 +69,8 @@ public class ClhsdbPrintAll {
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 {

@ -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
@ -55,11 +55,6 @@ public class ClhsdbPrintAs {
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;

@ -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
@ -27,6 +27,7 @@ import java.util.Map;
import jdk.test.lib.apps.LingeredApp;
import jdk.test.lib.Platform;
import jtreg.SkippedException;
/**
* @test
@ -83,6 +84,8 @@ public class ClhsdbPrintStatics {
"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 {

@ -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
@ -27,6 +27,7 @@ import java.util.Map;
import jdk.test.lib.apps.LingeredApp;
import jdk.test.lib.Platform;
import jtreg.SkippedException;
/**
* @test
@ -58,6 +59,8 @@ public class ClhsdbPstack {
"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 {

@ -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
@ -70,11 +70,6 @@ public class ClhsdbRegionDetailsScanOopsForG1 {
unExpStrMap.put("g1regiondetails", List.of("Unknown Region Type"));
String regionDetailsOutput = test.run(theApp.getPid(), cmds,
expStrMap, unExpStrMap);
if (regionDetailsOutput == null) {
LingeredApp.stopApp(theApp);
throw new SkippedException("attach permission issues");
}
// Test the output of 'scanoops' -- get the start and end addresses
// from the StartsHumongous region. Ensure that it contains an
// array of Strings.

@ -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
@ -58,11 +58,6 @@ public class ClhsdbScanOops {
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<>();

@ -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
@ -29,6 +29,7 @@ import java.util.List;
import java.util.Map;
import jdk.test.lib.apps.LingeredApp;
import jtreg.SkippedException;
/**
* @test
@ -74,6 +75,8 @@ public class ClhsdbSource {
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 {

@ -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
@ -25,6 +25,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import jdk.test.lib.apps.LingeredApp;
import jtreg.SkippedException;
/**
* @test
@ -76,14 +77,6 @@ public class ClhsdbThread {
expStrMap,
unExpStrMap);
if (consolidatedOutput == null) {
// Output could be null due to attach permission issues.
System.out.println(
"Output is empty. Probably due to attach permission issues.");
LingeredApp.stopApp(theApp);
return;
}
// Test the thread <id> command now. Obtain <id> from the
// output of the previous 'threads' command. The word before
// the token 'Finalizer' should denote the thread id of the
@ -109,6 +102,8 @@ public class ClhsdbThread {
"Last_Java_SP"));
cmds = List.of(cmd);
test.run(theApp.getPid(), cmds, expStrMap, null);
} catch (SkippedException se) {
throw se;
} catch (Exception ex) {
throw new RuntimeException("Test ERROR " + ex, ex);
} finally {

@ -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
@ -25,6 +25,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import jdk.test.lib.apps.LingeredApp;
import jtreg.SkippedException;
/**
* @test
@ -63,6 +64,8 @@ public class ClhsdbVmStructsDump {
"type Universe null",
"type ConstantPoolCache MetaspaceObj"));
test.run(theApp.getPid(), cmds, expStrMap, null);
} catch (SkippedException se) {
throw se;
} catch (Exception ex) {
throw new RuntimeException("Test ERROR " + ex, ex);
} finally {

@ -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
@ -27,6 +27,7 @@ import java.util.Map;
import jdk.test.lib.apps.LingeredApp;
import jdk.test.lib.Platform;
import jtreg.SkippedException;
/**
* @test
@ -63,6 +64,8 @@ public class ClhsdbWhere {
"public static void main"));
test.run(theApp.getPid(), cmds, expStrMap, null);
} catch (SkippedException se) {
throw se;
} catch (Exception ex) {
throw new RuntimeException("Test ERROR " + ex, ex);
} finally {