43
44 import jdk.test.lib.JDKToolFinder;
45 import jdk.test.lib.process.ProcessTools;
46 import jdk.test.lib.util.JarUtils;
47 import jdk.test.lib.util.ModuleInfoWriter;
48
49 /*
50 * @test
51 * @bug 8205654
52 * @summary Unit test for sun.tools.ProcessHelper class. The test launches Java processes with different Java options
53 * and checks that sun.tools.ProcessHelper.getMainClass(pid) method returns a correct main class.
54 *
55 * @requires vm.flagless
56 * @requires os.family == "linux"
57 * @enablePreview
58 * @modules jdk.jcmd/sun.tools.common:+open
59 * java.base/jdk.internal.module
60 * @library /test/lib
61 * @build test.TestProcess
62 * jdk.test.lib.util.JarUtils
63 * jdk.test.lib.util.ModuleInfoWriter
64 * @run main/othervm TestProcessHelper
65 */
66 public class TestProcessHelper {
67
68 private static final String TEST_PROCESS_MAIN_CLASS_NAME = "TestProcess";
69 private static final String TEST_PROCESS_MAIN_CLASS_PACKAGE = "test";
70 private static final String TEST_PROCESS_MAIN_CLASS = TEST_PROCESS_MAIN_CLASS_PACKAGE + "."
71 + TEST_PROCESS_MAIN_CLASS_NAME;
72 private static final Path TEST_CLASSES = FileSystems.getDefault().getPath(System.getProperty("test.classes"));
73 private static final Path USER_DIR = FileSystems.getDefault().getPath(System.getProperty("user.dir", "."));
74 private static final Path TEST_MODULES = USER_DIR.resolve("testmodules");
75 private static final String JAVA_PATH = JDKToolFinder.getJDKTool("java");
76 private static final Path TEST_CLASS = TEST_CLASSES.resolve(TEST_PROCESS_MAIN_CLASS_PACKAGE)
77 .resolve(TEST_PROCESS_MAIN_CLASS_NAME + ".class");
78
79 private static final String[] CP_OPTIONS = {"-cp", "-classpath", "--class-path"};
80 private static final String[][] VM_ARGS = {{}, {"-Dtest1=aaa"}, {"-Dtest1=aaa", "-Dtest2=bbb ccc"}};
81 private static final String[][] ARGS = {{}, {"param1"}, {"param1", "param2"}};
82 private static final String[] MP_OPTIONS = {"-p", "--module-path"};
83 private static final String[] MODULE_OPTIONS = {"-m", "--module", "--module="};
|
43
44 import jdk.test.lib.JDKToolFinder;
45 import jdk.test.lib.process.ProcessTools;
46 import jdk.test.lib.util.JarUtils;
47 import jdk.test.lib.util.ModuleInfoWriter;
48
49 /*
50 * @test
51 * @bug 8205654
52 * @summary Unit test for sun.tools.ProcessHelper class. The test launches Java processes with different Java options
53 * and checks that sun.tools.ProcessHelper.getMainClass(pid) method returns a correct main class.
54 *
55 * @requires vm.flagless
56 * @requires os.family == "linux"
57 * @enablePreview
58 * @modules jdk.jcmd/sun.tools.common:+open
59 * java.base/jdk.internal.module
60 * @library /test/lib
61 * @build test.TestProcess
62 * jdk.test.lib.util.JarUtils
63 * @run main/othervm TestProcessHelper
64 */
65 public class TestProcessHelper {
66
67 private static final String TEST_PROCESS_MAIN_CLASS_NAME = "TestProcess";
68 private static final String TEST_PROCESS_MAIN_CLASS_PACKAGE = "test";
69 private static final String TEST_PROCESS_MAIN_CLASS = TEST_PROCESS_MAIN_CLASS_PACKAGE + "."
70 + TEST_PROCESS_MAIN_CLASS_NAME;
71 private static final Path TEST_CLASSES = FileSystems.getDefault().getPath(System.getProperty("test.classes"));
72 private static final Path USER_DIR = FileSystems.getDefault().getPath(System.getProperty("user.dir", "."));
73 private static final Path TEST_MODULES = USER_DIR.resolve("testmodules");
74 private static final String JAVA_PATH = JDKToolFinder.getJDKTool("java");
75 private static final Path TEST_CLASS = TEST_CLASSES.resolve(TEST_PROCESS_MAIN_CLASS_PACKAGE)
76 .resolve(TEST_PROCESS_MAIN_CLASS_NAME + ".class");
77
78 private static final String[] CP_OPTIONS = {"-cp", "-classpath", "--class-path"};
79 private static final String[][] VM_ARGS = {{}, {"-Dtest1=aaa"}, {"-Dtest1=aaa", "-Dtest2=bbb ccc"}};
80 private static final String[][] ARGS = {{}, {"param1"}, {"param1", "param2"}};
81 private static final String[] MP_OPTIONS = {"-p", "--module-path"};
82 private static final String[] MODULE_OPTIONS = {"-m", "--module", "--module="};
|