From 7e81bd36dd1b544c88b03bd687d9afbef739b01e Mon Sep 17 00:00:00 2001 From: Christoph Langer Date: Sun, 11 Dec 2022 18:28:45 +0100 Subject: [PATCH] Backport 57e6d92a6ddbfe78cbf250a4502ce0911ee6f75a --- doc/building.html | 83 ++++++++++++++++++++++++------------------ doc/building.md | 44 +++++++++++----------- doc/testing.html | 16 ++++---- make/autoconf/basic.m4 | 14 ++++++- 4 files changed, 90 insertions(+), 67 deletions(-) diff --git a/doc/building.html b/doc/building.html index 7d6f18cd65d..79596224748 100644 --- a/doc/building.html +++ b/doc/building.html @@ -1,19 +1,24 @@ - + - - - + + + Building the JDK - - + + -
+

Building the JDK

Using the run-test framework

This new way of running tests is developer-centric. It assumes that you have built a JDK locally and want to test it. Running common test targets is simple, and more complex ad-hoc combination of tests is possible. The user interface is forgiving, and clearly report errors it cannot resolve.

-

The main target “run-test” uses the jdk-image as the tested product. There is also an alternate target “exploded-run-test” that uses the exploded image instead. Not all tests will run successfully on the exploded image, but using this target can greatly improve rebuild times for certain workflows.

+

The main target "run-test" uses the jdk-image as the tested product. There is also an alternate target "exploded-run-test" that uses the exploded image instead. Not all tests will run successfully on the exploded image, but using this target can greatly improve rebuild times for certain workflows.

Some example command-lines:

$ make run-test-tier1
 $ make run-test-jdk_lang JTREG="JOBS=8"
@@ -55,7 +55,7 @@ 

Using the run-test framework

$ make run-test TEST="jtreg:test/hotspot:hotspot_gc test/hotspot/jtreg/native_sanity/JniVersion.java" $ make exploded-run-test TEST=tier2

Configuration

-

To be able to run JTReg tests, configure needs to know where to find the JTReg test framework. If it is not picked up automatically by configure, use the --with-jtreg=<path to jtreg home> option to point to the JTReg framework. Note that this option should point to the JTReg home, i.e. the top directory, containing lib/jtreg.jar etc. (An alternative is to set the JT_HOME environment variable to point to the JTReg home before running configure.)

+

To be able to run JTReg tests, configure needs to know where to find the JTReg test framework. If it is not picked up automatically by configure, use the --with-jtreg=<path to jtreg home> option to point to the JTReg framework. Note that this option should point to the JTReg home, i.e. the top directory, containing lib/jtreg.jar etc. (An alternative is to set the JT_HOME environment variable to point to the JTReg home before running configure.)

Test selection

All functionality is available using the run-test make target. In this use case, the test or tests to be executed is controlled using the TEST variable. To speed up subsequent test runs with no source code changes, run-test-only can be used instead, which do not depend on the source and test image build.

For some common top-level tests, direct make targets have been generated. This includes all JTReg test groups, the hotspot gtest, and custom tests (if present). This means that make run-test-tier1 is equivalent to make run-test TEST="tier1", but the latter is more tab-completion friendly. For more complex test runs, the run-test TEST="x" solution needs to be used.

@@ -82,7 +82,7 @@

JTReg

Gtest

Since the Hotspot Gtest suite is so quick, the default is to run all tests. This is specified by just gtest, or as a fully qualified test descriptor gtest:all.

If you want, you can single out an individual test or a group of tests, for instance gtest:LogDecorations or gtest:LogDecorations.level_test_vm. This can be particularly useful if you want to run a shaky test repeatedly.

-

For Gtest, there is a separate test suite for each JVM variant. The JVM variant is defined by adding /<variant> to the test descriptor, e.g. gtest:Log/client. If you specify no variant, gtest will run once for each JVM variant present (e.g. server, client). So if you only have the server JVM present, then gtest:all will be equivalent to gtest:all/server.

+

For Gtest, there is a separate test suite for each JVM variant. The JVM variant is defined by adding /<variant> to the test descriptor, e.g. gtest:Log/client. If you specify no variant, gtest will run once for each JVM variant present (e.g. server, client). So if you only have the server JVM present, then gtest:all will be equivalent to gtest:all/server.

Test results and summary

At the end of the test run, a summary of all tests run will be presented. This will have a consistent look, regardless of what test suites were used. This is a sample summary:

==============================
@@ -97,16 +97,16 @@ 

Test results and summary

Tests where the number of TOTAL tests does not equal the number of PASSed tests will be considered a test failure. These are marked with the >> ... << marker for easy identification.

The classification of non-passed tests differs a bit between test suites. In the summary, ERROR is used as a catch-all for tests that neither passed nor are classified as failed by the framework. This might indicate test framework error, timeout or other problems.

In case of test failures, make run-test will exit with a non-zero exit value.

-

All tests have their result stored in build/$BUILD/test-results/$TEST_ID, where TEST_ID is a path-safe conversion from the fully qualified test descriptor, e.g. for jtreg:jdk/test:tier1 the TEST_ID is jtreg_jdk_test_tier1. This path is also printed in the log at the end of the test run.

+

All tests have their result stored in build/$BUILD/test-results/$TEST_ID, where TEST_ID is a path-safe conversion from the fully qualified test descriptor, e.g. for jtreg:jdk/test:tier1 the TEST_ID is jtreg_jdk_test_tier1. This path is also printed in the log at the end of the test run.

Additional work data is stored in build/$BUILD/test-support/$TEST_ID. For some frameworks, this directory might contain information that is useful in determining the cause of a failed test.

Test suite control

It is possible to control various aspects of the test suites using make control variables.

These variables use a keyword=value approach to allow multiple values to be set. So, for instance, JTREG="JOBS=1;TIMEOUT=8" will set the JTReg concurrency level to 1 and the timeout factor to 8. This is equivalent to setting JTREG_JOBS=1 JTREG_TIMEOUT=8, but using the keyword format means that the JTREG variable is parsed and verified for correctness, so JTREG="TMIEOUT=8" would give an error, while JTREG_TMIEOUT=8 would just pass unnoticed.

To separate multiple keyword=value pairs, use ; (semicolon). Since the shell normally eats ;, the recommended usage is to write the assignment inside qoutes, e.g. JTREG="...;...". This will also make sure spaces are preserved, as in JTREG="VM_OPTIONS=-XshowSettings -Xlog:gc+ref=debug".

-

(Other ways are possible, e.g. using backslash: JTREG=JOBS=1\;TIMEOUT=8. Also, as a special technique, the string %20 will be replaced with space for certain options, e.g. JTREG=VM_OPTIONS=-XshowSettings%20-Xlog:gc+ref=debug. This can be useful if you have layers of scripts and have trouble getting proper quoting of command line arguments through.)

+

(Other ways are possible, e.g. using backslash: JTREG=JOBS=1\;TIMEOUT=8. Also, as a special technique, the string %20 will be replaced with space for certain options, e.g. JTREG=VM_OPTIONS=-XshowSettings%20-Xlog:gc+ref=debug. This can be useful if you have layers of scripts and have trouble getting proper quoting of command line arguments through.)

As far as possible, the names of the keywords have been standardized between test suites.

General keywords (TEST_OPTS)

-

Some keywords are valid across different test suites. If you want to run tests from multiple test suites, or just don’t want to care which test suite specific control variable to use, then you can use the general TEST_OPTS control variable.

+

Some keywords are valid across different test suites. If you want to run tests from multiple test suites, or just don't want to care which test suite specific control variable to use, then you can use the general TEST_OPTS control variable.

There are also some keywords that applies globally to the test runner system, not to any specific test suites. These are also available as TEST_OPTS keywords.

JOBS

Currently only applies to JTReg.

@@ -179,11 +179,11 @@

Client UI Tests

Some Client UI tests use key sequences which may be reserved by the operating system. Usually that causes the test failure. So it is highly recommended to disable system key shortcuts prior testing. The steps to access and disable system key shortcuts for various platforms are provided below.

MacOS

Choose Apple menu; System Preferences, click Keyboard, then click Shortcuts; select or deselect desired shortcut.

-

For example, test/jdk/javax/swing/TooltipManager/JMenuItemToolTipKeyBindingsTest/JMenuItemToolTipKeyBindingsTest.java fails on MacOS because it uses CTRL + F1 key sequence to show or hide tooltip message but the key combination is reserved by the operating system. To run the test correctly the default global key shortcut should be disabled using the steps described above, and then deselect “Turn keyboard access on or off” option which is responsible for CTRL + F1 combination.

+

For example, test/jdk/javax/swing/TooltipManager/JMenuItemToolTipKeyBindingsTest/JMenuItemToolTipKeyBindingsTest.java fails on MacOS because it uses CTRL + F1 key sequence to show or hide tooltip message but the key combination is reserved by the operating system. To run the test correctly the default global key shortcut should be disabled using the steps described above, and then deselect "Turn keyboard access on or off" option which is responsible for CTRL + F1 combination.

Linux

Open the Activities overview and start typing Settings; Choose Settings, click Devices, then click Keyboard; set or override desired shortcut.

Windows

-

Type gpedit in the Search and then click Edit group policy; navigate to User Configuration -> Administrative Templates -> Windows Components -> File Explorer; in the right-side pane look for “Turn off Windows key hotkeys” and double click on it; enable or disable hotkeys.

+

Type gpedit in the Search and then click Edit group policy; navigate to User Configuration -> Administrative Templates -> Windows Components -> File Explorer; in the right-side pane look for "Turn off Windows key hotkeys" and double click on it; enable or disable hotkeys.

Note: restart is required to make the settings take effect.

diff --git a/make/autoconf/basic.m4 b/make/autoconf/basic.m4 index a3a4e132a4f..dc02d44c630 100644 --- a/make/autoconf/basic.m4 +++ b/make/autoconf/basic.m4 @@ -220,6 +220,18 @@ AC_DEFUN_ONCE([BASIC_SETUP_DEVKIT], [UTIL_PREPEND_TO_PATH([TOOLCHAIN_PATH],$with_toolchain_path)] ) + AC_ARG_WITH([xcode-path], [AS_HELP_STRING([--with-xcode-path], + [set up toolchain on Mac OS using a path to an Xcode installation])]) + + if test "x$with_xcode_path" != x; then + if test "x$OPENJDK_BUILD_OS" = "xmacosx"; then + UTIL_PREPEND_TO_PATH([TOOLCHAIN_PATH], + $with_xcode_path/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin:$with_xcode_path/Contents/Developer/usr/bin) + else + AC_MSG_WARN([Option --with-xcode-path is only valid on Mac OS, ignoring.]) + fi + fi + AC_ARG_WITH([extra-path], [AS_HELP_STRING([--with-extra-path], [prepend these directories to the default path])], [UTIL_PREPEND_TO_PATH([EXTRA_PATH],$with_extra_path)] @@ -230,7 +242,7 @@ AC_DEFUN_ONCE([BASIC_SETUP_DEVKIT], # If not, detect if Xcode is installed by running xcodebuild -version # if no Xcode installed, xcodebuild exits with 1 # if Xcode is installed, even if xcode-select is misconfigured, then it exits with 0 - if test "x$DEVKIT_ROOT" != x || /usr/bin/xcodebuild -version >/dev/null 2>&1; then + if test "x$DEVKIT_ROOT" != x || test "x$TOOLCHAIN_PATH" != x || /usr/bin/xcodebuild -version >/dev/null 2>&1; then # We need to use xcodebuild in the toolchain dir provided by the user UTIL_LOOKUP_PROGS(XCODEBUILD, xcodebuild, $TOOLCHAIN_PATH) if test x$XCODEBUILD = x; then