1 /* 2 * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 25 /* 26 * Methods and definitions common to docker tests container in this directory 27 */ 28 29 import java.nio.file.Files; 30 import java.nio.file.Paths; 31 import jdk.test.lib.containers.docker.DockerRunOptions; 32 import jdk.test.lib.containers.docker.DockerTestUtils; 33 import jdk.test.lib.Utils; 34 import jdk.test.lib.process.OutputAnalyzer; 35 36 37 public class Common { 38 public static final String imageNameAndTag = "jdk-internal:test"; 39 40 public static String imageName(String suffix) { 41 return imageNameAndTag + "-" + suffix; 42 } 43 44 45 public static void prepareWhiteBox() throws Exception { 46 Files.copy(Paths.get(ClassFileInstaller.getJarPath("whitebox.jar")), 47 Paths.get(Utils.TEST_CLASSES, "whitebox.jar")); 48 } 49 50 51 // create simple commonly used options 52 public static DockerRunOptions newOpts(String imageNameAndTag) { 53 return new DockerRunOptions(imageNameAndTag, "/jdk/bin/java", "-version") 54 .addJavaOpts("-Xlog:os+container=trace"); 55 } 56 57 58 // create commonly used options with class to be launched inside container 59 public static DockerRunOptions newOpts(String imageNameAndTag, String testClass) { 60 DockerRunOptions opts = 61 new DockerRunOptions(imageNameAndTag, "/jdk/bin/java", testClass); 62 opts.addDockerOpts("--volume", Utils.TEST_CLASSES + ":/test-classes/"); 63 opts.addJavaOpts("-Xlog:os+container=trace", "-cp", "/test-classes/"); 64 return opts; 65 } 66 | 1 /* 2 * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 package jdk.test.lib.containers.docker; 25 26 /* 27 * Methods and definitions common to docker tests container in this directory 28 */ 29 30 import java.io.File; 31 import java.nio.file.Files; 32 import java.nio.file.Paths; 33 import jdk.test.lib.containers.docker.DockerRunOptions; 34 import jdk.test.lib.containers.docker.DockerTestUtils; 35 import jdk.test.lib.Utils; 36 import jdk.test.lib.process.OutputAnalyzer; 37 38 39 public class Common { 40 public static final String imageNameAndTag = "jdk-internal:test"; 41 42 public static String imageName(String suffix) { 43 return imageNameAndTag + "-" + suffix; 44 } 45 46 47 public static void prepareWhiteBox() throws Exception { 48 Files.copy(Paths.get(new File("whitebox.jar").getAbsolutePath()), 49 Paths.get(Utils.TEST_CLASSES, "whitebox.jar")); 50 } 51 52 53 // create simple commonly used options 54 public static DockerRunOptions newOpts(String imageNameAndTag) { 55 return new DockerRunOptions(imageNameAndTag, "/jdk/bin/java", "-version") 56 .addJavaOpts("-Xlog:os+container=trace"); 57 } 58 59 60 // create commonly used options with class to be launched inside container 61 public static DockerRunOptions newOpts(String imageNameAndTag, String testClass) { 62 DockerRunOptions opts = 63 new DockerRunOptions(imageNameAndTag, "/jdk/bin/java", testClass); 64 opts.addDockerOpts("--volume", Utils.TEST_CLASSES + ":/test-classes/"); 65 opts.addJavaOpts("-Xlog:os+container=trace", "-cp", "/test-classes/"); 66 return opts; 67 } 68 |