Java Code Examples for jdk.test.lib.process.OutputAnalyzer#firstMatch()

The following examples show how to use jdk.test.lib.process.OutputAnalyzer#firstMatch() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestLargePagesFlags.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public void expect(Flag... expectedFlags) throws Exception {
  if (useFlags == null) {
    throw new IllegalStateException("Must run use() before expect()");
  }

  OutputAnalyzer output = executeNewJVM(useFlags);

  for (Flag flag : expectedFlags) {
    System.out.println("Looking for: " + flag.flagString());
    String strValue = output.firstMatch(".* " + flag.name() +  " .* :?= (\\S+).*", 1);

    if (strValue == null) {
      throw new RuntimeException("Flag " + flag.name() + " couldn't be found");
    }

    if (!flag.value().equals(strValue)) {
      throw new RuntimeException("Wrong value for: " + flag.name()
                                 + " expected: " + flag.value()
                                 + " got: " + strValue);
    }
  }

  output.shouldHaveExitValue(0);
}
 
Example 2
Source File: SetVMFlagTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private void setImmutableFlag(CommandExecutor executor) {
    OutputAnalyzer out = getAllFlags(executor);
    String flagName = out.firstMatch(IMMUTABLE_PATTERN, 1);
    String flagVal = out.firstMatch(IMMUTABLE_PATTERN, 2);

    System.out.println("### Setting an immutable flag '" + flagName + "'");

    if (flagVal == null) {
        System.err.println(out.getOutput());
        throw new Error("Can not find an immutable uintx flag");
    }

    Long numVal = Long.parseLong(flagVal);

    out = executor.execute("VM.set_flag " + flagName + " " + (numVal + 1));
    out.stderrShouldBeEmpty();
    out.stdoutShouldContain("only 'writeable' flags can be set");

    out = getAllFlags(executor);

    String newFlagVal = out.firstMatch(IMMUTABLE_PATTERN.replace("(\\S+)", flagName), 1);

    assertEquals(newFlagVal, flagVal);
}
 
Example 3
Source File: SetVMFlagTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private void setMutableFlagWithInvalidValue(CommandExecutor executor) {
    OutputAnalyzer out = getAllFlags(executor);
    String flagName = out.firstMatch(MANAGEABLE_PATTERN, 1);
    String flagVal = out.firstMatch(MANAGEABLE_PATTERN, 2);

    System.out.println("### Setting a mutable flag '" + flagName + "' to an invalid value");

    if (flagVal == null) {
        System.err.println(out.getOutput());
        throw new Error("Can not find a boolean manageable flag");
    }

    // a boolean flag accepts only 0/1 as its value
    out = executor.execute("VM.set_flag " + flagName + " unexpected_value");
    out.stderrShouldBeEmpty();
    out.stdoutShouldContain("flag value must be a boolean (1/0 or true/false)");

    out = getAllFlags(executor);

    String newFlagVal = out.firstMatch(MANAGEABLE_PATTERN.replace("(\\S+)", flagName), 1);

    assertEquals(newFlagVal, flagVal);
}
 
Example 4
Source File: SetVMFlagTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private void setMutableFlag(CommandExecutor executor) {
    OutputAnalyzer out = getAllFlags(executor);
    String flagName = out.firstMatch(MANAGEABLE_PATTERN, 1);
    String flagVal = out.firstMatch(MANAGEABLE_PATTERN, 2);

    System.out.println("### Setting a mutable flag '" + flagName + "'");

    if (flagVal == null) {
        System.err.println(out.getOutput());
        throw new Error("Can not find a boolean manageable flag");
    }

    Boolean blnVal = Boolean.parseBoolean(flagVal);
    setMutableFlagInternal(executor, flagName, !blnVal, true);
    setMutableFlagInternal(executor, flagName, blnVal, false);
}
 
Example 5
Source File: SetVMFlagTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private void setMutableFlagInternal(CommandExecutor executor, String flag,
                                    boolean val, boolean isNumeric) {
    String strFlagVal;
    if (isNumeric) {
        strFlagVal = val ? "1" : "0";
    } else {
        strFlagVal = val ? "true" : "false";
    }

    OutputAnalyzer out = executor.execute("VM.set_flag " + flag + " " + strFlagVal);
    out.stderrShouldBeEmpty();

    out = getAllFlags(executor);

    String newFlagVal = out.firstMatch(MANAGEABLE_PATTERN.replace("(\\S+)", flag), 1);

    assertNotEquals(newFlagVal, val ? "1" : "0");
}
 
Example 6
Source File: TestParallelGCThreads.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public static void testDefaultValue()  throws Exception {
  ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
    "-XX:+UnlockExperimentalVMOptions", "-XX:+PrintFlagsFinal", "-version");

  OutputAnalyzer output = new OutputAnalyzer(pb.start());
  String value = output.firstMatch(printFlagsFinalPattern, 1);

  try {
    Asserts.assertNotNull(value, "Couldn't find uint flag " + flagName);

    Long longValue = new Long(value);

    // Sanity check that we got a non-zero value.
    Asserts.assertNotEquals(longValue, "0");

    output.shouldHaveExitValue(0);
  } catch (Exception e) {
    System.err.println(output.getOutput());
    throw e;
  }
}
 
Example 7
Source File: TestArrayAllocatorMallocLimit.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public static void testDefaultValue()  throws Exception {
  ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
    "-XX:+UnlockExperimentalVMOptions", "-XX:+PrintFlagsFinal", "-version");

  OutputAnalyzer output = new OutputAnalyzer(pb.start());
  String value = output.firstMatch(printFlagsFinalPattern, 1);

  try {
    Asserts.assertNotNull(value, "Couldn't find size_t flag " + flagName);

    // A size_t is not always parseable with Long.parseValue,
    // use BigInteger instead.
    BigInteger biValue = new BigInteger(value);

    // Sanity check that we got a non-zero value.
    Asserts.assertNotEquals(biValue, "0");

    output.shouldHaveExitValue(0);
  } catch (Exception e) {
    System.err.println(output.getOutput());
    throw e;
  }
}
 
Example 8
Source File: TestArrayAllocatorMallocLimit.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public static void testSetValue() throws Exception {
  long flagValue = 2048;

  ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
    "-XX:+UnlockExperimentalVMOptions", "-XX:" + flagName + "=" + flagValue, "-XX:+PrintFlagsFinal", "-version");

  OutputAnalyzer output = new OutputAnalyzer(pb.start());
  String value = output.firstMatch(printFlagsFinalPattern, 1);

  try {
    Asserts.assertNotNull("Couldn't find size_t flag " + flagName);

    long longValue = Long.parseLong(value);

    Asserts.assertEquals(longValue, flagValue);

    output.shouldHaveExitValue(0);
  } catch (Exception e) {
    System.err.println(output.getOutput());
    throw e;
  }
}
 
Example 9
Source File: TestShutdownEvent.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private static void runSubtest(int subTestIndex) throws Exception {
    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true,
                            "-XX:+LogJFR",
                            "-XX:-CreateMinidumpOnCrash",
                            "-XX:StartFlightRecording=filename=./dumped.jfr,dumponexit=true,settings=default",
                            "jdk.jfr.event.runtime.TestShutdownEvent$TestMain",
                            String.valueOf(subTestIndex));
    OutputAnalyzer output = ProcessTools.executeProcess(pb);
    System.out.println(output.getOutput());
    int exitCode = output.getExitValue();
    System.out.println("Exit code: " + exitCode);

    String recordingName = output.firstMatch("emergency jfr file: (.*.jfr)", 1);
    if (recordingName == null) {
        recordingName = "./dumped.jfr";
    }

    List<RecordedEvent> events = RecordingFile.readAllEvents(Paths.get(recordingName));
    List<RecordedEvent> filteredEvents = events.stream()
        .filter(e -> e.getEventType().getName().equals(EventNames.Shutdown))
        .sorted(Comparator.comparing(RecordedEvent::getStartTime))
        .collect(Collectors.toList());

    Asserts.assertEquals(filteredEvents.size(), 1);
    RecordedEvent event = filteredEvents.get(0);
    subTests[subTestIndex].verifyEvents(event, exitCode);
}
 
Example 10
Source File: TestAggressiveHeap.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private static void testFlag() throws Exception {
    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
        option, "-XX:+PrintFlagsFinal", "-version");

    OutputAnalyzer output = new OutputAnalyzer(pb.start());

    output.shouldHaveExitValue(0);

    String value = output.firstMatch(parallelGCPattern);
    if (value == null) {
        throw new RuntimeException(
            option + " didn't set UseParallelGC as if from command line");
    }
}
 
Example 11
Source File: TestMetaspaceSizeFlags.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private static MetaspaceFlags runAndGetValue(long maxMetaspaceSize, long metaspaceSize) throws Exception {
  OutputAnalyzer output = run(maxMetaspaceSize, metaspaceSize);
  output.shouldNotMatch("Error occurred during initialization of VM\n.*");

  String stringMaxMetaspaceSize = output.firstMatch(".* MaxMetaspaceSize .* = (\\d+).*", 1);
  String stringMetaspaceSize = output.firstMatch(".* MetaspaceSize .* = (\\d+).*", 1);

  return new MetaspaceFlags(Long.parseLong(stringMaxMetaspaceSize),
                            Long.parseLong(stringMetaspaceSize));
}
 
Example 12
Source File: TestLargePageUseForAuxMemory.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
static void checkSize(OutputAnalyzer output, long expectedSize, String pattern) {
    String pageSizeStr = output.firstMatch(pattern, 1);

    if (pageSizeStr == null) {
        output.reportDiagnosticSummary();
        throw new RuntimeException("Match from '" + pattern + "' got 'null' expected: " + expectedSize);
    }

    long size = parseMemoryString(pageSizeStr);
    if (size != expectedSize) {
        output.reportDiagnosticSummary();
        throw new RuntimeException("Match from '" + pattern + "' got " + size + " expected: " + expectedSize);
    }
}
 
Example 13
Source File: TestHumongousCodeCacheRoots.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Executes a class in a new VM process with the given parameters.
 * @param vmargs Arguments to the VM to run
 * @param classname Name of the class to run
 * @param arguments Arguments to the class
 * @param useTestDotJavaDotOpts Use test.java.opts as part of the VM argument string
 * @return The OutputAnalyzer with the results for the invocation.
 */
public static OutputAnalyzer runWhiteBoxTest(String[] vmargs, String classname, String[] arguments, boolean useTestDotJavaDotOpts) throws Exception {
  ArrayList<String> finalargs = new ArrayList<String>();

  String[] whiteboxOpts = new String[] {
    "-Xbootclasspath/a:.",
    "-XX:+UnlockDiagnosticVMOptions", "-XX:+WhiteBoxAPI",
    "-cp", System.getProperty("java.class.path"),
  };

  if (useTestDotJavaDotOpts) {
    // System.getProperty("test.java.opts") is '' if no options is set,
    // we need to skip such a result
    String[] externalVMOpts = new String[0];
    if (System.getProperty("test.java.opts") != null && System.getProperty("test.java.opts").length() != 0) {
      externalVMOpts = System.getProperty("test.java.opts").split(" ");
    }
    finalargs.addAll(Arrays.asList(externalVMOpts));
  }

  finalargs.addAll(Arrays.asList(vmargs));
  finalargs.addAll(Arrays.asList(whiteboxOpts));
  finalargs.add(classname);
  finalargs.addAll(Arrays.asList(arguments));

  ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(finalargs.toArray(new String[0]));
  OutputAnalyzer output = new OutputAnalyzer(pb.start());
  try {
      output.shouldHaveExitValue(0);
  } catch (RuntimeException e) {
      // It's ok if there is no client vm in the jdk.
      if (output.firstMatch("Unrecognized option: -client") == null) {
          throw e;
      }
  }

  return output;
}
 
Example 14
Source File: TestShutdownEvent.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private static void runSubtest(int subTestIndex) throws Exception {
    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true,
                            "-XX:+LogJFR",
                            "-XX:-CreateMinidumpOnCrash",
                            "-XX:StartFlightRecording=filename=./dumped.jfr,dumponexit=true,settings=default",
                            "jdk.jfr.event.runtime.TestShutdownEvent$TestMain",
                            String.valueOf(subTestIndex));
    OutputAnalyzer output = ProcessTools.executeProcess(pb);
    System.out.println(output.getOutput());
    int exitCode = output.getExitValue();
    System.out.println("Exit code: " + exitCode);

    String recordingName = output.firstMatch("emergency jfr file: (.*.jfr)", 1);
    if (recordingName == null) {
        recordingName = "./dumped.jfr";
    }

    List<RecordedEvent> events = RecordingFile.readAllEvents(Paths.get(recordingName));
    List<RecordedEvent> filteredEvents = events.stream()
        .filter(e -> e.getEventType().getName().equals(EventNames.Shutdown))
        .sorted(Comparator.comparing(RecordedEvent::getStartTime))
        .collect(Collectors.toList());

    Asserts.assertEquals(filteredEvents.size(), 1);
    RecordedEvent event = filteredEvents.get(0);
    subTests[subTestIndex].verifyEvents(event, exitCode);
}
 
Example 15
Source File: TestDumpOnCrash.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private static Path getHsErrJfrPath(OutputAnalyzer output) throws Exception {
    // extract to find hs-err_pid log file location
    final String hs_err_pid_log_file = output.firstMatch("# *(\\S*hs_err_pid\\d+\\.log)", 1);
    if (hs_err_pid_log_file == null) {
        throw new RuntimeException("Did not find hs_err_pid.log file in output.\n");
    }
    // the dumped out jfr file should have the same name and location but with a .jfr extension
    final String hs_err_pid_jfr_file = hs_err_pid_log_file.replace(LOG_FILE_EXTENSION, JFR_FILE_EXTENSION);
    return Paths.get(hs_err_pid_jfr_file);
}
 
Example 16
Source File: TestDumpOnCrash.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private static Path getHsErrJfrPath(OutputAnalyzer output) throws Exception {
    // extract to find hs-err_pid log file location
    final String hs_err_pid_log_file = output.firstMatch("# *(\\S*hs_err_pid\\d+\\.log)", 1);
    if (hs_err_pid_log_file == null) {
        throw new RuntimeException("Did not find hs_err_pid.log file in output.\n");
    }
    // the dumped out jfr file should have the same name and location but with a .jfr extension
    final String hs_err_pid_jfr_file = hs_err_pid_log_file.replace(LOG_FILE_EXTENSION, JFR_FILE_EXTENSION);
    return Paths.get(hs_err_pid_jfr_file);
}
 
Example 17
Source File: SafeFetchInErrorHandlingTest.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {

    if (!Platform.isDebugBuild() || Platform.isZero()) {
      return;
    }

    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
        "-XX:+UnlockDiagnosticVMOptions",
        "-Xmx100M",
        "-XX:ErrorHandlerTest=14",
        "-XX:+TestSafeFetchInErrorHandler",
        "-XX:-CreateCoredumpOnCrash",
        "-version");

    OutputAnalyzer output_detail = new OutputAnalyzer(pb.start());

    // we should have crashed with a SIGSEGV
    output_detail.shouldMatch("# A fatal error has been detected by the Java Runtime Environment:.*");
    output_detail.shouldMatch("# +(?:SIGSEGV|EXCEPTION_ACCESS_VIOLATION).*");

    // extract hs-err file
    String hs_err_file = output_detail.firstMatch("# *(\\S*hs_err_pid\\d+\\.log)", 1);
    if (hs_err_file == null) {
      throw new RuntimeException("Did not find hs-err file in output.\n");
    }

    File f = new File(hs_err_file);
    if (!f.exists()) {
      throw new RuntimeException("hs-err file missing at "
          + f.getAbsolutePath() + ".\n");
    }

    System.out.println("Found hs_err file. Scanning...");

    FileInputStream fis = new FileInputStream(f);
    BufferedReader br = new BufferedReader(new InputStreamReader(fis));
    String line = null;

    Pattern [] pattern = new Pattern[] {
        Pattern.compile("Will test SafeFetch..."),
        Pattern.compile("SafeFetch OK."),
    };
    int currentPattern = 0;

    String lastLine = null;
    while ((line = br.readLine()) != null) {
      if (currentPattern < pattern.length) {
        if (pattern[currentPattern].matcher(line).matches()) {
          System.out.println("Found: " + line + ".");
          currentPattern ++;
        }
      }
      lastLine = line;
    }
    br.close();

    if (currentPattern < pattern.length) {
      throw new RuntimeException("hs-err file incomplete (first missing pattern: " +  currentPattern + ")");
    }

    if (!lastLine.equals("END.")) {
      throw new RuntimeException("hs-err file incomplete (missing END marker.)");
    } else {
      System.out.println("End marker found.");
    }

    System.out.println("OK.");

  }
 
Example 18
Source File: TestCrashOnOutOfMemoryError.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
    if (args.length == 1) {
        // This should guarantee to throw:
        // java.lang.OutOfMemoryError: Requested array size exceeds VM limit
        try {
            Object[] oa = new Object[Integer.MAX_VALUE];
            throw new Error("OOME not triggered");
        } catch (OutOfMemoryError err) {
            throw new Error("OOME didn't abort JVM!");
        }
    }
    // else this is the main test
    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+CrashOnOutOfMemoryError",
             "-XX:-CreateCoredumpOnCrash", "-Xmx64m", TestCrashOnOutOfMemoryError.class.getName(),"throwOOME");
    OutputAnalyzer output = new OutputAnalyzer(pb.start());
    int exitValue = output.getExitValue();
    if (0 == exitValue) {
        //expecting a non zero value
        throw new Error("Expected to get non zero exit value");
    }

    /* Output should look something like this. The actual text will depend on the OS and its core dump processing.
       Aborting due to java.lang.OutOfMemoryError: Requested array size exceeds VM limit
       # To suppress the following error report, specify this argument
       # after -XX: or in .hotspotrc:  SuppressErrorAt=/debug.cpp:303
       #
       # A fatal error has been detected by the Java Runtime Environment:
       #
       #  Internal Error (/home/cheleswer/Desktop/jdk9/dev/hotspot/src/share/vm/utilities/debug.cpp:303), pid=6212, tid=6213
       #  fatal error: OutOfMemory encountered: Requested array size exceeds VM limit
       #
       # JRE version: OpenJDK Runtime Environment (9.0) (build 1.9.0-internal-debug-cheleswer_2015_10_20_14_32-b00)
       # Java VM: OpenJDK 64-Bit Server VM (1.9.0-internal-debug-cheleswer_2015_10_20_14_32-b00, mixed mode, tiered, compressed oops, serial gc, linux-amd64)
       # Core dump will be written. Default location: Core dumps may be processed with "/usr/share/apport/apport %p %s %c %P" (or dumping to
         /home/cheleswer/Desktop/core.6212)
       #
       # An error report file with more information is saved as:
       # /home/cheleswer/Desktop/hs_err_pid6212.log
       #
       # If you would like to submit a bug report, please visit:
       #   http://bugreport.java.com/bugreport/crash.jsp
       #
       Current thread is 6213
       Dumping core ...
       Aborted (core dumped)
    */
    output.shouldContain("Aborting due to java.lang.OutOfMemoryError: Requested array size exceeds VM limit");
    // extract hs-err file
    String hs_err_file = output.firstMatch("# *(\\S*hs_err_pid\\d+\\.log)", 1);
    if (hs_err_file == null) {
        throw new Error("Did not find hs-err file in output.\n");
    }

    /*
     * Check if hs_err files exist or not
     */
    File f = new File(hs_err_file);
    if (!f.exists()) {
        throw new Error("hs-err file missing at "+ f.getAbsolutePath() + ".\n");
    }

    /*
     * Checking the completness of hs_err file. If last line of hs_err file is "END"
     * then it proves that file is complete.
     */
    try (FileInputStream fis = new FileInputStream(f);
        BufferedReader br = new BufferedReader(new InputStreamReader(fis))) {
        String line = null;
        String lastLine = null;
        while ((line = br.readLine()) != null) {
            lastLine = line;
        }
        if (!lastLine.equals("END.")) {
            throw new Error("hs-err file incomplete (missing END marker.)");
        } else {
            System.out.println("End marker found.");
        }
    }
    System.out.println("PASSED");
}
 
Example 19
Source File: SecondaryErrorTest.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {

    // Do not execute for windows, nor for non-debug builds
    if (Platform.isWindows()) {
      return;
    }

    if (!Platform.isDebugBuild()) {
      return;
    }

    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
        "-XX:+UnlockDiagnosticVMOptions",
        "-Xmx100M",
        "-XX:-CreateCoredumpOnCrash",
        "-XX:ErrorHandlerTest=15",
        "-XX:TestCrashInErrorHandler=14",
        "-version");

    OutputAnalyzer output_detail = new OutputAnalyzer(pb.start());

    // we should have crashed with a SIGFPE
    output_detail.shouldMatch("# A fatal error has been detected by the Java Runtime Environment:.*");
    output_detail.shouldMatch("# +SIGFPE.*");

    // extract hs-err file
    String hs_err_file = output_detail.firstMatch("# *(\\S*hs_err_pid\\d+\\.log)", 1);
    if (hs_err_file == null) {
      throw new RuntimeException("Did not find hs-err file in output.\n");
    }

    // scan hs-err file: File should contain the "[error occurred during error reporting..]"
    // markers which show that the secondary error handling kicked in and handled the
    // error successfully. As an added test, we check that the last line contains "END.",
    // which is an end marker written in the last step and proves that hs-err file was
    // completely written.
    File f = new File(hs_err_file);
    if (!f.exists()) {
      throw new RuntimeException("hs-err file missing at "
          + f.getAbsolutePath() + ".\n");
    }

    System.out.println("Found hs_err file. Scanning...");

    FileInputStream fis = new FileInputStream(f);
    BufferedReader br = new BufferedReader(new InputStreamReader(fis));
    String line = null;

    Pattern [] pattern = new Pattern[] {
        Pattern.compile("Will crash now \\(TestCrashInErrorHandler=14\\)..."),
        Pattern.compile("\\[error occurred during error reporting \\(test secondary crash 1\\).*\\]"),
        Pattern.compile("Will crash now \\(TestCrashInErrorHandler=14\\)..."),
        Pattern.compile("\\[error occurred during error reporting \\(test secondary crash 2\\).*\\]"),
    };
    int currentPattern = 0;

    String lastLine = null;
    while ((line = br.readLine()) != null) {
      if (currentPattern < pattern.length) {
        if (pattern[currentPattern].matcher(line).matches()) {
          System.out.println("Found: " + line + ".");
          currentPattern ++;
        }
      }
      lastLine = line;
    }
    br.close();

    if (currentPattern < pattern.length) {
      throw new RuntimeException("hs-err file incomplete (first missing pattern: " +  currentPattern + ")");
    }

    if (!lastLine.equals("END.")) {
      throw new RuntimeException("hs-err file incomplete (missing END marker.)");
    } else {
      System.out.println("End marker found.");
    }

    System.out.println("OK.");

  }