test/failure_handler/src/share/classes/jdk/test/failurehandler/jtreg/OS.java
author iignatyev
Tue, 20 Sep 2016 16:56:04 +0300
changeset 41038 23d98594d9bd
child 48601 391502ceeed9
permissions -rw-r--r--
8166262: failurehandler should not use jtreg internal API Reviewed-by: sla, dsamersoff
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
41038
23d98594d9bd 8166262: failurehandler should not use jtreg internal API
iignatyev
parents:
diff changeset
     1
/*
23d98594d9bd 8166262: failurehandler should not use jtreg internal API
iignatyev
parents:
diff changeset
     2
 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
23d98594d9bd 8166262: failurehandler should not use jtreg internal API
iignatyev
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
23d98594d9bd 8166262: failurehandler should not use jtreg internal API
iignatyev
parents:
diff changeset
     4
 *
23d98594d9bd 8166262: failurehandler should not use jtreg internal API
iignatyev
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
23d98594d9bd 8166262: failurehandler should not use jtreg internal API
iignatyev
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
23d98594d9bd 8166262: failurehandler should not use jtreg internal API
iignatyev
parents:
diff changeset
     7
 * published by the Free Software Foundation.
23d98594d9bd 8166262: failurehandler should not use jtreg internal API
iignatyev
parents:
diff changeset
     8
 *
23d98594d9bd 8166262: failurehandler should not use jtreg internal API
iignatyev
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
23d98594d9bd 8166262: failurehandler should not use jtreg internal API
iignatyev
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
23d98594d9bd 8166262: failurehandler should not use jtreg internal API
iignatyev
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
23d98594d9bd 8166262: failurehandler should not use jtreg internal API
iignatyev
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
23d98594d9bd 8166262: failurehandler should not use jtreg internal API
iignatyev
parents:
diff changeset
    13
 * accompanied this code).
23d98594d9bd 8166262: failurehandler should not use jtreg internal API
iignatyev
parents:
diff changeset
    14
 *
23d98594d9bd 8166262: failurehandler should not use jtreg internal API
iignatyev
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
23d98594d9bd 8166262: failurehandler should not use jtreg internal API
iignatyev
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
23d98594d9bd 8166262: failurehandler should not use jtreg internal API
iignatyev
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
23d98594d9bd 8166262: failurehandler should not use jtreg internal API
iignatyev
parents:
diff changeset
    18
 *
23d98594d9bd 8166262: failurehandler should not use jtreg internal API
iignatyev
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
23d98594d9bd 8166262: failurehandler should not use jtreg internal API
iignatyev
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
23d98594d9bd 8166262: failurehandler should not use jtreg internal API
iignatyev
parents:
diff changeset
    21
 * questions.
23d98594d9bd 8166262: failurehandler should not use jtreg internal API
iignatyev
parents:
diff changeset
    22
 */
23d98594d9bd 8166262: failurehandler should not use jtreg internal API
iignatyev
parents:
diff changeset
    23
23d98594d9bd 8166262: failurehandler should not use jtreg internal API
iignatyev
parents:
diff changeset
    24
package jdk.test.failurehandler.jtreg;
23d98594d9bd 8166262: failurehandler should not use jtreg internal API
iignatyev
parents:
diff changeset
    25
23d98594d9bd 8166262: failurehandler should not use jtreg internal API
iignatyev
parents:
diff changeset
    26
// Stripped down version of jtreg internal class com.sun.javatest.regtest.config.OS
23d98594d9bd 8166262: failurehandler should not use jtreg internal API
iignatyev
parents:
diff changeset
    27
class OS {
23d98594d9bd 8166262: failurehandler should not use jtreg internal API
iignatyev
parents:
diff changeset
    28
    public final String family;
23d98594d9bd 8166262: failurehandler should not use jtreg internal API
iignatyev
parents:
diff changeset
    29
23d98594d9bd 8166262: failurehandler should not use jtreg internal API
iignatyev
parents:
diff changeset
    30
    private static OS current;
23d98594d9bd 8166262: failurehandler should not use jtreg internal API
iignatyev
parents:
diff changeset
    31
23d98594d9bd 8166262: failurehandler should not use jtreg internal API
iignatyev
parents:
diff changeset
    32
    public static OS current() {
23d98594d9bd 8166262: failurehandler should not use jtreg internal API
iignatyev
parents:
diff changeset
    33
        if (current == null) {
23d98594d9bd 8166262: failurehandler should not use jtreg internal API
iignatyev
parents:
diff changeset
    34
            String name = System.getProperty("os.name");
23d98594d9bd 8166262: failurehandler should not use jtreg internal API
iignatyev
parents:
diff changeset
    35
            current = new OS(name);
23d98594d9bd 8166262: failurehandler should not use jtreg internal API
iignatyev
parents:
diff changeset
    36
        }
23d98594d9bd 8166262: failurehandler should not use jtreg internal API
iignatyev
parents:
diff changeset
    37
        return current;
23d98594d9bd 8166262: failurehandler should not use jtreg internal API
iignatyev
parents:
diff changeset
    38
    }
23d98594d9bd 8166262: failurehandler should not use jtreg internal API
iignatyev
parents:
diff changeset
    39
23d98594d9bd 8166262: failurehandler should not use jtreg internal API
iignatyev
parents:
diff changeset
    40
    private OS(String name) {
23d98594d9bd 8166262: failurehandler should not use jtreg internal API
iignatyev
parents:
diff changeset
    41
        if (name.startsWith("Linux")) {
23d98594d9bd 8166262: failurehandler should not use jtreg internal API
iignatyev
parents:
diff changeset
    42
            family = "linux";
23d98594d9bd 8166262: failurehandler should not use jtreg internal API
iignatyev
parents:
diff changeset
    43
        } else if (name.startsWith("Mac") || name.startsWith("Darwin")) {
23d98594d9bd 8166262: failurehandler should not use jtreg internal API
iignatyev
parents:
diff changeset
    44
            family = "mac";
23d98594d9bd 8166262: failurehandler should not use jtreg internal API
iignatyev
parents:
diff changeset
    45
        } else if (name.startsWith("SunOS") || name.startsWith("Solaris")) {
23d98594d9bd 8166262: failurehandler should not use jtreg internal API
iignatyev
parents:
diff changeset
    46
            family = "solaris";
23d98594d9bd 8166262: failurehandler should not use jtreg internal API
iignatyev
parents:
diff changeset
    47
        } else if (name.startsWith("Windows")) {
23d98594d9bd 8166262: failurehandler should not use jtreg internal API
iignatyev
parents:
diff changeset
    48
            family = "windows";
23d98594d9bd 8166262: failurehandler should not use jtreg internal API
iignatyev
parents:
diff changeset
    49
        } else {
23d98594d9bd 8166262: failurehandler should not use jtreg internal API
iignatyev
parents:
diff changeset
    50
            // use first word of name
23d98594d9bd 8166262: failurehandler should not use jtreg internal API
iignatyev
parents:
diff changeset
    51
            family = name.replaceFirst("^([^ ]+).*", "$1");
23d98594d9bd 8166262: failurehandler should not use jtreg internal API
iignatyev
parents:
diff changeset
    52
        }
23d98594d9bd 8166262: failurehandler should not use jtreg internal API
iignatyev
parents:
diff changeset
    53
    }
23d98594d9bd 8166262: failurehandler should not use jtreg internal API
iignatyev
parents:
diff changeset
    54
}
23d98594d9bd 8166262: failurehandler should not use jtreg internal API
iignatyev
parents:
diff changeset
    55
23d98594d9bd 8166262: failurehandler should not use jtreg internal API
iignatyev
parents:
diff changeset
    56