hotspot/test/testlibrary_tests/ctw/JarDirTest.java
author ctornqvi
Fri, 19 Aug 2016 10:06:30 -0400
changeset 40631 ed82623d7831
parent 40048 7e816aed8ba8
child 43414 bd9a5a9dc9bc
permissions -rw-r--r--
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder Reviewed-by: coleenp, gtriantafill, mseledtsov, iignatyev, dholmes, dsamersoff
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
26915
ba674d5d0f77 8025606: [TESTBUG] Move ctw-tests to /testlibrary_tests
vlivanov
parents:
diff changeset
     1
/*
36209
8db2a78cbc29 8151156: [TESTBUG] Integrate trivial Hotspot test changes from Jake before Jigsaw M3
ctornqvi
parents: 33730
diff changeset
     2
 * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
26915
ba674d5d0f77 8025606: [TESTBUG] Move ctw-tests to /testlibrary_tests
vlivanov
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
ba674d5d0f77 8025606: [TESTBUG] Move ctw-tests to /testlibrary_tests
vlivanov
parents:
diff changeset
     4
 *
ba674d5d0f77 8025606: [TESTBUG] Move ctw-tests to /testlibrary_tests
vlivanov
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
ba674d5d0f77 8025606: [TESTBUG] Move ctw-tests to /testlibrary_tests
vlivanov
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
ba674d5d0f77 8025606: [TESTBUG] Move ctw-tests to /testlibrary_tests
vlivanov
parents:
diff changeset
     7
 * published by the Free Software Foundation.
ba674d5d0f77 8025606: [TESTBUG] Move ctw-tests to /testlibrary_tests
vlivanov
parents:
diff changeset
     8
 *
ba674d5d0f77 8025606: [TESTBUG] Move ctw-tests to /testlibrary_tests
vlivanov
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
ba674d5d0f77 8025606: [TESTBUG] Move ctw-tests to /testlibrary_tests
vlivanov
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ba674d5d0f77 8025606: [TESTBUG] Move ctw-tests to /testlibrary_tests
vlivanov
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
ba674d5d0f77 8025606: [TESTBUG] Move ctw-tests to /testlibrary_tests
vlivanov
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
ba674d5d0f77 8025606: [TESTBUG] Move ctw-tests to /testlibrary_tests
vlivanov
parents:
diff changeset
    13
 * accompanied this code).
ba674d5d0f77 8025606: [TESTBUG] Move ctw-tests to /testlibrary_tests
vlivanov
parents:
diff changeset
    14
 *
ba674d5d0f77 8025606: [TESTBUG] Move ctw-tests to /testlibrary_tests
vlivanov
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
ba674d5d0f77 8025606: [TESTBUG] Move ctw-tests to /testlibrary_tests
vlivanov
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
ba674d5d0f77 8025606: [TESTBUG] Move ctw-tests to /testlibrary_tests
vlivanov
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
ba674d5d0f77 8025606: [TESTBUG] Move ctw-tests to /testlibrary_tests
vlivanov
parents:
diff changeset
    18
 *
ba674d5d0f77 8025606: [TESTBUG] Move ctw-tests to /testlibrary_tests
vlivanov
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ba674d5d0f77 8025606: [TESTBUG] Move ctw-tests to /testlibrary_tests
vlivanov
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
ba674d5d0f77 8025606: [TESTBUG] Move ctw-tests to /testlibrary_tests
vlivanov
parents:
diff changeset
    21
 * questions.
ba674d5d0f77 8025606: [TESTBUG] Move ctw-tests to /testlibrary_tests
vlivanov
parents:
diff changeset
    22
 */
ba674d5d0f77 8025606: [TESTBUG] Move ctw-tests to /testlibrary_tests
vlivanov
parents:
diff changeset
    23
ba674d5d0f77 8025606: [TESTBUG] Move ctw-tests to /testlibrary_tests
vlivanov
parents:
diff changeset
    24
/*
ba674d5d0f77 8025606: [TESTBUG] Move ctw-tests to /testlibrary_tests
vlivanov
parents:
diff changeset
    25
 * @test
ba674d5d0f77 8025606: [TESTBUG] Move ctw-tests to /testlibrary_tests
vlivanov
parents:
diff changeset
    26
 * @bug 8012447
40631
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 40048
diff changeset
    27
 * @library /test/lib /testlibrary/ctw/src
40048
7e816aed8ba8 8160773: error: package jdk.internal.jimage does not exist
tpivovarova
parents: 38121
diff changeset
    28
 * @modules java.base/jdk.internal.jimage
7e816aed8ba8 8160773: error: package jdk.internal.jimage does not exist
tpivovarova
parents: 38121
diff changeset
    29
 *          java.base/jdk.internal.misc
38121
b9649af838e0 8155034: [TESTBUG] ctw tests fail to compile: module reads package sun.reflect from both jdk.unsupported and java.base
ppunegov
parents: 36209
diff changeset
    30
 *          java.base/jdk.internal.reflect
29678
dd2f3932c21e 8075586: Add @modules as needed to the open hotspot tests
ykantser
parents: 28190
diff changeset
    31
 *          java.compiler
dd2f3932c21e 8075586: Add @modules as needed to the open hotspot tests
ykantser
parents: 28190
diff changeset
    32
 *          java.management
dd2f3932c21e 8075586: Add @modules as needed to the open hotspot tests
ykantser
parents: 28190
diff changeset
    33
 *          jdk.jvmstat/sun.jvmstat.monitor
40631
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 40048
diff changeset
    34
 * @build sun.hotspot.WhiteBox Foo Bar
26915
ba674d5d0f77 8025606: [TESTBUG] Move ctw-tests to /testlibrary_tests
vlivanov
parents:
diff changeset
    35
 * @run main ClassFileInstaller sun.hotspot.WhiteBox Foo Bar
ba674d5d0f77 8025606: [TESTBUG] Move ctw-tests to /testlibrary_tests
vlivanov
parents:
diff changeset
    36
 *                              sun.hotspot.WhiteBox$WhiteBoxPermission
ba674d5d0f77 8025606: [TESTBUG] Move ctw-tests to /testlibrary_tests
vlivanov
parents:
diff changeset
    37
 * @run main JarDirTest prepare
ba674d5d0f77 8025606: [TESTBUG] Move ctw-tests to /testlibrary_tests
vlivanov
parents:
diff changeset
    38
 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Dsun.hotspot.tools.ctw.logfile=ctw.log sun.hotspot.tools.ctw.CompileTheWorld jars/*
ba674d5d0f77 8025606: [TESTBUG] Move ctw-tests to /testlibrary_tests
vlivanov
parents:
diff changeset
    39
 * @run main JarDirTest check ctw.log
ba674d5d0f77 8025606: [TESTBUG] Move ctw-tests to /testlibrary_tests
vlivanov
parents:
diff changeset
    40
 * @summary testing of CompileTheWorld :: jars in directory
ba674d5d0f77 8025606: [TESTBUG] Move ctw-tests to /testlibrary_tests
vlivanov
parents:
diff changeset
    41
 * @author igor.ignatyev@oracle.com
ba674d5d0f77 8025606: [TESTBUG] Move ctw-tests to /testlibrary_tests
vlivanov
parents:
diff changeset
    42
 */
ba674d5d0f77 8025606: [TESTBUG] Move ctw-tests to /testlibrary_tests
vlivanov
parents:
diff changeset
    43
ba674d5d0f77 8025606: [TESTBUG] Move ctw-tests to /testlibrary_tests
vlivanov
parents:
diff changeset
    44
import java.io.File;
ba674d5d0f77 8025606: [TESTBUG] Move ctw-tests to /testlibrary_tests
vlivanov
parents:
diff changeset
    45
import java.nio.file.Files;
ba674d5d0f77 8025606: [TESTBUG] Move ctw-tests to /testlibrary_tests
vlivanov
parents:
diff changeset
    46
import java.nio.file.Paths;
ba674d5d0f77 8025606: [TESTBUG] Move ctw-tests to /testlibrary_tests
vlivanov
parents:
diff changeset
    47
40631
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 40048
diff changeset
    48
import jdk.test.lib.process.OutputAnalyzer;
26915
ba674d5d0f77 8025606: [TESTBUG] Move ctw-tests to /testlibrary_tests
vlivanov
parents:
diff changeset
    49
ba674d5d0f77 8025606: [TESTBUG] Move ctw-tests to /testlibrary_tests
vlivanov
parents:
diff changeset
    50
public class JarDirTest extends CtwTest {
ba674d5d0f77 8025606: [TESTBUG] Move ctw-tests to /testlibrary_tests
vlivanov
parents:
diff changeset
    51
    private static final String[] SHOULD_CONTAIN
ba674d5d0f77 8025606: [TESTBUG] Move ctw-tests to /testlibrary_tests
vlivanov
parents:
diff changeset
    52
            = {"# jar_in_dir: jars",
ba674d5d0f77 8025606: [TESTBUG] Move ctw-tests to /testlibrary_tests
vlivanov
parents:
diff changeset
    53
                    "# jar: jars" + File.separator +"foo.jar",
ba674d5d0f77 8025606: [TESTBUG] Move ctw-tests to /testlibrary_tests
vlivanov
parents:
diff changeset
    54
                    "# jar: jars" + File.separator +"bar.jar",
ba674d5d0f77 8025606: [TESTBUG] Move ctw-tests to /testlibrary_tests
vlivanov
parents:
diff changeset
    55
                    "Done (4 classes, 12 methods, "};
ba674d5d0f77 8025606: [TESTBUG] Move ctw-tests to /testlibrary_tests
vlivanov
parents:
diff changeset
    56
ba674d5d0f77 8025606: [TESTBUG] Move ctw-tests to /testlibrary_tests
vlivanov
parents:
diff changeset
    57
    private JarDirTest() {
ba674d5d0f77 8025606: [TESTBUG] Move ctw-tests to /testlibrary_tests
vlivanov
parents:
diff changeset
    58
        super(SHOULD_CONTAIN);
ba674d5d0f77 8025606: [TESTBUG] Move ctw-tests to /testlibrary_tests
vlivanov
parents:
diff changeset
    59
    }
ba674d5d0f77 8025606: [TESTBUG] Move ctw-tests to /testlibrary_tests
vlivanov
parents:
diff changeset
    60
ba674d5d0f77 8025606: [TESTBUG] Move ctw-tests to /testlibrary_tests
vlivanov
parents:
diff changeset
    61
    public static void main(String[] args) throws Exception {
ba674d5d0f77 8025606: [TESTBUG] Move ctw-tests to /testlibrary_tests
vlivanov
parents:
diff changeset
    62
        new JarDirTest().run(args);
ba674d5d0f77 8025606: [TESTBUG] Move ctw-tests to /testlibrary_tests
vlivanov
parents:
diff changeset
    63
    }
ba674d5d0f77 8025606: [TESTBUG] Move ctw-tests to /testlibrary_tests
vlivanov
parents:
diff changeset
    64
ba674d5d0f77 8025606: [TESTBUG] Move ctw-tests to /testlibrary_tests
vlivanov
parents:
diff changeset
    65
    protected void prepare() throws Exception {
ba674d5d0f77 8025606: [TESTBUG] Move ctw-tests to /testlibrary_tests
vlivanov
parents:
diff changeset
    66
        String path = "jars";
ba674d5d0f77 8025606: [TESTBUG] Move ctw-tests to /testlibrary_tests
vlivanov
parents:
diff changeset
    67
        Files.createDirectory(Paths.get(path));
ba674d5d0f77 8025606: [TESTBUG] Move ctw-tests to /testlibrary_tests
vlivanov
parents:
diff changeset
    68
ba674d5d0f77 8025606: [TESTBUG] Move ctw-tests to /testlibrary_tests
vlivanov
parents:
diff changeset
    69
        ProcessBuilder pb = createJarProcessBuilder("cf", "jars/foo.jar",
ba674d5d0f77 8025606: [TESTBUG] Move ctw-tests to /testlibrary_tests
vlivanov
parents:
diff changeset
    70
                "Foo.class", "Bar.class");
ba674d5d0f77 8025606: [TESTBUG] Move ctw-tests to /testlibrary_tests
vlivanov
parents:
diff changeset
    71
        OutputAnalyzer output = new OutputAnalyzer(pb.start());
ba674d5d0f77 8025606: [TESTBUG] Move ctw-tests to /testlibrary_tests
vlivanov
parents:
diff changeset
    72
        dump(output, "ctw-foo.jar");
ba674d5d0f77 8025606: [TESTBUG] Move ctw-tests to /testlibrary_tests
vlivanov
parents:
diff changeset
    73
        output.shouldHaveExitValue(0);
ba674d5d0f77 8025606: [TESTBUG] Move ctw-tests to /testlibrary_tests
vlivanov
parents:
diff changeset
    74
ba674d5d0f77 8025606: [TESTBUG] Move ctw-tests to /testlibrary_tests
vlivanov
parents:
diff changeset
    75
        pb = createJarProcessBuilder("cf", "jars/bar.jar", "Foo.class",
ba674d5d0f77 8025606: [TESTBUG] Move ctw-tests to /testlibrary_tests
vlivanov
parents:
diff changeset
    76
                "Bar.class");
ba674d5d0f77 8025606: [TESTBUG] Move ctw-tests to /testlibrary_tests
vlivanov
parents:
diff changeset
    77
        output = new OutputAnalyzer(pb.start());
ba674d5d0f77 8025606: [TESTBUG] Move ctw-tests to /testlibrary_tests
vlivanov
parents:
diff changeset
    78
        dump(output, "ctw-bar.jar");
ba674d5d0f77 8025606: [TESTBUG] Move ctw-tests to /testlibrary_tests
vlivanov
parents:
diff changeset
    79
        output.shouldHaveExitValue(0);
ba674d5d0f77 8025606: [TESTBUG] Move ctw-tests to /testlibrary_tests
vlivanov
parents:
diff changeset
    80
    }
ba674d5d0f77 8025606: [TESTBUG] Move ctw-tests to /testlibrary_tests
vlivanov
parents:
diff changeset
    81
ba674d5d0f77 8025606: [TESTBUG] Move ctw-tests to /testlibrary_tests
vlivanov
parents:
diff changeset
    82
}