RFR: CODETOOLS-7903223: Enable no-display-required parts of Basic tests in HEADLESS mode

Jonathan Gibbons jjg at openjdk.org
Fri Jul 1 05:47:21 UTC 2022


Please review a mostly-test-only fix to run more tests when running in HEADLESS mode, such as in GitHub Actions.

4 jtreg self-tests, including the important `Basic` tests, involve test suites with `@run applet` tests. These tests fail on a headless system, and were previously disabled on such systems by using `ifndef HEADLESS` to exclude the tests from execution. But these tests exercise more than just applet functionality, and excluding the entire test is too drastic a solution.

The change is to always enable these tests, modifying their behavior to avoid using the parts of the test that use `@run applet`.

The changes fall into 5 groups:

1. `Agent.java` ... if the `java.awt.headless` property is set in jtreg, it is propagated to any agents that are started. This is primarily for testing/debugging. The property does not normally need to be set, even on a headless system.

2. The `Basic` tests ... a new keyword is added to those tests in the `basic` suite that should not be run in headless mode, which is determined automatically by calling `GraphicsEnvironment.isHeadless()`.  The expected  number of tests in different categories is adjusted accordingly.  Note that bad/malformed tests using `@run applet` are not affected, because they result in an `Error` result and the action is never invoked.

3. `ReportOnlyTest` ... this is a follow-up to the `Basic` tests, to verify the test counts are reported accurately in report-only mode. If HEADLESS is set, the expected numbers of passed and failed tests are adjusted.

4. `EnvTests` ... as with the `Basic` tests, a new keyword is added to applet tests, so that if HEADLESS is set, the applet tests are not executed. The tests are also modified to use JDK 8 and 9 as older versions, instead of JDK 6 and 7.

5. `Rerun tests` ... similar to the preceding cases. If HEADLESS is set, the applet tests are not executed, the expected number of tests is modified, and the applet tests are ignored when checking the rerun info.

## Testing

Locally, the modifications are tested by a combination of setting `-Djava.awt.headless=true` for the `Basic` tests and `HEADLESS` for the other tests.

More notably, the `Basic` and `ReportOnlyTest` tests are seen to be executed, and pass, in the Github Actions for the repo.

-------------

Commit messages:
 - CODETOOLS-7903223: Enable no-display-required parts of Basic tests in HEADLESS mode

Changes: https://git.openjdk.org/jtreg/pull/92/files
 Webrev: https://webrevs.openjdk.org/?repo=jtreg&pr=92&range=00
  Issue: https://bugs.openjdk.org/browse/CODETOOLS-7903223
  Stats: 118 lines in 18 files changed: 82 ins; 14 del; 22 mod
  Patch: https://git.openjdk.org/jtreg/pull/92.diff
  Fetch: git fetch https://git.openjdk.org/jtreg pull/92/head:pull/92

PR: https://git.openjdk.org/jtreg/pull/92


More information about the jtreg-dev mailing list