[jdk8u-dev] RFR: 8305329: [8u] Unify test libraries into single test library - step 1
Zdenek Zambersky
zzambers at openjdk.org
Thu Mar 30 21:20:45 UTC 2023
I would like to start effort to unify test libraries in openjdk 8 into one unified library. This is first step of that effort, which moves newest copy of jdk test library (added with jfr backport) from `jdk/test/lib` to `test/lib`. For more details please continue reading.
**Problem:**
Test libraries in jdk8 are a bit messy.
There are currently 3 different test libraries:
- hotspot testlibrary - placed in [hotspot/test/testlibrary](https://github.com/openjdk/jdk8u-dev/tree/89aeae16e85ddfbd581cb86d0b0480b1e2d50e99/hotspot/test/testlibrary), (pkgs `com.oracle.java.testlibrary`, `sun.hotspot...` ), includes testlibrary tests in [hotspot/test/testlibrary_tests](https://github.com/openjdk/jdk8u-dev/tree/89aeae16e85ddfbd581cb86d0b0480b1e2d50e99/hotspot/test/testlibrary_tests)
- jdk testlibrary (old) - placed in [jdk/test/lib/testlibrary](https://github.com/openjdk/jdk8u-dev/tree/master/jdk/test/lib/testlibrary), (pkgs `jdk.testlibrary`, `com.oracle.testlibrary.jsr292`)
- jdk test lib - placed directly in [jdk/test/lib](https://github.com/openjdk/jdk8u-dev/tree/master/jdk/test/lib), was added with [jfr backport](https://github.com/openjdk/jdk8u-dev/commit/df7e09043392d5952d522a28702c6e5ec3e8492e), (pkgs `jdk.test.lib` `sun.hotspot...`)
Many test library classes exist in multiple different copies (using different pkgs). Few examples:
- Platform.java - 3 copies ([hs](https://github.com/openjdk/jdk8u-dev/blob/89aeae16e85ddfbd581cb86d0b0480b1e2d50e99/hotspot/test/testlibrary/com/oracle/java/testlibrary/Platform.java), [jdk (old)](https://github.com/openjdk/jdk8u-dev/blob/master/jdk/test/lib/testlibrary/jdk/testlibrary/Platform.java), [jdk (jfr)](https://github.com/openjdk/jdk8u-dev/blob/master/jdk/test/lib/jdk/test/lib/Platform.java))
- OutputAnalyzer.java - 3 copies ([hs](https://github.com/openjdk/jdk8u-dev/blob/89aeae16e85ddfbd581cb86d0b0480b1e2d50e99/hotspot/test/testlibrary/com/oracle/java/testlibrary/OutputAnalyzer.java), [jdk (old)](https://github.com/openjdk/jdk8u-dev/blob/master/jdk/test/lib/testlibrary/jdk/testlibrary/OutputAnalyzer.java), [jdk (jfr)](https://github.com/openjdk/jdk8u-dev/blob/master/jdk/test/lib/jdk/test/lib/process/OutputAnalyzer.java))
- WhiteBox.java - 2 copies ([hotspot](https://github.com/openjdk/jdk8u-dev/blob/89aeae16e85ddfbd581cb86d0b0480b1e2d50e99/hotspot/test/testlibrary/whitebox/sun/hotspot/WhiteBox.java), [jdk (jfr)](https://github.com/openjdk/jdk8u-dev/blob/master/jdk/test/lib/sun/hotspot/WhiteBox.java))
Few additional observations:
- classes in jdk test lib (jfr) use java packages compatible with newer jdks, other 2 don't (other 2 are actually not even compatible with each other)
- test lib added with jfr has newest classes, but some of them are NOT JDK8 compatible, some of them do not even compile on 8 (see e.g. [SecurityTools.java](https://github.com/openjdk/jdk8u-dev/blob/cd40350f0e69faf4d9a4658408798eb6e389f573/jdk/test/lib/jdk/test/lib/SecurityTools.java#L86), [InMemoryJavaCompiler.java](https://github.com/openjdk/jdk8u-dev/blob/cd40350f0e69faf4d9a4658408798eb6e389f573/jdk/test/lib/jdk/test/lib/compiler/InMemoryJavaCompiler.java#L146) ...) , some whitebox stuff in `sun.hotspot` also seem incompatible with 8 (e.g. [NMethod.java](https://github.com/openjdk/jdk8u-dev/blob/89aeae16e85ddfbd581cb86d0b0480b1e2d50e99/jdk/test/lib/sun/hotspot/code/NMethod.java#L37) (compare to [NMethod.java](https://github.com/openjdk/jdk8u-dev/blob/cd40350f0e69faf4d9a4658408798eb6e389f573/hotspot/test/testlibrary/whitebox/sun/hotspot/code/NMethod.java#L37) from hs))
- most jdk tests (with exception of jfr ones) use old testlibrary, but few tests already started using test lib added with jfr
- paths to test lib as specified `@library` jtreg tag is different from newer jdks (for all 3 test libraries)
This situation complicates backporting and leads to confusion. (What is correct library path? What package test lib classes use? Which library to use and to which one do backports? Which part are broken and why? etc...)
See some examples: https://github.com/openjdk/jdk8u-dev/pull/129 https://github.com/openjdk/jdk8u-dev/pull/255#issuecomment-1412522724
**Solution:**
Proposed solution is to have single test library placed in `test/lib` directory (+ test library tests in `test/lib-test`) by fixing/merging test libraries. (same locations are used in newer [jdks](https://github.com/openjdk/jdk17u-dev/tree/master/test/lib))
Goal is following:
- single test library, removed code duplication
- all test lib classes compatible with JDK8
- locations of test lib files and java packages (used by test library classes) same as in later jdks
- path as specified by `@library` jtreg tag compatible with later jdks (`@library /test/lib`)
- only test lib is moved. Tests and `TEST.ROOT` files are not moved, so this should not break existing CIs.
Because this is big change it should be performed in steps:
1. move jdk test library added by jfr to `test/lib` and do necessary modifications to tests (add `external.lib.roots` to `TEST.ROOT` files, modify `@library` tag of affected test)
2. Fix test lib in new location to work with hotspot tests (fix/merge with hotspot testlibrary), modify hotpot tests to use it, remove hotspot testlibrary
3. continue with jdk tests, doing more fixes to test lib, if necessary (fix/merge with jdk testlibrary), eventually migrating all tests and removing jdk testlibrary (old)
**Changes in this PR:**
This is just the first step and consist of:
- moved test lib classes `jdk/test/lib` -> `test/lib` (excluding `testlibrary`, `security` dirs belonging to the old jdk testlibrary)
- added appropriate `external.lib.roots` to `TEST.ROOT` files of jdk and hotspot
- modified affected tests to use moved library (just modifications of `@library`, with excpetion of `TestNative.sh`)
**Testing:**
tier1: passed (see Checks)
jdk_core: [OK](https://github.com/zzambers/jdk-tester/actions/runs/4481657956/jobs/8053572622) (basically jdk tier1+tier2,no regressions to [master](https://github.com/zzambers/jdk-tester/actions/runs/4481634969/jobs/7878603557))
jdk_jfr: [OK](https://github.com/zzambers/jdk-tester/actions/runs/4481322671/jobs/8053582402) (no regressions to [master](https://github.com/zzambers/jdk-tester/actions/runs/3997510473/jobs/6858945097))
-------------
Commit messages:
- Moved test lib
Changes: https://git.openjdk.org/jdk8u-dev/pull/294/files
Webrev: https://webrevs.openjdk.org/?repo=jdk8u-dev&pr=294&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8305329
Stats: 486 lines in 608 files changed: 8 ins; 12 del; 466 mod
Patch: https://git.openjdk.org/jdk8u-dev/pull/294.diff
Fetch: git fetch https://git.openjdk.org/jdk8u-dev.git pull/294/head:pull/294
PR: https://git.openjdk.org/jdk8u-dev/pull/294
More information about the jdk8u-dev
mailing list