< prev index next >

test/jdk/java/lang/System/OsVersionTest.java

Print this page
rev 59105 : imported patch corelibs


  24 import jdk.test.lib.Platform;
  25 import jdk.test.lib.process.OutputAnalyzer;
  26 import jdk.test.lib.process.ProcessTools;
  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.
  33  * @library /test/lib
  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()) {


  24 import jdk.test.lib.Platform;
  25 import jdk.test.lib.process.OutputAnalyzer;
  26 import jdk.test.lib.process.ProcessTools;
  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.
  33  * @library /test/lib
  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()) {
  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()) {
< prev index next >