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

Add support of using compiled test library

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: P3 P3
    • None
    • 25
    • hotspot
    • None

      ## Summary

      This project introduce ability to compile test libraries, add them into test image, and use these compiled jars during test execution and implicit compilation by jtreg.

      ## Motivation

      jtreg compiles uses test classes and test libraries implicilty by demand. This cause issues with dependencies and concurrent compilation
      [https://bugs.openjdk.org/browse/CODETOOLS-7902847][CODETOOLS-7902847 Class directory of a test case should not be used to compile a library]
      The another issues are:
      1. Compile on-demand is error-prone, the compile-time errors require all test runs to be found.
      2. It is not clear if testlibrary is always compiled with the same flags and same dependencies.
      3. Compile warnings are silently ignored.
      4. Potentially reduce execution time in CI.

      ## The proposed solution

      The jtreg should be extended to support additional property `precompiledJar` in LIBRARY.properties that shows path to jar for this library in `test-image`.
      Also, we need to add jtreg option --testimage that is the root for various test artifacts. The usage of test image might be extended in the future.

      Makefiles should be updated to build the testlibraries like native test libraries and update jtreg execution to set test image.
      So `make run-test TEST=` build/update testlibraries and use them while pure jtreg execution use existing mode.

      As additional bonuses we have:
      1. Ablity to easier develop tests with testlibrary. In the most of cases it could be run just with `java -cp testlib.jar Test.java` during development.
      2. Quick find of compile-time errors of test library code.
      3. Possibly faster excution, no need to re-scan and re-compile testlibrary thousands times.

      ## Jtreg behaviour proposed changes

      1. The jtreg should be modified to have ability to use classpaths for testlibrary.
      2. This jar should be used as a classpath instead of implicit compilation and in runtime.
      3. The jtreg should be backward compatible and compile testlibrary on-demand if jar is not available.
      4. The explicit @build should be able use testlibrary as a sourcepath as it do now. However, need to clean if this is needed in long-term.


      ## The possible future improvements

      The jtreg `test-image` might be used a single point for all test artifacts. So user just point the test image root and all artifacts in the image
      are set via proprties in testsuite. It might be testlibrary, native linraries, pre-built test classes and other.

      The next step would be:
      1. Check how many tests in hotspot and jdk testsuite don't require special build setting and might be compiled during build.
      2. Add test.native.dir in the testsuite so no need to configure it using separate parameter.
      3. Add support of using CDS/AOT binaries from test image.

      ## Potential issues

      The difference between new behaviour and the existing `compile-on-demand` behavior looks like the main problem.
      It might be makes sense to don't allow compile-on-demand for the libraries that might be compiled.

      ## Possible alternatives

      It might makes sense to have jar-only as a testlibrary and don't be able to execute these tests without test images.
      So looks like
      @library <path>/testlibrary.jar
      or
      don't support compile on demand for testlibrary with `precompiledJar` in LIBRARY.properties.

      jdk poc changes: https://github.com/openjdk/jdk/compare/master...lmesnik:jdk:test-lib?expand=1
      (TBD add dependency of test-image on build-test-lib)
      jtreg poc changes: https://github.com/openjdk/jtreg/compare/master...lmesnik:jtreg:lib?expand=1


            lmesnik Leonid Mesnik
            lmesnik Leonid Mesnik
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: