author | mr |
Wed, 16 Jan 2019 16:27:21 -0800 | |
changeset 53372 | 4003935e6e5f |
parent 51675 | b487c1e914d0 |
permissions | -rw-r--r-- |
42338 | 1 |
/* |
51675 | 2 |
* Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. |
42338 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
22 |
*/ |
|
23 |
||
24 |
/** |
|
25 |
* @test |
|
51675 | 26 |
* @library /test/lib |
27 |
* @build InfoStreams jdk.test.lib.process.ProcessTools |
|
42338 | 28 |
* @run main InfoStreams |
29 |
* @summary Test that informational options use the correct streams |
|
30 |
*/ |
|
31 |
||
51675 | 32 |
import jdk.test.lib.process.ProcessTools; |
33 |
import jdk.test.lib.process.OutputAnalyzer; |
|
42338 | 34 |
|
35 |
public class InfoStreams { |
|
36 |
||
37 |
public static OutputAnalyzer run(String ... opts) throws Exception { |
|
38 |
return ProcessTools.executeTestJava(opts).shouldHaveExitValue(0); |
|
39 |
} |
|
40 |
||
41 |
private static final String |
|
42 |
java_version = System.getProperty("java.version"), |
|
43 |
USAGE = "^Usage: java ", |
|
44 |
VERSION_ERR = "^(java|openjdk) version \"" + java_version + "\"", |
|
45 |
VERSION_OUT = "^(java|openjdk) " + java_version, |
|
46 |
FULLVERSION_ERR = "^(java|openjdk) full version \"" + java_version + ".*\"", |
|
47 |
FULLVERSION_OUT = "^(java|openjdk) " + java_version, |
|
48 |
NONSTD = ".*These extra options are subject to change"; |
|
49 |
||
50 |
public static void main(String ... args) throws Exception { |
|
51 |
||
52 |
String classPath = System.getProperty("java.class.path"); |
|
53 |
||
49538
707553fcca04
8196750: [Testbug] tools/launcher tests need to tolerate unrelated warnings
anazarov
parents:
47216
diff
changeset
|
54 |
run("-help").stderrShouldMatch(USAGE).stdoutShouldNotMatch(USAGE); |
707553fcca04
8196750: [Testbug] tools/launcher tests need to tolerate unrelated warnings
anazarov
parents:
47216
diff
changeset
|
55 |
run("--help").stdoutShouldMatch(USAGE).stderrShouldNotMatch(USAGE); |
42338 | 56 |
|
49538
707553fcca04
8196750: [Testbug] tools/launcher tests need to tolerate unrelated warnings
anazarov
parents:
47216
diff
changeset
|
57 |
run("-version").stderrShouldMatch(VERSION_ERR) |
707553fcca04
8196750: [Testbug] tools/launcher tests need to tolerate unrelated warnings
anazarov
parents:
47216
diff
changeset
|
58 |
.stdoutShouldNotMatch(VERSION_ERR) |
707553fcca04
8196750: [Testbug] tools/launcher tests need to tolerate unrelated warnings
anazarov
parents:
47216
diff
changeset
|
59 |
.stdoutShouldNotMatch(VERSION_OUT); |
707553fcca04
8196750: [Testbug] tools/launcher tests need to tolerate unrelated warnings
anazarov
parents:
47216
diff
changeset
|
60 |
run("--version").stdoutShouldMatch(VERSION_OUT) |
707553fcca04
8196750: [Testbug] tools/launcher tests need to tolerate unrelated warnings
anazarov
parents:
47216
diff
changeset
|
61 |
.stderrShouldNotMatch(VERSION_OUT) |
707553fcca04
8196750: [Testbug] tools/launcher tests need to tolerate unrelated warnings
anazarov
parents:
47216
diff
changeset
|
62 |
.stderrShouldNotMatch(VERSION_ERR); |
42338 | 63 |
|
64 |
run("-showversion", "--dry-run", "-cp", classPath, "InfoStreams") |
|
65 |
.stderrShouldMatch(VERSION_ERR) |
|
49538
707553fcca04
8196750: [Testbug] tools/launcher tests need to tolerate unrelated warnings
anazarov
parents:
47216
diff
changeset
|
66 |
.stdoutShouldNotMatch(VERSION_ERR) |
707553fcca04
8196750: [Testbug] tools/launcher tests need to tolerate unrelated warnings
anazarov
parents:
47216
diff
changeset
|
67 |
.stdoutShouldNotMatch(VERSION_OUT); |
42338 | 68 |
run("--show-version", "--dry-run", "-cp", classPath, "InfoStreams") |
69 |
.stdoutShouldMatch(VERSION_OUT) |
|
49538
707553fcca04
8196750: [Testbug] tools/launcher tests need to tolerate unrelated warnings
anazarov
parents:
47216
diff
changeset
|
70 |
.stderrShouldNotMatch(VERSION_OUT) |
707553fcca04
8196750: [Testbug] tools/launcher tests need to tolerate unrelated warnings
anazarov
parents:
47216
diff
changeset
|
71 |
.stderrShouldNotMatch(VERSION_ERR); |
42338 | 72 |
|
73 |
run("-fullversion").stderrShouldMatch(FULLVERSION_ERR) |
|
49538
707553fcca04
8196750: [Testbug] tools/launcher tests need to tolerate unrelated warnings
anazarov
parents:
47216
diff
changeset
|
74 |
.stdoutShouldNotMatch(FULLVERSION_ERR) |
707553fcca04
8196750: [Testbug] tools/launcher tests need to tolerate unrelated warnings
anazarov
parents:
47216
diff
changeset
|
75 |
.stdoutShouldNotMatch(FULLVERSION_OUT); |
42338 | 76 |
run("--full-version").stdoutShouldMatch(FULLVERSION_OUT) |
49538
707553fcca04
8196750: [Testbug] tools/launcher tests need to tolerate unrelated warnings
anazarov
parents:
47216
diff
changeset
|
77 |
.stderrShouldNotMatch(FULLVERSION_OUT) |
707553fcca04
8196750: [Testbug] tools/launcher tests need to tolerate unrelated warnings
anazarov
parents:
47216
diff
changeset
|
78 |
.stderrShouldNotMatch(FULLVERSION_ERR); |
42338 | 79 |
|
49538
707553fcca04
8196750: [Testbug] tools/launcher tests need to tolerate unrelated warnings
anazarov
parents:
47216
diff
changeset
|
80 |
run("-X").stderrShouldMatch(NONSTD).stdoutShouldNotMatch(NONSTD); |
707553fcca04
8196750: [Testbug] tools/launcher tests need to tolerate unrelated warnings
anazarov
parents:
47216
diff
changeset
|
81 |
run("--help-extra").stdoutShouldMatch(NONSTD).stderrShouldNotMatch(NONSTD); |
42338 | 82 |
} |
83 |
} |