< prev index next >

test/hotspot/jtreg/serviceability/sa/TestJmapCore.java

Print this page




  70             }
  71         }
  72         test(args[1]);
  73     }
  74 
  75     // Test tries to run java with ulimit unlimited if it is possible
  76     static boolean useDefaultUlimit() {
  77         if (Platform.isWindows()) {
  78             return true;
  79         }
  80         try {
  81             OutputAnalyzer output = ProcessTools.executeProcess("sh", "-c", "ulimit -c unlimited && ulimit -c");
  82             return !(output.getExitValue() == 0 && output.getStdout().contains("unlimited"));
  83         } catch (Throwable t) {
  84             return true;
  85         }
  86     }
  87 
  88     static void test(String type) throws Throwable {
  89         ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, "-XX:+CreateCoredumpOnCrash",
  90                 "-XX:MaxMetaspaceSize=64m", "-XX:+CrashOnOutOfMemoryError",
  91                 TestJmapCore.class.getName(), type);
  92 
  93         boolean useDefaultUlimit = useDefaultUlimit();
  94         System.out.println("Run test with ulimit: " + (useDefaultUlimit ? "default" : "unlimited"));
  95         OutputAnalyzer output = useDefaultUlimit
  96             ? ProcessTools.executeProcess(pb)
  97             : ProcessTools.executeProcess("sh", "-c", "ulimit -c unlimited && "
  98                     + ProcessTools.getCommandLine(pb));
  99         File core;
 100         String pattern = Platform.isWindows() ? "mdmp" : "core";
 101         File[] cores = new File(".").listFiles((dir, name) -> name.contains(pattern));
 102         if (cores.length == 0) {
 103             // /cores/core.$pid might be generated on macosx by default
 104             String pid = output.firstMatch("^(\\d+)" + pidSeparator, 1);
 105             core = new File("cores/core." + pid);
 106             if (!core.exists()) {
 107                 throw new SkippedException("Has not been able to find coredump");
 108             }
 109         } else {
 110             Asserts.assertTrue(cores.length == 1,




  70             }
  71         }
  72         test(args[1]);
  73     }
  74 
  75     // Test tries to run java with ulimit unlimited if it is possible
  76     static boolean useDefaultUlimit() {
  77         if (Platform.isWindows()) {
  78             return true;
  79         }
  80         try {
  81             OutputAnalyzer output = ProcessTools.executeProcess("sh", "-c", "ulimit -c unlimited && ulimit -c");
  82             return !(output.getExitValue() == 0 && output.getStdout().contains("unlimited"));
  83         } catch (Throwable t) {
  84             return true;
  85         }
  86     }
  87 
  88     static void test(String type) throws Throwable {
  89         ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, "-XX:+CreateCoredumpOnCrash",
  90                 "-Xmx512m", "-XX:MaxMetaspaceSize=64m", "-XX:+CrashOnOutOfMemoryError",
  91                 TestJmapCore.class.getName(), type);
  92 
  93         boolean useDefaultUlimit = useDefaultUlimit();
  94         System.out.println("Run test with ulimit: " + (useDefaultUlimit ? "default" : "unlimited"));
  95         OutputAnalyzer output = useDefaultUlimit
  96             ? ProcessTools.executeProcess(pb)
  97             : ProcessTools.executeProcess("sh", "-c", "ulimit -c unlimited && "
  98                     + ProcessTools.getCommandLine(pb));
  99         File core;
 100         String pattern = Platform.isWindows() ? "mdmp" : "core";
 101         File[] cores = new File(".").listFiles((dir, name) -> name.contains(pattern));
 102         if (cores.length == 0) {
 103             // /cores/core.$pid might be generated on macosx by default
 104             String pid = output.firstMatch("^(\\d+)" + pidSeparator, 1);
 105             core = new File("cores/core." + pid);
 106             if (!core.exists()) {
 107                 throw new SkippedException("Has not been able to find coredump");
 108             }
 109         } else {
 110             Asserts.assertTrue(cores.length == 1,


< prev index next >