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