jdk/test/sun/management/jmxremote/bootstrap/CustomLauncherTest.java
author mchung
Wed, 10 Aug 2016 15:51:25 -0700
changeset 40261 86a49ba76f52
parent 36511 9d0388c6b336
child 42772 b93b2c218be0
permissions -rw-r--r--
8136930: Simplify use of module-system options by custom launchers Reviewed-by: alanb, ksrini, henryjen, sundar
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
21367
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
     1
/*
30376
2ccf2cf7ea48 8078896: Add @modules as needed to the jdk_svc tests
ykantser
parents: 28760
diff changeset
     2
 * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
21367
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
     4
 *
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
     7
 * published by the Free Software Foundation.
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
     8
 *
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    13
 * accompanied this code).
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    14
 *
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    18
 *
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    21
 * questions.
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    22
 */
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    23
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    24
import java.io.File;
22062
175604b1209f 8029809: sun/management/jmxremote/bootstrap/CustomLauncherTest.java fails intermittently with "Operation not permitted"
jbachorik
parents: 21822
diff changeset
    25
import java.io.IOException;
21367
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    26
import java.nio.file.FileSystem;
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    27
import java.nio.file.FileSystems;
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    28
import java.nio.file.Files;
21802
b36494ddf19e 8027163: sun/management/jmxremote/bootstrap/CustomLauncherTest.java should be updated for jdk8 removal of solaris-32bit support
jbachorik
parents: 21662
diff changeset
    29
import java.nio.file.LinkOption;
21367
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    30
import java.nio.file.Path;
22062
175604b1209f 8029809: sun/management/jmxremote/bootstrap/CustomLauncherTest.java fails intermittently with "Operation not permitted"
jbachorik
parents: 21822
diff changeset
    31
import java.nio.file.StandardCopyOption;
21802
b36494ddf19e 8027163: sun/management/jmxremote/bootstrap/CustomLauncherTest.java should be updated for jdk8 removal of solaris-32bit support
jbachorik
parents: 21662
diff changeset
    32
import java.nio.file.attribute.PosixFilePermission;
b36494ddf19e 8027163: sun/management/jmxremote/bootstrap/CustomLauncherTest.java should be updated for jdk8 removal of solaris-32bit support
jbachorik
parents: 21662
diff changeset
    33
import java.util.HashSet;
b36494ddf19e 8027163: sun/management/jmxremote/bootstrap/CustomLauncherTest.java should be updated for jdk8 removal of solaris-32bit support
jbachorik
parents: 21662
diff changeset
    34
import java.util.Set;
21367
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    35
import java.util.concurrent.TimeUnit;
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    36
import java.util.concurrent.atomic.AtomicReference;
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    37
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    38
import jdk.testlibrary.ProcessTools;
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    39
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    40
/**
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    41
 * @test
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    42
 * @bug 6434402 8004926
21404
0e54d286d846 8027358: sun/management/jmxremote/bootstrap/LocalManagementTest.java failing since JDK-8004926
jbachorik
parents: 21367
diff changeset
    43
 * @library /lib/testlibrary
30376
2ccf2cf7ea48 8078896: Add @modules as needed to the jdk_svc tests
ykantser
parents: 28760
diff changeset
    44
 * @modules java.management/sun.management
2ccf2cf7ea48 8078896: Add @modules as needed to the jdk_svc tests
ykantser
parents: 28760
diff changeset
    45
 *          java.management
24366
57c0a8b7a936 8034960: Serviceability tests using @library failing with java.lang.NoClassDefFoundError
ykantser
parents: 22255
diff changeset
    46
 * @build jdk.testlibrary.*
21367
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    47
 * @build TestManager TestApplication CustomLauncherTest
21802
b36494ddf19e 8027163: sun/management/jmxremote/bootstrap/CustomLauncherTest.java should be updated for jdk8 removal of solaris-32bit support
jbachorik
parents: 21662
diff changeset
    48
 * @run main/othervm CustomLauncherTest
21367
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    49
 * @author Jaroslav Bachorik
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    50
 */
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    51
public class CustomLauncherTest {
21822
12f13ba496cd 8028141: test/sun/management/jmxremote/bootstrap/LocalManagementTest|CustomLauncherTest.java failing again
rriggs
parents: 21802
diff changeset
    52
    private static final  String TEST_CLASSPATH = System.getProperty("test.class.path");
21367
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    53
    private static final  String TEST_JDK = System.getProperty("test.jdk");
22062
175604b1209f 8029809: sun/management/jmxremote/bootstrap/CustomLauncherTest.java fails intermittently with "Operation not permitted"
jbachorik
parents: 21822
diff changeset
    54
    private static final  String WORK_DIR = System.getProperty("user.dir");
21367
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    55
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    56
    private static final  String TEST_SRC = System.getProperty("test.src");
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    57
    private static final  String OSNAME = System.getProperty("os.name");
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    58
    private static final  String ARCH;
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    59
    private static final  String LIBARCH;
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    60
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    61
    static {
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    62
        // magic with os.arch
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    63
        String osarch = System.getProperty("os.arch");
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    64
        switch (osarch) {
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    65
            case "i386":
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    66
            case "i486":
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    67
            case "i586":
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    68
            case "i686":
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    69
            case "i786":
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    70
            case "i886":
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    71
            case "i986": {
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    72
                ARCH = "i586";
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    73
                break;
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    74
            }
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    75
            case "x86_64":
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    76
            case "amd64": {
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    77
                ARCH = "amd64";
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    78
                break;
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    79
            }
21802
b36494ddf19e 8027163: sun/management/jmxremote/bootstrap/CustomLauncherTest.java should be updated for jdk8 removal of solaris-32bit support
jbachorik
parents: 21662
diff changeset
    80
            case "sparc":
b36494ddf19e 8027163: sun/management/jmxremote/bootstrap/CustomLauncherTest.java should be updated for jdk8 removal of solaris-32bit support
jbachorik
parents: 21662
diff changeset
    81
                ARCH = "sparcv9";
b36494ddf19e 8027163: sun/management/jmxremote/bootstrap/CustomLauncherTest.java should be updated for jdk8 removal of solaris-32bit support
jbachorik
parents: 21662
diff changeset
    82
                break;
21367
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    83
            default: {
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    84
                ARCH = osarch;
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    85
            }
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    86
        }
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    87
        LIBARCH = ARCH.equals("i586") ? "i386" : ARCH;
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    88
    }
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    89
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    90
    public static void main(String[] args) throws Exception {
21822
12f13ba496cd 8028141: test/sun/management/jmxremote/bootstrap/LocalManagementTest|CustomLauncherTest.java failing again
rriggs
parents: 21802
diff changeset
    91
        if (TEST_CLASSPATH == null || TEST_CLASSPATH.isEmpty()) {
21367
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    92
            System.out.println("Test is designed to be run from jtreg only");
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    93
            return;
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    94
        }
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
    95
22255
b4f108102ca9 8031420: sun/management/jmxremote/bootstrap/CustomLauncherTest.java fails on some platforms: Unable to locate 'libjvm.so'
jbachorik
parents: 22062
diff changeset
    96
        if (getPlatform() == null) {
b4f108102ca9 8031420: sun/management/jmxremote/bootstrap/CustomLauncherTest.java fails on some platforms: Unable to locate 'libjvm.so'
jbachorik
parents: 22062
diff changeset
    97
            System.out.println("Test not designed to run on this operating " +
b4f108102ca9 8031420: sun/management/jmxremote/bootstrap/CustomLauncherTest.java fails on some platforms: Unable to locate 'libjvm.so'
jbachorik
parents: 22062
diff changeset
    98
                                "system (" + OSNAME + "), skipping...");
b4f108102ca9 8031420: sun/management/jmxremote/bootstrap/CustomLauncherTest.java fails on some platforms: Unable to locate 'libjvm.so'
jbachorik
parents: 22062
diff changeset
    99
            return;
b4f108102ca9 8031420: sun/management/jmxremote/bootstrap/CustomLauncherTest.java fails on some platforms: Unable to locate 'libjvm.so'
jbachorik
parents: 22062
diff changeset
   100
        }
b4f108102ca9 8031420: sun/management/jmxremote/bootstrap/CustomLauncherTest.java fails on some platforms: Unable to locate 'libjvm.so'
jbachorik
parents: 22062
diff changeset
   101
21367
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   102
        final FileSystem FS = FileSystems.getDefault();
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   103
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   104
        Path libjvmPath = findLibjvm(FS);
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   105
        if (libjvmPath == null) {
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   106
            throw new Error("Unable to locate 'libjvm.so' in " + TEST_JDK);
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   107
        }
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   108
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   109
        Process serverPrc = null, clientPrc = null;
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   110
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   111
        try {
22062
175604b1209f 8029809: sun/management/jmxremote/bootstrap/CustomLauncherTest.java fails intermittently with "Operation not permitted"
jbachorik
parents: 21822
diff changeset
   112
            String[] launcher = getLauncher();
21802
b36494ddf19e 8027163: sun/management/jmxremote/bootstrap/CustomLauncherTest.java should be updated for jdk8 removal of solaris-32bit support
jbachorik
parents: 21662
diff changeset
   113
30665
de1d43259890 8072906: sun/management/jmxremote/bootstrap/CustomLauncherTest.java failing on embedded platform
jbachorik
parents: 28760
diff changeset
   114
            if (launcher == null) return; // launcher not available for the tested platform; skip
de1d43259890 8072906: sun/management/jmxremote/bootstrap/CustomLauncherTest.java failing on embedded platform
jbachorik
parents: 28760
diff changeset
   115
21367
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   116
            System.out.println("Starting custom launcher:");
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   117
            System.out.println("=========================");
22062
175604b1209f 8029809: sun/management/jmxremote/bootstrap/CustomLauncherTest.java fails intermittently with "Operation not permitted"
jbachorik
parents: 21822
diff changeset
   118
            System.out.println("  launcher  : " + launcher[0]);
21367
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   119
            System.out.println("  libjvm    : " + libjvmPath.toString());
21822
12f13ba496cd 8028141: test/sun/management/jmxremote/bootstrap/LocalManagementTest|CustomLauncherTest.java failing again
rriggs
parents: 21802
diff changeset
   120
            System.out.println("  classpath : " + TEST_CLASSPATH);
22062
175604b1209f 8029809: sun/management/jmxremote/bootstrap/CustomLauncherTest.java fails intermittently with "Operation not permitted"
jbachorik
parents: 21822
diff changeset
   121
            ProcessBuilder server = new ProcessBuilder(
175604b1209f 8029809: sun/management/jmxremote/bootstrap/CustomLauncherTest.java fails intermittently with "Operation not permitted"
jbachorik
parents: 21822
diff changeset
   122
                launcher[1],
175604b1209f 8029809: sun/management/jmxremote/bootstrap/CustomLauncherTest.java fails intermittently with "Operation not permitted"
jbachorik
parents: 21822
diff changeset
   123
                libjvmPath.toString(),
175604b1209f 8029809: sun/management/jmxremote/bootstrap/CustomLauncherTest.java fails intermittently with "Operation not permitted"
jbachorik
parents: 21822
diff changeset
   124
                TEST_CLASSPATH,
175604b1209f 8029809: sun/management/jmxremote/bootstrap/CustomLauncherTest.java fails intermittently with "Operation not permitted"
jbachorik
parents: 21822
diff changeset
   125
                "TestApplication"
175604b1209f 8029809: sun/management/jmxremote/bootstrap/CustomLauncherTest.java fails intermittently with "Operation not permitted"
jbachorik
parents: 21822
diff changeset
   126
            );
21367
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   127
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   128
            final AtomicReference<String> port = new AtomicReference<>();
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   129
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   130
            serverPrc = ProcessTools.startProcess(
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   131
                "Launcher",
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   132
                server,
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   133
                (String line) -> {
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   134
                    if (line.startsWith("port:")) {
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   135
                         port.set(line.split("\\:")[1]);
25182
1f6766bac82c 8048193: [tests] Replace JPS and stdout based PID retrieval by Process.getPid()
jbachorik
parents: 24366
diff changeset
   136
                    } else if (line.startsWith("waiting")) {
21367
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   137
                         return true;
25182
1f6766bac82c 8048193: [tests] Replace JPS and stdout based PID retrieval by Process.getPid()
jbachorik
parents: 24366
diff changeset
   138
                    }
1f6766bac82c 8048193: [tests] Replace JPS and stdout based PID retrieval by Process.getPid()
jbachorik
parents: 24366
diff changeset
   139
                    return false;
21367
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   140
                },
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   141
                5,
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   142
                TimeUnit.SECONDS
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   143
            );
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   144
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   145
            System.out.println("Attaching test manager:");
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   146
            System.out.println("=========================");
25182
1f6766bac82c 8048193: [tests] Replace JPS and stdout based PID retrieval by Process.getPid()
jbachorik
parents: 24366
diff changeset
   147
            System.out.println("  PID           : " + serverPrc.getPid());
21367
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   148
            System.out.println("  shutdown port : " + port.get());
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   149
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   150
            ProcessBuilder client = ProcessTools.createJavaProcessBuilder(
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   151
                "-cp",
28760
b83d51c77b31 8067945: SVC jdk/test/* should be cleaned from JRE layout dependency
ykantser
parents: 25182
diff changeset
   152
                TEST_CLASSPATH,
40261
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 36511
diff changeset
   153
                "--add-exports", "java.management/sun.management=ALL-UNNAMED",
21367
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   154
                "TestManager",
25182
1f6766bac82c 8048193: [tests] Replace JPS and stdout based PID retrieval by Process.getPid()
jbachorik
parents: 24366
diff changeset
   155
                String.valueOf(serverPrc.getPid()),
21367
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   156
                port.get(),
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   157
                "true"
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   158
            );
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   159
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   160
            clientPrc = ProcessTools.startProcess(
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   161
                "TestManager",
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   162
                client,
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   163
                (String line) -> line.startsWith("Starting TestManager for PID"),
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   164
                10,
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   165
                TimeUnit.SECONDS
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   166
            );
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   167
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   168
            int clientExitCode = clientPrc.waitFor();
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   169
            int serverExitCode = serverPrc.waitFor();
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   170
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   171
            if (clientExitCode != 0 || serverExitCode != 0) {
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   172
                throw new Error("Test failed");
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   173
            }
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   174
        } finally {
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   175
            if (clientPrc != null) {
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   176
                clientPrc.destroy();
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   177
                clientPrc.waitFor();
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   178
            }
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   179
            if (serverPrc != null) {
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   180
                serverPrc.destroy();
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   181
                serverPrc.waitFor();
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   182
            }
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   183
        }
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   184
    }
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   185
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   186
    private static Path findLibjvm(FileSystem FS) {
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   187
        Path libjvmPath = findLibjvm(FS.getPath(TEST_JDK, "jre", "lib", LIBARCH));
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   188
        if (libjvmPath == null) {
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   189
            libjvmPath = findLibjvm(FS.getPath(TEST_JDK, "lib", LIBARCH));
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   190
        }
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   191
        return libjvmPath;
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   192
    }
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   193
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   194
    private static Path findLibjvm(Path libPath) {
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   195
        // ARCH/libjvm.so -> ARCH/server/libjvm.so -> ARCH/client/libjvm.so
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   196
        Path libjvmPath = libPath.resolve("libjvm.so");
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   197
        if (isFileOk(libjvmPath)) {
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   198
            return libjvmPath;
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   199
        }
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   200
        libjvmPath = libPath.resolve("server/libjvm.so");
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   201
        if (isFileOk(libjvmPath)) {
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   202
            return libjvmPath;
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   203
        }
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   204
        libjvmPath = libPath.resolve("client/libjvm.so");
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   205
        if (isFileOk(libPath)) {
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   206
            return libjvmPath;
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   207
        }
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   208
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   209
        return null;
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   210
    }
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   211
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   212
    private static boolean isFileOk(Path path) {
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   213
        return Files.isRegularFile(path) && Files.isReadable(path);
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   214
    }
22062
175604b1209f 8029809: sun/management/jmxremote/bootstrap/CustomLauncherTest.java fails intermittently with "Operation not permitted"
jbachorik
parents: 21822
diff changeset
   215
175604b1209f 8029809: sun/management/jmxremote/bootstrap/CustomLauncherTest.java fails intermittently with "Operation not permitted"
jbachorik
parents: 21822
diff changeset
   216
    private static String getPlatform() {
175604b1209f 8029809: sun/management/jmxremote/bootstrap/CustomLauncherTest.java fails intermittently with "Operation not permitted"
jbachorik
parents: 21822
diff changeset
   217
        String platform = null;
175604b1209f 8029809: sun/management/jmxremote/bootstrap/CustomLauncherTest.java fails intermittently with "Operation not permitted"
jbachorik
parents: 21822
diff changeset
   218
        switch (OSNAME.toLowerCase()) {
175604b1209f 8029809: sun/management/jmxremote/bootstrap/CustomLauncherTest.java fails intermittently with "Operation not permitted"
jbachorik
parents: 21822
diff changeset
   219
            case "linux": {
175604b1209f 8029809: sun/management/jmxremote/bootstrap/CustomLauncherTest.java fails intermittently with "Operation not permitted"
jbachorik
parents: 21822
diff changeset
   220
                platform = "linux";
175604b1209f 8029809: sun/management/jmxremote/bootstrap/CustomLauncherTest.java fails intermittently with "Operation not permitted"
jbachorik
parents: 21822
diff changeset
   221
                break;
175604b1209f 8029809: sun/management/jmxremote/bootstrap/CustomLauncherTest.java fails intermittently with "Operation not permitted"
jbachorik
parents: 21822
diff changeset
   222
            }
175604b1209f 8029809: sun/management/jmxremote/bootstrap/CustomLauncherTest.java fails intermittently with "Operation not permitted"
jbachorik
parents: 21822
diff changeset
   223
            case "sunos": {
175604b1209f 8029809: sun/management/jmxremote/bootstrap/CustomLauncherTest.java fails intermittently with "Operation not permitted"
jbachorik
parents: 21822
diff changeset
   224
                platform = "solaris";
175604b1209f 8029809: sun/management/jmxremote/bootstrap/CustomLauncherTest.java fails intermittently with "Operation not permitted"
jbachorik
parents: 21822
diff changeset
   225
                break;
175604b1209f 8029809: sun/management/jmxremote/bootstrap/CustomLauncherTest.java fails intermittently with "Operation not permitted"
jbachorik
parents: 21822
diff changeset
   226
            }
175604b1209f 8029809: sun/management/jmxremote/bootstrap/CustomLauncherTest.java fails intermittently with "Operation not permitted"
jbachorik
parents: 21822
diff changeset
   227
            default: {
22255
b4f108102ca9 8031420: sun/management/jmxremote/bootstrap/CustomLauncherTest.java fails on some platforms: Unable to locate 'libjvm.so'
jbachorik
parents: 22062
diff changeset
   228
                platform = null;
22062
175604b1209f 8029809: sun/management/jmxremote/bootstrap/CustomLauncherTest.java fails intermittently with "Operation not permitted"
jbachorik
parents: 21822
diff changeset
   229
            }
175604b1209f 8029809: sun/management/jmxremote/bootstrap/CustomLauncherTest.java fails intermittently with "Operation not permitted"
jbachorik
parents: 21822
diff changeset
   230
        }
175604b1209f 8029809: sun/management/jmxremote/bootstrap/CustomLauncherTest.java fails intermittently with "Operation not permitted"
jbachorik
parents: 21822
diff changeset
   231
175604b1209f 8029809: sun/management/jmxremote/bootstrap/CustomLauncherTest.java fails intermittently with "Operation not permitted"
jbachorik
parents: 21822
diff changeset
   232
        return platform;
175604b1209f 8029809: sun/management/jmxremote/bootstrap/CustomLauncherTest.java fails intermittently with "Operation not permitted"
jbachorik
parents: 21822
diff changeset
   233
    }
175604b1209f 8029809: sun/management/jmxremote/bootstrap/CustomLauncherTest.java fails intermittently with "Operation not permitted"
jbachorik
parents: 21822
diff changeset
   234
175604b1209f 8029809: sun/management/jmxremote/bootstrap/CustomLauncherTest.java fails intermittently with "Operation not permitted"
jbachorik
parents: 21822
diff changeset
   235
    private static String[] getLauncher() throws IOException {
175604b1209f 8029809: sun/management/jmxremote/bootstrap/CustomLauncherTest.java fails intermittently with "Operation not permitted"
jbachorik
parents: 21822
diff changeset
   236
        String platform = getPlatform();
175604b1209f 8029809: sun/management/jmxremote/bootstrap/CustomLauncherTest.java fails intermittently with "Operation not permitted"
jbachorik
parents: 21822
diff changeset
   237
        if (platform == null) {
175604b1209f 8029809: sun/management/jmxremote/bootstrap/CustomLauncherTest.java fails intermittently with "Operation not permitted"
jbachorik
parents: 21822
diff changeset
   238
            return null;
175604b1209f 8029809: sun/management/jmxremote/bootstrap/CustomLauncherTest.java fails intermittently with "Operation not permitted"
jbachorik
parents: 21822
diff changeset
   239
        }
175604b1209f 8029809: sun/management/jmxremote/bootstrap/CustomLauncherTest.java fails intermittently with "Operation not permitted"
jbachorik
parents: 21822
diff changeset
   240
175604b1209f 8029809: sun/management/jmxremote/bootstrap/CustomLauncherTest.java fails intermittently with "Operation not permitted"
jbachorik
parents: 21822
diff changeset
   241
        String launcher = TEST_SRC + File.separator + platform + "-" + ARCH +
175604b1209f 8029809: sun/management/jmxremote/bootstrap/CustomLauncherTest.java fails intermittently with "Operation not permitted"
jbachorik
parents: 21822
diff changeset
   242
                          File.separator + "launcher";
175604b1209f 8029809: sun/management/jmxremote/bootstrap/CustomLauncherTest.java fails intermittently with "Operation not permitted"
jbachorik
parents: 21822
diff changeset
   243
175604b1209f 8029809: sun/management/jmxremote/bootstrap/CustomLauncherTest.java fails intermittently with "Operation not permitted"
jbachorik
parents: 21822
diff changeset
   244
        final FileSystem FS = FileSystems.getDefault();
175604b1209f 8029809: sun/management/jmxremote/bootstrap/CustomLauncherTest.java fails intermittently with "Operation not permitted"
jbachorik
parents: 21822
diff changeset
   245
        Path launcherPath = FS.getPath(launcher);
175604b1209f 8029809: sun/management/jmxremote/bootstrap/CustomLauncherTest.java fails intermittently with "Operation not permitted"
jbachorik
parents: 21822
diff changeset
   246
175604b1209f 8029809: sun/management/jmxremote/bootstrap/CustomLauncherTest.java fails intermittently with "Operation not permitted"
jbachorik
parents: 21822
diff changeset
   247
        final boolean hasLauncher = Files.isRegularFile(launcherPath, LinkOption.NOFOLLOW_LINKS)&&
175604b1209f 8029809: sun/management/jmxremote/bootstrap/CustomLauncherTest.java fails intermittently with "Operation not permitted"
jbachorik
parents: 21822
diff changeset
   248
                                    Files.isReadable(launcherPath);
175604b1209f 8029809: sun/management/jmxremote/bootstrap/CustomLauncherTest.java fails intermittently with "Operation not permitted"
jbachorik
parents: 21822
diff changeset
   249
        if (!hasLauncher) {
175604b1209f 8029809: sun/management/jmxremote/bootstrap/CustomLauncherTest.java fails intermittently with "Operation not permitted"
jbachorik
parents: 21822
diff changeset
   250
            System.out.println("Launcher [" + launcher + "] does not exist. Skipping the test.");
175604b1209f 8029809: sun/management/jmxremote/bootstrap/CustomLauncherTest.java fails intermittently with "Operation not permitted"
jbachorik
parents: 21822
diff changeset
   251
            return null;
175604b1209f 8029809: sun/management/jmxremote/bootstrap/CustomLauncherTest.java fails intermittently with "Operation not permitted"
jbachorik
parents: 21822
diff changeset
   252
        }
175604b1209f 8029809: sun/management/jmxremote/bootstrap/CustomLauncherTest.java fails intermittently with "Operation not permitted"
jbachorik
parents: 21822
diff changeset
   253
175604b1209f 8029809: sun/management/jmxremote/bootstrap/CustomLauncherTest.java fails intermittently with "Operation not permitted"
jbachorik
parents: 21822
diff changeset
   254
        // It is impossible to store an executable file in the source control
175604b1209f 8029809: sun/management/jmxremote/bootstrap/CustomLauncherTest.java fails intermittently with "Operation not permitted"
jbachorik
parents: 21822
diff changeset
   255
        // We need to copy the launcher to the working directory
175604b1209f 8029809: sun/management/jmxremote/bootstrap/CustomLauncherTest.java fails intermittently with "Operation not permitted"
jbachorik
parents: 21822
diff changeset
   256
        // and set the executable flag
175604b1209f 8029809: sun/management/jmxremote/bootstrap/CustomLauncherTest.java fails intermittently with "Operation not permitted"
jbachorik
parents: 21822
diff changeset
   257
        Path localLauncherPath = FS.getPath(WORK_DIR, "launcher");
175604b1209f 8029809: sun/management/jmxremote/bootstrap/CustomLauncherTest.java fails intermittently with "Operation not permitted"
jbachorik
parents: 21822
diff changeset
   258
        Files.copy(launcherPath, localLauncherPath,
33268
8db7e6cffaf4 8138579: Custom launcher fails to start because of permission problem
jbachorik
parents: 30669
diff changeset
   259
                   StandardCopyOption.REPLACE_EXISTING);
22062
175604b1209f 8029809: sun/management/jmxremote/bootstrap/CustomLauncherTest.java fails intermittently with "Operation not permitted"
jbachorik
parents: 21822
diff changeset
   260
        if (!Files.isExecutable(localLauncherPath)) {
175604b1209f 8029809: sun/management/jmxremote/bootstrap/CustomLauncherTest.java fails intermittently with "Operation not permitted"
jbachorik
parents: 21822
diff changeset
   261
            Set<PosixFilePermission> perms = new HashSet<>(
175604b1209f 8029809: sun/management/jmxremote/bootstrap/CustomLauncherTest.java fails intermittently with "Operation not permitted"
jbachorik
parents: 21822
diff changeset
   262
                Files.getPosixFilePermissions(
175604b1209f 8029809: sun/management/jmxremote/bootstrap/CustomLauncherTest.java fails intermittently with "Operation not permitted"
jbachorik
parents: 21822
diff changeset
   263
                    localLauncherPath,
175604b1209f 8029809: sun/management/jmxremote/bootstrap/CustomLauncherTest.java fails intermittently with "Operation not permitted"
jbachorik
parents: 21822
diff changeset
   264
                    LinkOption.NOFOLLOW_LINKS
175604b1209f 8029809: sun/management/jmxremote/bootstrap/CustomLauncherTest.java fails intermittently with "Operation not permitted"
jbachorik
parents: 21822
diff changeset
   265
                )
175604b1209f 8029809: sun/management/jmxremote/bootstrap/CustomLauncherTest.java fails intermittently with "Operation not permitted"
jbachorik
parents: 21822
diff changeset
   266
            );
175604b1209f 8029809: sun/management/jmxremote/bootstrap/CustomLauncherTest.java fails intermittently with "Operation not permitted"
jbachorik
parents: 21822
diff changeset
   267
            perms.add(PosixFilePermission.OWNER_EXECUTE);
175604b1209f 8029809: sun/management/jmxremote/bootstrap/CustomLauncherTest.java fails intermittently with "Operation not permitted"
jbachorik
parents: 21822
diff changeset
   268
            Files.setPosixFilePermissions(localLauncherPath, perms);
175604b1209f 8029809: sun/management/jmxremote/bootstrap/CustomLauncherTest.java fails intermittently with "Operation not permitted"
jbachorik
parents: 21822
diff changeset
   269
        }
175604b1209f 8029809: sun/management/jmxremote/bootstrap/CustomLauncherTest.java fails intermittently with "Operation not permitted"
jbachorik
parents: 21822
diff changeset
   270
        return new String[] {launcher, localLauncherPath.toAbsolutePath().toString()};
175604b1209f 8029809: sun/management/jmxremote/bootstrap/CustomLauncherTest.java fails intermittently with "Operation not permitted"
jbachorik
parents: 21822
diff changeset
   271
    }
21367
679b312e3c5b 8004926: sun/management/jmxremote/bootstrap/CustomLauncherTest.sh oftenly times out
jbachorik
parents:
diff changeset
   272
}