Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8179249

Improve process output analysis in CDS tests

    Details

    • Type: Enhancement
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 10
    • Fix Version/s: 11
    • Component/s: hotspot
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      b03

      Description

      Many CDS tests have the following pattern for analyzing the output of a JVM process.

          OutputAnalyzer out = TestCommon.execCommon("-cp", cp, mainClass, ....);
          out.shouldMatch(".*pattern");
          out.shouldHaveExitValue(0);

      However, due to Address Space Layout Randomization (ASLR), intermittently the launched JVM process may fail to map the archive. In that case, it's possible for the output to not match the given pattern, and thus the test would report a spurious failure.

      Many of the existing tests used this pattern to avoid the spurious failures (see http://hg.openjdk.java.net/jdk/hs/file/f43576cfb273/test/hotspot/jtreg/runtime/appcds/ClassPathAttr.java#l77 )

            output = TestCommon.execCommon("-Xlog:class+path", "-cp", cp, "CpAttr1");
            if (!TestCommon.isUnableToMap(output)){
              output.shouldMatch("checking shared classpath entry: .*cpattr2.jar");
              output.shouldMatch("checking shared classpath entry: .*cpattr3.jar");
            }

      However, in many cases in the past, we have forgotten to put the isUnableToMap check, and subsequently would have to fix the test.

      A better design this:

            TestCommon.run("-Xlog:class+path", "-cp", cp, "CpAttr1")
              .assertNormalExit(output -> {
                  output.shouldMatch("checking shared classpath entry: .*cpattr2.jar");
                  output.shouldMatch("checking shared classpath entry: .*cpattr3.jar");
                });

      here, the output.shouldMatch() code is provided in a Lambda expression. The assertNormalExit() method would invoke the Lambda expression only if no 'unable to map" error has happened.

        Attachments

          Activity

            People

            • Assignee:
              iklam Ioi Lam
              Reporter:
              iklam Ioi Lam
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: