Path: blob/master/test/hotspot/jtreg/testlibrary_tests/ctw/JarDirTest.java
40942 views
/*1* Copyright (c) 2013, 2021, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/*24* @test25* @bug 801244726* @library /test/lib /testlibrary/ctw/src27* @modules java.base/jdk.internal.access28* java.base/jdk.internal.jimage29* java.base/jdk.internal.misc30* java.base/jdk.internal.reflect31* java.compiler32* java.management33* jdk.internal.jvmstat/sun.jvmstat.monitor34* @build sun.hotspot.WhiteBox Foo Bar35* @run driver jdk.test.lib.helpers.ClassFileInstaller sun.hotspot.WhiteBox Foo Bar36* @run driver JarDirTest prepare37* @run driver JarDirTest compile jars/*38* @run driver JarDirTest check39* @summary testing of CompileTheWorld :: jars in directory40* @author [email protected]41*/4243import java.io.File;44import java.nio.file.Files;45import java.nio.file.Paths;4647import jdk.test.lib.process.OutputAnalyzer;4849public class JarDirTest extends CtwTest {50private static final String[] SHOULD_CONTAIN51= {"# jar_in_dir: jars",52"# jar: jars" + File.separator +"foo.jar",53"# jar: jars" + File.separator +"bar.jar",54"Done (4 classes, 12 methods, "};5556private JarDirTest() {57super(SHOULD_CONTAIN);58}5960public static void main(String[] args) throws Exception {61new JarDirTest().run(args);62}6364protected void prepare() throws Exception {65String path = "jars";66Files.createDirectory(Paths.get(path));6768ProcessBuilder pb = createJarProcessBuilder("cf", "jars/foo.jar",69"Foo.class", "Bar.class");70OutputAnalyzer output = new OutputAnalyzer(pb.start());71dump(output, "ctw-foo.jar");72output.shouldHaveExitValue(0);7374pb = createJarProcessBuilder("cf", "jars/bar.jar", "Foo.class",75"Bar.class");76output = new OutputAnalyzer(pb.start());77dump(output, "ctw-bar.jar");78output.shouldHaveExitValue(0);79}8081}828384