1 % Testing OpenJDK 2 3 ## Using the run-test framework 4 5 This new way of running tests is developer-centric. It assumes that you have 6 built a jdk locally and want to test it. Running common test targets is simple, 7 and more complex ad-hoc combination of tests is possible. The user interface is 8 forgiving, and clearly report errors it cannot resolve. 9 10 The main target "run-test" uses the jdk-image as the tested product. There is 11 also an alternate target "exploded-run-test" that uses the exploded image 12 instead. Not all tests will run successfully on the exploded image, but using 13 this target can greatly improve rebuild times for certain workflows. 14 15 Some example command-lines: 16 17 $ make run-test-tier1 18 $ make run-test-jdk_lang JTREG="JOBS=8" 19 $ make run-test TEST=jdk_lang 20 $ make run-test-only TEST="gtest:LogTagSet gtest:LogTagSetDescriptions" GTEST="REPEAT=-1" 21 $ make run-test TEST="hotspot:hotspot_gc" JTREG="JOBS=1;TIMEOUT=8;VM_OPTIONS=-XshowSettings -Xlog:gc+ref=debug" 22 $ make run-test TEST="jtreg:test/hotspot:hotspot_gc test/hotspot/jtreg/native_sanity/JniVersion.java" 23 $ make exploded-run-test TEST=tier2 24 25 ### Configuration 26 27 To be able to run JTReg tests, `configure` needs to know where to find the 28 JTReg test framework. If it is not picked up automatically by configure, use 29 the `--with-jtreg=<path to jtreg home>` option to point to the JTReg framework. 30 Note that this option should point to the JTReg home, i.e. the top directory, 31 containing `lib/jtreg.jar` etc. (An alternative is to set the `JT_HOME` 32 environment variable to point to the JTReg home before running `configure`.) 33 34 ## Test selection 35 36 All functionality is available using the run-test make target. In this use 37 case, the test or tests to be executed is controlled using the `TEST` variable. 38 To speed up subsequent test runs with no source code changes, run-test-only can 39 be used instead, which do not depend on the source and test image build. 40 41 For some common top-level tests, direct make targets have been generated. This 42 includes all JTReg test groups, the hotspot gtest, and custom tests (if 43 present). This means that `make run-test-tier1` is equivalent to `make run-test 44 TEST="tier1"`, but the latter is more tab-completion friendly. For more complex 45 test runs, the `run-test TEST="x"` solution needs to be used. 46 47 The test specifications given in `TEST` is parsed into fully qualified test 48 descriptors, which clearly and unambigously show which tests will be run. As an 49 example, `:tier1` will expand to `jtreg:$(TOPDIR)/test/hotspot/jtreg:tier1 50 jtreg:$(TOPDIR)/test/jdk:tier1 jtreg:$(TOPDIR)/test/langtools:tier1 51 jtreg:$(TOPDIR)/test/nashorn:tier1 jtreg:$(TOPDIR)/test/jaxp:tier1`. You can 52 always submit a list of fully qualified test descriptors in the `TEST` variable 53 if you want to shortcut the parser. 54 55 ### JTReg 56 57 JTReg tests can be selected either by picking a JTReg test group, or a selection 58 of files or directories containing JTReg tests. 59 60 JTReg test groups can be specified either without a test root, e.g. `:tier1` 61 (or `tier1`, the initial colon is optional), or with, e.g. `hotspot:tier1`, 62 `test/jdk:jdk_util` or `$(TOPDIR)/test/hotspot/jtreg:hotspot_all`. The test 63 root can be specified either as an absolute path, or a path relative to the 64 OpenJDK top directory, or the `test` directory. For simplicity, the hotspot 65 JTReg test root, which really is `hotspot/jtreg` can be abbreviated as 66 just `hotspot`. 67 68 When specified without a test root, all matching groups from all test roots 69 will be added. Otherwise, only the group from the specified test root will be 70 added. 71 72 Individual JTReg tests or directories containing JTReg tests can also be 73 specified, like `test/hotspot/jtreg/native_sanity/JniVersion.java` or 74 `hotspot/jtreg/native_sanity`. Just like for test root selection, you can 75 either specify an absolute path (which can even point to JTReg tests outside 76 the source tree), or a path relative to either the OpenJDK top directory or the 77 `test` directory. `hotspot` can be used as an alias for `hotspot/jtreg` here as 78 well. 79 80 As long as the test groups or test paths can be uniquely resolved, you do not 81 need to enter the `jtreg:` prefix. If this is not possible, or if you want to 82 use a fully qualified test descriptor, add `jtreg:`, e.g. 83 `jtreg:test/hotspot/jtreg/native_sanity`. 84 85 ### Gtest 86 87 Since the Hotspot Gtest suite is so quick, the default is to run all tests. 88 This is specified by just `gtest`, or as a fully qualified test descriptor 89 `gtest:all`. 90 91 If you want, you can single out an individual test or a group of tests, for 92 instance `gtest:LogDecorations` or `gtest:LogDecorations.level_test_vm`. This 93 can be particularly useful if you want to run a shaky test repeatedly. 94 95 For Gtest, there is a separate test suite for each JVM variant. The JVM variant 96 is defined by adding `/<variant>` to the test descriptor, e.g. 97 `gtest:Log/client`. If you specify no variant, gtest will run once for each JVM 98 variant present (e.g. server, client). So if you only have the server JVM 99 present, then `gtest:all` will be equivalent to `gtest:all/server`. 100 101 ## Test results and summary 102 103 At the end of the test run, a summary of all tests run will be presented. This 104 will have a consistent look, regardless of what test suites were used. This is 105 a sample summary: 106 107 ============================== 108 Test summary 109 ============================== 110 TEST TOTAL PASS FAIL ERROR 111 >> jtreg:jdk/test:tier1 1867 1865 2 0 << 112 jtreg:langtools/test:tier1 4711 4711 0 0 113 jtreg:nashorn/test:tier1 133 133 0 0 114 ============================== 115 TEST FAILURE 116 117 Tests where the number of TOTAL tests does not equal the number of PASSed tests 118 will be considered a test failure. These are marked with the `>> ... <<` marker 119 for easy identification. 120 121 The classification of non-passed tests differs a bit between test suites. In 122 the summary, ERROR is used as a catch-all for tests that neither passed nor are 123 classified as failed by the framework. This might indicate test framework 124 error, timeout or other problems. 125 126 In case of test failures, `make run-test` will exit with a non-zero exit value. 127 128 All tests have their result stored in `build/$BUILD/test-results/$TEST_ID`, 129 where TEST_ID is a path-safe conversion from the fully qualified test 130 descriptor, e.g. for `jtreg:jdk/test:tier1` the TEST_ID is 131 `jtreg_jdk_test_tier1`. This path is also printed in the log at the end of the 132 test run. 133 134 Additional work data is stored in `build/$BUILD/test-support/$TEST_ID`. For 135 some frameworks, this directory might contain information that is useful in 136 determining the cause of a failed test. 137 138 ## Test suite control 139 140 It is possible to control various aspects of the test suites using make control 141 variables. 142 143 These variables use a keyword=value approach to allow multiple values to be 144 set. So, for instance, `JTREG="JOBS=1;TIMEOUT=8"` will set the JTReg 145 concurrency level to 1 and the timeout factor to 8. This is equivalent to 146 setting `JTREG_JOBS=1 JTREG_TIMEOUT=8`, but using the keyword format means that 147 the `JTREG` variable is parsed and verified for correctness, so 148 `JTREG="TMIEOUT=8"` would give an error, while `JTREG_TMIEOUT=8` would just 149 pass unnoticed. 150 151 To separate multiple keyword=value pairs, use `;` (semicolon). Since the shell 152 normally eats `;`, the recommended usage is to write the assignment inside 153 qoutes, e.g. `JTREG="...;..."`. This will also make sure spaces are preserved, 154 as in `JTREG="VM_OPTIONS=-XshowSettings -Xlog:gc+ref=debug"`. 155 156 (Other ways are possible, e.g. using backslash: `JTREG=JOBS=1\;TIMEOUT=8`. 157 Also, as a special technique, the string `%20` will be replaced with space for 158 certain options, e.g. `JTREG=VM_OPTIONS=-XshowSettings%20-Xlog:gc+ref=debug`. 159 This can be useful if you have layers of scripts and have trouble getting 160 proper quoting of command line arguments through.) 161 162 As far as possible, the names of the keywords have been standardized between 163 test suites. 164 165 ### JTReg keywords 166 167 #### JOBS 168 The test concurrency (`-concurrency`). 169 170 Defaults to TEST_JOBS (if set by `--with-test-jobs=`), otherwise it defaults to 171 JOBS, except for Hotspot, where the default is *number of CPU cores/2*, but 172 never more than 12. 173 174 #### TIMEOUT 175 The timeout factor (`-timeoutFactor`). 176 177 Defaults to 4. 178 179 #### TEST_MODE 180 The test mode (`-agentvm`, `-samevm` or `-othervm`). 181 182 Defaults to `-agentvm`. 183 184 #### ASSERT 185 Enable asserts (`-ea -esa`, or none). 186 187 Set to `true` or `false`. If true, adds `-ea -esa`. Defaults to true, except 188 for hotspot. 189 190 #### VERBOSE 191 The verbosity level (`-verbose`). 192 193 Defaults to `fail,error,summary`. 194 195 #### RETAIN 196 What test data to retain (`-retain`). 197 198 Defaults to `fail,error`. 199 200 #### MAX_MEM 201 Limit memory consumption (`-Xmx` and `-vmoption:-Xmx`, or none). 202 203 Limit memory consumption for JTReg test framework and VM under test. Set to 0 204 to disable the limits. 205 206 Defaults to 512m, except for hotspot, where it defaults to 0 (no limit). 207 208 #### OPTIONS 209 Additional options to the JTReg test framework. 210 211 Use `JTREG="OPTIONS=--help all"` to see all available JTReg options. 212 213 #### JAVA_OPTIONS 214 Additional Java options to JTReg (`-javaoption`). 215 216 #### VM_OPTIONS 217 Additional VM options to JTReg (`-vmoption`). 218 219 ### Gtest keywords 220 221 #### REPEAT 222 The number of times to repeat the tests (`--gtest_repeat`). 223 224 Default is 1. Set to -1 to repeat indefinitely. This can be especially useful 225 combined with `OPTIONS=--gtest_break_on_failure` to reproduce an intermittent 226 problem. 227 228 #### OPTIONS 229 Additional options to the Gtest test framework. 230 231 Use `GTEST="OPTIONS=--help"` to see all available Gtest options. 232 233 --- 234 # Override some definitions in the global css file that are not optimal for 235 # this document. 236 header-includes: 237 - '<style type="text/css">pre, code, tt { color: #1d6ae5; }</style>' 238 ---