8179317: [TESTBUG] rewrite runtime shell tests in java
Converted shell tests to Java Reviewed-by: dholmes, iignatyev, lmesnik
This commit is contained in:
parent
03721247d8
commit
ccb4ab5499
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
#
|
||||
# This code is free software; you can redistribute it and/or modify it
|
||||
@ -880,8 +880,10 @@ endif
|
||||
ifeq ($(call isTargetOs, windows), true)
|
||||
BUILD_HOTSPOT_JTREG_EXECUTABLES_CFLAGS_exeFPRegs := -MT
|
||||
BUILD_HOTSPOT_JTREG_EXCLUDE += exesigtest.c libterminatedThread.c
|
||||
BUILD_HOTSPOT_JTREG_EXECUTABLES_LIBS_exejvm-test-launcher := jvm.lib
|
||||
|
||||
else
|
||||
BUILD_HOTSPOT_JTREG_EXECUTABLES_LIBS_exejvm-test-launcher := -ljvm
|
||||
BUILD_HOTSPOT_JTREG_LIBRARIES_LIBS_libbootclssearch_agent += -lpthread
|
||||
BUILD_HOTSPOT_JTREG_LIBRARIES_LIBS_libsystemclssearch_agent += -lpthread
|
||||
BUILD_HOTSPOT_JTREG_LIBRARIES_LIBS_libgetsysprop001 += -lpthread
|
||||
|
@ -552,7 +552,7 @@ vmTestbase_largepages = \
|
||||
vmTestbase/metaspace/stressDictionary/StressDictionary.java \
|
||||
vmTestbase/metaspace/stressHierarchy/stressHierarchy001/TestDescription.java \
|
||||
vmTestbase/metaspace/stressHierarchy/stressHierarchy011/TestDescription.java \
|
||||
vmTestbase/metaspace/flags/maxMetaspaceSize/TestDescription.java \
|
||||
vmTestbase/metaspace/flags/maxMetaspaceSize/TestMaxMetaspaceSize.java \
|
||||
vmTestbase/metaspace/shrink_grow/ShrinkGrowTest/ShrinkGrowTest.java \
|
||||
vmTestbase/metaspace/shrink_grow/ShrinkGrowMultiJVM/ShrinkGrowMultiJVM.java \
|
||||
vmTestbase/metaspace/shrink_grow/CompressedClassSpaceSize/TestDescription.java
|
||||
|
@ -1,63 +0,0 @@
|
||||
#
|
||||
# Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
#
|
||||
# This code is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License version 2 only, as
|
||||
# published by the Free Software Foundation.
|
||||
#
|
||||
# This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
# version 2 for more details (a copy is included in the LICENSE file that
|
||||
# accompanied this code).
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License version
|
||||
# 2 along with this work; if not, write to the Free Software Foundation,
|
||||
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#
|
||||
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
# or visit www.oracle.com if you need additional information or have any
|
||||
# questions.
|
||||
#
|
||||
|
||||
|
||||
# @test Test7162488.sh
|
||||
# @bug 7162488
|
||||
# @summary VM not printing unknown -XX options
|
||||
# @run shell Test7162488.sh
|
||||
#
|
||||
|
||||
if [ "${TESTSRC}" = "" ]
|
||||
then
|
||||
TESTSRC=${PWD}
|
||||
echo "TESTSRC not set. Using "${TESTSRC}" as default"
|
||||
fi
|
||||
echo "TESTSRC=${TESTSRC}"
|
||||
## Adding common setup Variables for running shell tests.
|
||||
. ${TESTSRC}/../../test_env.sh
|
||||
|
||||
JAVA=${TESTJAVA}${FS}bin${FS}java
|
||||
|
||||
#
|
||||
# Just run with an option we are confident will not be recognized,
|
||||
# and check for the message:
|
||||
#
|
||||
OPTION=this_is_not_an_option
|
||||
|
||||
${JAVA} -showversion -XX:${OPTION} 2>&1 | grep "Unrecognized VM option"
|
||||
if [ "$?" != "0" ]
|
||||
then
|
||||
printf "FAILED: option not flagged as unrecognized.\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
${JAVA} -showversion -XX:${OPTION} 2>&1 | grep ${OPTION}
|
||||
if [ "$?" != "0" ]
|
||||
then
|
||||
printf "FAILED: bad option not named as being bad.\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
printf "Passed.\n"
|
||||
|
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 7162488
|
||||
* @summary VM should print unrecognized -XX option
|
||||
* @library /test/lib
|
||||
* @run driver TestUnrecognizedVmOption
|
||||
*/
|
||||
import jdk.test.lib.process.OutputAnalyzer;
|
||||
import jdk.test.lib.process.ProcessTools;
|
||||
|
||||
public class TestUnrecognizedVmOption {
|
||||
static final String OPTION="this_is_not_an_option";
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
ProcessBuilder pb =
|
||||
ProcessTools.createJavaProcessBuilder(true, "-showversion", "-XX:" + OPTION);
|
||||
new OutputAnalyzer(pb.start())
|
||||
.shouldNotHaveExitValue(0)
|
||||
.shouldContain("Unrecognized VM option")
|
||||
.shouldContain(OPTION);
|
||||
}
|
||||
}
|
53
test/hotspot/jtreg/runtime/StackGap/TestStackGap.java
Normal file
53
test/hotspot/jtreg/runtime/StackGap/TestStackGap.java
Normal file
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @summary Linux kernel stack guard should not cause segfaults on x86-32
|
||||
* @modules java.base/jdk.internal.misc
|
||||
* @library /test/lib
|
||||
* @requires os.family == "linux"
|
||||
* @compile T.java
|
||||
* @run main/native TestStackGap
|
||||
*/
|
||||
|
||||
|
||||
import jdk.test.lib.Utils;
|
||||
import jdk.test.lib.process.ProcessTools;
|
||||
import jdk.test.lib.process.OutputAnalyzer;
|
||||
|
||||
public class TestStackGap {
|
||||
public static void main(String args[]) throws Exception {
|
||||
ProcessBuilder pb = ProcessTools.createNativeTestProcessBuilder("stack-gap");
|
||||
pb.environment().put("CLASSPATH", Utils.TEST_CLASS_PATH);
|
||||
new OutputAnalyzer(pb.start())
|
||||
.shouldHaveExitValue(0);
|
||||
|
||||
pb = ProcessTools.createNativeTestProcessBuilder("stack-gap",
|
||||
"-XX:+DisablePrimordialThreadGuardPages");
|
||||
pb.environment().put("CLASSPATH", Utils.TEST_CLASS_PATH);
|
||||
new OutputAnalyzer(pb.start())
|
||||
.shouldHaveExitValue(0);
|
||||
}
|
||||
}
|
||||
|
@ -1,49 +0,0 @@
|
||||
# Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
#
|
||||
# This code is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License version 2 only, as
|
||||
# published by the Free Software Foundation.
|
||||
#
|
||||
# This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
# version 2 for more details (a copy is included in the LICENSE file that
|
||||
# accompanied this code).
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License version
|
||||
# 2 along with this work; if not, write to the Free Software Foundation,
|
||||
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#
|
||||
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
# or visit www.oracle.com if you need additional information or have any
|
||||
# questions.
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# @test testme.sh
|
||||
# @summary Linux kernel stack guard should not cause segfaults on x86-32
|
||||
# @compile T.java
|
||||
# @run shell testme.sh
|
||||
#
|
||||
|
||||
if [ "${TESTSRC}" = "" ]
|
||||
then
|
||||
TESTSRC=${PWD}
|
||||
echo "TESTSRC not set. Using "${TESTSRC}" as default"
|
||||
fi
|
||||
echo "TESTSRC=${TESTSRC}"
|
||||
## Adding common setup Variables for running shell tests.
|
||||
. ${TESTSRC}/../../test_env.sh
|
||||
|
||||
if [ "${VM_OS}" != "linux" ]
|
||||
then
|
||||
echo "Test only valid for Linux"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
LD_LIBRARY_PATH=.:${TESTJAVA}/lib/${VM_TYPE}:/usr/lib:$LD_LIBRARY_PATH
|
||||
export LD_LIBRARY_PATH
|
||||
|
||||
${TESTNATIVEPATH}/stack-gap || exit $?
|
||||
${TESTNATIVEPATH}/stack-gap -XX:+DisablePrimordialThreadGuardPages || exit $?
|
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @summary Stack guard pages should be installed correctly and removed when thread is detached
|
||||
* @modules java.base/jdk.internal.misc
|
||||
* @library /test/lib
|
||||
* @requires os.family == "linux"
|
||||
* @compile DoOverflow.java
|
||||
* @run main/native TestStackGuardPages
|
||||
*/
|
||||
import jdk.test.lib.Utils;
|
||||
import jdk.test.lib.process.ProcessTools;
|
||||
import jdk.test.lib.process.OutputAnalyzer;
|
||||
|
||||
|
||||
public class TestStackGuardPages {
|
||||
public static void main(String args[]) throws Exception {
|
||||
ProcessBuilder pb = ProcessTools.createNativeTestProcessBuilder("invoke",
|
||||
"test_java_overflow");
|
||||
pb.environment().put("CLASSPATH", Utils.TEST_CLASS_PATH);
|
||||
new OutputAnalyzer(pb.start())
|
||||
.shouldHaveExitValue(0);
|
||||
|
||||
pb = ProcessTools.createNativeTestProcessBuilder("invoke", "test_native_overflow");
|
||||
pb.environment().put("CLASSPATH", Utils.TEST_CLASS_PATH);
|
||||
new OutputAnalyzer(pb.start())
|
||||
.shouldHaveExitValue(0);
|
||||
}
|
||||
}
|
||||
|
@ -1,51 +0,0 @@
|
||||
# Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
#
|
||||
# This code is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License version 2 only, as
|
||||
# published by the Free Software Foundation.
|
||||
#
|
||||
# This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
# version 2 for more details (a copy is included in the LICENSE file that
|
||||
# accompanied this code).
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License version
|
||||
# 2 along with this work; if not, write to the Free Software Foundation,
|
||||
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#
|
||||
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
# or visit www.oracle.com if you need additional information or have any
|
||||
# questions.
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# @test testme.sh
|
||||
# @summary Stack guard pages should be installed correctly and removed when thread is detached
|
||||
# @compile DoOverflow.java
|
||||
# @run shell testme.sh
|
||||
#
|
||||
|
||||
if [ "${TESTSRC}" = "" ]
|
||||
then
|
||||
TESTSRC=${PWD}
|
||||
echo "TESTSRC not set. Using "${TESTSRC}" as default"
|
||||
fi
|
||||
echo "TESTSRC=${TESTSRC}"
|
||||
## Adding common setup Variables for running shell tests.
|
||||
. ${TESTSRC}/../../test_env.sh
|
||||
|
||||
if [ "${VM_OS}" != "linux" ]
|
||||
then
|
||||
echo "Test only valid for Linux"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
LD_LIBRARY_PATH=.:${TESTJAVA}/lib/${VM_TYPE}:/usr/lib:$LD_LIBRARY_PATH
|
||||
export LD_LIBRARY_PATH
|
||||
|
||||
# Run the test for a java and native overflow
|
||||
${TESTNATIVEPATH}/invoke test_java_overflow
|
||||
${TESTNATIVEPATH}/invoke test_native_overflow
|
||||
exit $?
|
62
test/hotspot/jtreg/runtime/TLS/TestTLS.java
Normal file
62
test/hotspot/jtreg/runtime/TLS/TestTLS.java
Normal file
@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Copyright (c) 2019, Google Inc. All rights reserved.
|
||||
* Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @summary Test with extra TLS size.
|
||||
* @modules java.base/jdk.internal.misc
|
||||
* @library /test/lib
|
||||
* @requires os.family == "linux"
|
||||
* @compile T.java
|
||||
* @run main/native TestTLS
|
||||
*/
|
||||
import jdk.test.lib.Utils;
|
||||
import jdk.test.lib.process.ProcessTools;
|
||||
import jdk.test.lib.process.OutputAnalyzer;
|
||||
|
||||
|
||||
public class TestTLS {
|
||||
public static void main(String args[]) throws Exception {
|
||||
test01();
|
||||
}
|
||||
|
||||
// Testcase 1. Run with stack size adjusted for TLS, expect success
|
||||
public static void test01() throws Exception {
|
||||
ProcessBuilder pb = ProcessTools.createNativeTestProcessBuilder("stack-tls", "-add_tls");
|
||||
pb.environment().put("CLASSPATH", Utils.TEST_CLASS_PATH);
|
||||
new OutputAnalyzer(pb.start())
|
||||
.shouldHaveExitValue(0);
|
||||
}
|
||||
|
||||
// Testcase 2. Run with no stack size adjustment and expect failure.
|
||||
// Potential failures include StackOverflowError, thread creation failures,
|
||||
// crashes, and etc. The test case can be used to demonstrate the TLS issue
|
||||
// but is excluded from running in regular testing.
|
||||
public static void test02() throws Exception {
|
||||
ProcessBuilder pb = ProcessTools.createNativeTestProcessBuilder("stack-tls");
|
||||
pb.environment().put("CLASSPATH", Utils.TEST_CLASS_PATH);
|
||||
new OutputAnalyzer(pb.start())
|
||||
.shouldHaveExitValue(1);
|
||||
}
|
||||
}
|
@ -1,52 +0,0 @@
|
||||
# Copyright (c) 2019, Google Inc. All rights reserved.
|
||||
# Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
#
|
||||
# This code is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License version 2 only, as
|
||||
# published by the Free Software Foundation.
|
||||
#
|
||||
# This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
# version 2 for more details (a copy is included in the LICENSE file that
|
||||
# accompanied this code).
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License version
|
||||
# 2 along with this work; if not, write to the Free Software Foundation,
|
||||
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#
|
||||
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
# or visit www.oracle.com if you need additional information or have any
|
||||
# questions.
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# @test testtls.sh
|
||||
# @summary Test with extra TLS size.
|
||||
# @requires os.family == "linux"
|
||||
# @compile T.java
|
||||
# @run shell testtls.sh
|
||||
#
|
||||
|
||||
if [ "${TESTSRC}" = "" ]
|
||||
then
|
||||
TESTSRC=${PWD}
|
||||
echo "TESTSRC not set. Using "${TESTSRC}" as default"
|
||||
fi
|
||||
echo "TESTSRC=${TESTSRC}"
|
||||
## Adding common setup Variables for running shell tests.
|
||||
. ${TESTSRC}/../../test_env.sh
|
||||
|
||||
LD_LIBRARY_PATH=.:${TESTJAVA}/lib/${VM_TYPE}:/usr/lib:$LD_LIBRARY_PATH
|
||||
export LD_LIBRARY_PATH
|
||||
|
||||
# Test 1) Run with stack size adjusted for TLS
|
||||
${TESTNATIVEPATH}/stack-tls -add_tls || exit $?
|
||||
|
||||
# Test 2) Run with no stack size adjustment and expect failure.
|
||||
#
|
||||
# Potential failures include StackOverflowError, thread creation failures,
|
||||
# crashes, and etc. The test case can be used to demonstrate the TLS issue
|
||||
# but is excluded from running in regular testing.
|
||||
#${TESTNATIVEPATH}/stack-tls || exit $?
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2007, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2007, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -100,7 +100,7 @@ public class SigTestDriver {
|
||||
System.out.printf("Do execute: %s%n", cmd.toString());
|
||||
|
||||
ProcessBuilder pb = new ProcessBuilder(cmd);
|
||||
pb.environment().merge(envVar, jvmLibDir().toString(),
|
||||
pb.environment().merge(envVar, Platform.jvmLibDir().toString(),
|
||||
(x, y) -> y + File.pathSeparator + x);
|
||||
pb.environment().put("CLASSPATH", Utils.TEST_CLASS_PATH);
|
||||
|
||||
@ -143,32 +143,7 @@ public class SigTestDriver {
|
||||
}
|
||||
|
||||
private static Path libjsig() {
|
||||
return jvmLibDir().resolve((Platform.isWindows() ? "" : "lib")
|
||||
return Platform.jvmLibDir().resolve((Platform.isWindows() ? "" : "lib")
|
||||
+ "jsig." + Platform.sharedLibraryExt());
|
||||
}
|
||||
|
||||
private static Path jvmLibDir() {
|
||||
Path dir = Paths.get(Utils.TEST_JDK);
|
||||
if (Platform.isWindows()) {
|
||||
return dir.resolve("bin")
|
||||
.resolve(variant())
|
||||
.toAbsolutePath();
|
||||
} else {
|
||||
return dir.resolve("lib")
|
||||
.resolve(variant())
|
||||
.toAbsolutePath();
|
||||
}
|
||||
}
|
||||
|
||||
private static String variant() {
|
||||
if (Platform.isServer()) {
|
||||
return "server";
|
||||
} else if (Platform.isClient()) {
|
||||
return "client";
|
||||
} else if (Platform.isMinimal()) {
|
||||
return "minimal";
|
||||
} else {
|
||||
throw new Error("TESTBUG: unsupported vm variant");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -21,15 +21,8 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* @test
|
||||
*
|
||||
* @summary converted from VM Testbase metaspace/flags/maxMetaspaceSize.
|
||||
*
|
||||
* @library /vmTestbase /test/lib
|
||||
* @run driver jdk.test.lib.FileInstaller . .
|
||||
* @build metaspace.flags.maxMetaspaceSize.maxMetaspaceSize
|
||||
* @run shell maxMetaspaceSize.sh
|
||||
*/
|
||||
|
||||
public class Test {
|
||||
public static void test() {
|
||||
System.out.println ("Hello Test");
|
||||
}
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @summary Test the native process builder API.
|
||||
* @library /test/lib
|
||||
* @build Test
|
||||
* @run main/native TestNativeProcessBuilder
|
||||
*/
|
||||
|
||||
|
||||
import jdk.test.lib.Utils;
|
||||
import jdk.test.lib.process.ProcessTools;
|
||||
import jdk.test.lib.process.OutputAnalyzer;
|
||||
|
||||
public class TestNativeProcessBuilder {
|
||||
public static void main(String args[]) throws Exception {
|
||||
ProcessBuilder pb = ProcessTools.createNativeTestProcessBuilder("jvm-test-launcher");
|
||||
pb.environment().put("CLASSPATH", Utils.TEST_CLASS_PATH);
|
||||
new OutputAnalyzer(pb.start())
|
||||
.shouldHaveExitValue(0);
|
||||
}
|
||||
}
|
@ -0,0 +1,76 @@
|
||||
/*
|
||||
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
#include <jni.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
JNIEnv* create_vm(JavaVM **jvm)
|
||||
{
|
||||
JNIEnv* env;
|
||||
JavaVMInitArgs args;
|
||||
JavaVMOption options[1];
|
||||
|
||||
char classpath[4096];
|
||||
snprintf(classpath, sizeof classpath,
|
||||
"-Djava.class.path=%s", getenv("CLASSPATH"));
|
||||
options[0].optionString = classpath;
|
||||
|
||||
args.version = JNI_VERSION_1_8;
|
||||
args.nOptions = 1;
|
||||
args.options = &options[0];
|
||||
args.ignoreUnrecognized = 0;
|
||||
|
||||
int ret = JNI_CreateJavaVM(jvm, (void**)&env, &args);
|
||||
if (ret < 0)
|
||||
exit(10);
|
||||
|
||||
return env;
|
||||
}
|
||||
|
||||
|
||||
void run(JNIEnv *env) {
|
||||
jclass test_class;
|
||||
jmethodID test_method;
|
||||
|
||||
test_class = (*env)->FindClass(env, "Test");
|
||||
if (test_class == NULL)
|
||||
exit(11);
|
||||
|
||||
test_method = (*env)->GetStaticMethodID(env, test_class, "test", "()V");
|
||||
if (test_method == NULL)
|
||||
exit(12);
|
||||
|
||||
(*env)->CallStaticVoidMethod(env, test_class, test_method);
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
JavaVM *jvm;
|
||||
JNIEnv *env = create_vm(&jvm);
|
||||
|
||||
run(env);
|
||||
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* @test
|
||||
*
|
||||
* @summary converted from VM Testbase metaspace/flags/maxMetaspaceSize.
|
||||
*
|
||||
* @library /vmTestbase /test/lib
|
||||
* @build metaspace.flags.maxMetaspaceSize.maxMetaspaceSize
|
||||
* @run driver metaspace.flags.maxMetaspaceSize.TestMaxMetaspaceSize
|
||||
*/
|
||||
package metaspace.flags.maxMetaspaceSize;
|
||||
|
||||
import jdk.test.lib.process.OutputAnalyzer;
|
||||
import jdk.test.lib.process.ProcessTools;
|
||||
|
||||
public class TestMaxMetaspaceSize {
|
||||
public static void main(String[] args) throws Exception {
|
||||
ProcessBuilder pb =
|
||||
ProcessTools.createJavaProcessBuilder(true, "-XX:MaxMetaspaceSize=100m",
|
||||
maxMetaspaceSize.class.getName());
|
||||
OutputAnalyzer out = new OutputAnalyzer(pb.start());
|
||||
|
||||
if (out.getExitValue() == 0) {
|
||||
// test passed
|
||||
return;
|
||||
} else {
|
||||
System.out.println("Non-zero exit value from child process. Could be OOM, which is OK");
|
||||
out.shouldContain("Out of Memory Error");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,45 +0,0 @@
|
||||
# Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
#
|
||||
# This code is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License version 2 only, as
|
||||
# published by the Free Software Foundation.
|
||||
#
|
||||
# This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
# version 2 for more details (a copy is included in the LICENSE file that
|
||||
# accompanied this code).
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License version
|
||||
# 2 along with this work; if not, write to the Free Software Foundation,
|
||||
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#
|
||||
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
# or visit www.oracle.com if you need additional information or have any
|
||||
# questions.
|
||||
|
||||
JAVA="$TESTJAVA/bin/java"
|
||||
JAVA_OPTS="$TESTJAVAOPTS $TESTVMOPTS -cp $TESTCLASSPATH"
|
||||
|
||||
TST="metaspace.flags.maxMetaspaceSize.maxMetaspaceSize"
|
||||
echo ""
|
||||
echo "$JAVA $JAVA_OPTS -XX:MaxMetaspaceSize=100m $TST"
|
||||
echo ""
|
||||
$JAVA $JAVA_OPTS -XX:MaxMetaspaceSize=100m $TST
|
||||
res=$?
|
||||
|
||||
printf "\n\n"
|
||||
if [ $res -eq 0 ]; then
|
||||
echo Test passed
|
||||
else
|
||||
grep -s "Out of Memory Error" hs_err_pid*.log
|
||||
res2=$?
|
||||
if [ $res2 -eq 0 ]; then
|
||||
echo JAVA crashed with expected Out of Memory Error error.
|
||||
echo Test passed
|
||||
else
|
||||
echo Test failed
|
||||
exit 1
|
||||
fi
|
||||
fi
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -26,6 +26,8 @@ package jdk.test.lib;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.RandomAccessFile;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.regex.Pattern;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
@ -45,6 +47,7 @@ public class Platform {
|
||||
private static final String osArch = privilegedGetProperty("os.arch");
|
||||
private static final String userName = privilegedGetProperty("user.name");
|
||||
private static final String compiler = privilegedGetProperty("sun.management.compiler");
|
||||
private static final String testJdk = privilegedGetProperty("test.jdk");
|
||||
|
||||
private static String privilegedGetProperty(String key) {
|
||||
return AccessController.doPrivileged((
|
||||
@ -334,6 +337,35 @@ public class Platform {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns absolute path to directory containing JVM shared library.
|
||||
*/
|
||||
public static Path jvmLibDir() {
|
||||
Path dir = Paths.get(testJdk);
|
||||
if (Platform.isWindows()) {
|
||||
return dir.resolve("bin")
|
||||
.resolve(variant())
|
||||
.toAbsolutePath();
|
||||
} else {
|
||||
return dir.resolve("lib")
|
||||
.resolve(variant())
|
||||
.toAbsolutePath();
|
||||
}
|
||||
}
|
||||
|
||||
private static String variant() {
|
||||
if (Platform.isServer()) {
|
||||
return "server";
|
||||
} else if (Platform.isClient()) {
|
||||
return "client";
|
||||
} else if (Platform.isMinimal()) {
|
||||
return "minimal";
|
||||
} else {
|
||||
throw new Error("TESTBUG: unsupported vm variant");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static boolean isDefaultCDSArchiveSupported() {
|
||||
return (is64bit() &&
|
||||
isServer() &&
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -23,11 +23,13 @@
|
||||
|
||||
package jdk.test.lib.process;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.PrintStream;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
@ -45,6 +47,7 @@ import java.security.PrivilegedActionException;
|
||||
import java.security.PrivilegedExceptionAction;
|
||||
|
||||
import jdk.test.lib.JDKToolFinder;
|
||||
import jdk.test.lib.Platform;
|
||||
import jdk.test.lib.Utils;
|
||||
|
||||
public final class ProcessTools {
|
||||
@ -490,6 +493,48 @@ public final class ProcessTools {
|
||||
return analyzer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to create a process builder for launching native executable
|
||||
* test that uses/loads JVM.
|
||||
*
|
||||
* @param executableName The name of an executable to be launched.
|
||||
* @param args Arguments for the executable.
|
||||
* @return New ProcessBuilder instance representing the command.
|
||||
*/
|
||||
public static ProcessBuilder createNativeTestProcessBuilder(String executableName,
|
||||
String... args) throws Exception {
|
||||
executableName = Platform.isWindows() ? executableName + ".exe" : executableName;
|
||||
String executable = Paths.get(System.getProperty("test.nativepath"), executableName)
|
||||
.toAbsolutePath()
|
||||
.toString();
|
||||
|
||||
ProcessBuilder pb = new ProcessBuilder(executable);
|
||||
pb.command().addAll(Arrays.asList(args));
|
||||
addJvmLib(pb);
|
||||
return pb;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds JVM library path to the native library path.
|
||||
*
|
||||
* @param pb ProcessBuilder to be updated with JVM library path.
|
||||
* @return pb Update ProcessBuilder instance.
|
||||
*/
|
||||
public static ProcessBuilder addJvmLib(ProcessBuilder pb) throws Exception {
|
||||
String jvmLibDir = Platform.jvmLibDir().toString();
|
||||
String libPathVar = Platform.sharedLibraryPathVariableName();
|
||||
String currentLibPath = pb.environment().get(libPathVar);
|
||||
|
||||
String newLibPath = jvmLibDir;
|
||||
if ( (currentLibPath != null) && !currentLibPath.isEmpty() ) {
|
||||
newLibPath = currentLibPath + File.pathSeparator + jvmLibDir;
|
||||
}
|
||||
|
||||
pb.environment().put(libPathVar, newLibPath);
|
||||
|
||||
return pb;
|
||||
}
|
||||
|
||||
private static Process privilegedStart(ProcessBuilder pb) throws IOException {
|
||||
try {
|
||||
return AccessController.doPrivileged(
|
||||
|
Loading…
x
Reference in New Issue
Block a user