test/hotspot/jtreg/serviceability/sa/ClhsdbLauncher.java
changeset 53596 bb40a5303c84
parent 53267 0b6d6db878b6
child 53635 247e5ca412f5
equal deleted inserted replaced
53595:8462b295c08b 53596:bb40a5303c84
    31 import jdk.test.lib.Platform;
    31 import jdk.test.lib.Platform;
    32 import jdk.test.lib.JDKToolLauncher;
    32 import jdk.test.lib.JDKToolLauncher;
    33 import jdk.test.lib.JDKToolFinder;
    33 import jdk.test.lib.JDKToolFinder;
    34 import jdk.test.lib.process.OutputAnalyzer;
    34 import jdk.test.lib.process.OutputAnalyzer;
    35 import jdk.test.lib.SA.SATestUtils;
    35 import jdk.test.lib.SA.SATestUtils;
       
    36 import jtreg.SkippedException;
    36 
    37 
    37 
    38 
    38 /**
    39 /**
    39  * This is a framework to run 'jhsdb clhsdb' commands.
    40  * This is a framework to run 'jhsdb clhsdb' commands.
    40  * See open/test/hotspot/jtreg/serviceability/sa/ClhsdbLongConstant.java for
    41  * See open/test/hotspot/jtreg/serviceability/sa/ClhsdbLongConstant.java for
   175      */
   176      */
   176     public String run(long lingeredAppPid,
   177     public String run(long lingeredAppPid,
   177                       List<String> commands,
   178                       List<String> commands,
   178                       Map<String, List<String>> expectedStrMap,
   179                       Map<String, List<String>> expectedStrMap,
   179                       Map<String, List<String>> unExpectedStrMap)
   180                       Map<String, List<String>> unExpectedStrMap)
   180         throws IOException, InterruptedException {
   181         throws Exception {
   181 
   182 
   182         if (!Platform.shouldSAAttach()) {
   183         if (!Platform.shouldSAAttach()) {
   183             if (Platform.isOSX()) {
   184             if (Platform.isOSX() && SATestUtils.canAddPrivileges()) {
   184                 if (!SATestUtils.canAddPrivileges()) {
   185                 needPrivileges = true;
   185                    // Skip the test if we don't have enough permissions to attach
   186             }
   186                    // and cannot add privileges.
   187             else {
   187                    System.out.println("SA attach not expected to work - test skipped.");
   188                // Skip the test if we don't have enough permissions to attach
   188                    return null;
   189                // and cannot add privileges.
   189                } else {
   190                throw new SkippedException(
   190                    needPrivileges = true;
   191                    "SA attach not expected to work. Insufficient privileges.");
   191                }
   192            }
   192             } else {
       
   193                 System.out.println("SA attach not expected to work. Insufficient privileges.");
       
   194                 throw new Error("Cannot attach.");
       
   195             }
       
   196         }
   193         }
   197 
   194 
   198         attach(lingeredAppPid);
   195         attach(lingeredAppPid);
   199         return runCmd(commands, expectedStrMap, unExpectedStrMap);
   196         return runCmd(commands, expectedStrMap, unExpectedStrMap);
   200     }
   197     }