author | phh |
Sat, 30 Nov 2019 14:33:05 -0800 | |
changeset 59330 | 5b96c12f909d |
parent 51675 | b487c1e914d0 |
permissions | -rw-r--r-- |
31875 | 1 |
/* |
35775
00710c1b504a
8149529: Adapt SAP copyrights to new company name in jdk repository
goetz
parents:
31875
diff
changeset
|
2 |
* Copyright (c) 2015 SAP SE. All rights reserved. |
31875 | 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 |
*/ |
|
45709
841996818446
8182154: merge jdk.testlibrary.Platform and jdk.test.lib.Platform
iignatyev
parents:
35775
diff
changeset
|
23 |
|
841996818446
8182154: merge jdk.testlibrary.Platform and jdk.test.lib.Platform
iignatyev
parents:
35775
diff
changeset
|
24 |
import jdk.test.lib.Platform; |
51675 | 25 |
import jdk.test.lib.process.OutputAnalyzer; |
26 |
import jdk.test.lib.process.ProcessTools; |
|
31875 | 27 |
|
28 |
/* |
|
29 |
* @test |
|
30 |
* @bug 8132374 |
|
31 |
* @summary Check that the value of the os.version property is equal |
|
32 |
* to the value of the corresponding OS provided tools. |
|
51675 | 33 |
* @library /test/lib |
31875 | 34 |
* @run main OsVersionTest |
35 |
* @author Volker Simonis |
|
36 |
*/ |
|
37 |
public class OsVersionTest { |
|
38 |
||
39 |
public static void main(String args[]) throws Throwable { |
|
40 |
final String osVersion = System.getProperty("os.version"); |
|
41 |
if (osVersion == null) { |
|
42 |
throw new Error("Cant query 'os.version' property!"); |
|
43 |
} |
|
44 |
if (Platform.isLinux() || Platform.isSolaris()) { |
|
45 |
OutputAnalyzer output = ProcessTools.executeProcess("uname", "-r"); |
|
46 |
if (!osVersion.equals(output.getOutput().trim())) { |
|
47 |
throw new Error(osVersion + " != " + output.getOutput().trim()); |
|
48 |
} |
|
49 |
} |
|
50 |
else if (Platform.isOSX()) { |
|
51 |
OutputAnalyzer output = ProcessTools.executeProcess("sw_vers", "-productVersion"); |
|
52 |
if (!osVersion.equals(output.getOutput().trim())) { |
|
53 |
throw new Error(osVersion + " != " + output.getOutput().trim()); |
|
54 |
} |
|
55 |
} |
|
56 |
else if (Platform.isAix()) { |
|
57 |
OutputAnalyzer output1 = ProcessTools.executeProcess("uname", "-v"); |
|
58 |
OutputAnalyzer output2 = ProcessTools.executeProcess("uname", "-r"); |
|
59 |
String version = output1.getOutput().trim() + "." + output2.getOutput().trim(); |
|
60 |
if (!osVersion.equals(version)) { |
|
61 |
throw new Error(osVersion + " != " + version); |
|
62 |
} |
|
63 |
} |
|
64 |
else if (Platform.isWindows()) { |
|
65 |
OutputAnalyzer output = ProcessTools.executeProcess("cmd", "/c", "ver"); |
|
66 |
String version = output.firstMatch(".+\\[Version ([0-9.]+)\\]", 1); |
|
67 |
if (version == null || !version.startsWith(osVersion)) { |
|
68 |
throw new Error(osVersion + " != " + version); |
|
69 |
} |
|
70 |
} |
|
71 |
else { |
|
72 |
System.out.println("This test is currently not supported on " + |
|
73 |
Platform.getOsName()); |
|
74 |
} |
|
75 |
} |
|
76 |
} |