8178507: co-locate nsk.regression.gc tests
Summary: convert four tonga tests into jtreg
Reviewed-by: lmesnik, iignatyev
--- a/hotspot/make/test/JtregNative.gmk Fri Jun 23 09:25:27 2017 +0800
+++ b/hotspot/make/test/JtregNative.gmk Thu Jun 29 14:35:30 2017 -0400
@@ -45,6 +45,7 @@
BUILD_HOTSPOT_JTREG_NATIVE_SRC += \
$(HOTSPOT_TOPDIR)/test/gc/g1/TestJNIWeakG1 \
$(HOTSPOT_TOPDIR)/test/gc/stress/gclocker \
+ $(HOTSPOT_TOPDIR)/test/gc/cslocker \
$(HOTSPOT_TOPDIR)/test/native_sanity \
$(HOTSPOT_TOPDIR)/test/runtime/jni/8025979 \
$(HOTSPOT_TOPDIR)/test/runtime/jni/8033445 \
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/gc/TestFullGCALot.java Thu Jun 29 14:35:30 2017 -0400
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2017 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 TestFullGCALot
+ * @key gc
+ * @bug 4187687
+ * @summary Ensure no acess violation when using FullGCALot
+ * @requires vm.debug
+ * @run main/othervm -XX:+FullGCALot -XX:FullGCALotInterval=120 TestFullGCALot
+ */
+
+public class TestFullGCALot {
+
+ public static void main(String argv[]) {
+ System.out.println("Hello world!");
+ }
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/gc/TestMemoryInitialization.java Thu Jun 29 14:35:30 2017 -0400
@@ -0,0 +1,46 @@
+
+/*
+ * Copyright (c) 2002, 2017 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 TestMemoryInitialization
+ * bug 4668531
+ * Simple test for -XX:+CheckMemoryInitialization doesn't crash VM
+ */
+
+public class TestMemoryInitialization {
+ final static int LOOP_LENGTH = 10;
+ final static int CHUNK_SIZE = 1500000;
+
+ public static byte[] buffer;
+
+ public static void main(String args[]) {
+
+ for (int i = 0; i < LOOP_LENGTH; i++) {
+ for (int j = 0; j < LOOP_LENGTH; j++) {
+ buffer = new byte[CHUNK_SIZE];
+ buffer = null;
+ }
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/gc/TestMemoryInitializationWithCMS.java Thu Jun 29 14:35:30 2017 -0400
@@ -0,0 +1,39 @@
+
+/*
+ * Copyright (c) 2002, 2017 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 TestMemoryInitializationWithCMS
+ * @key gc
+ * @bug 4668531
+ * @requires vm.debug & vm.gc.ConcMarkSweep
+ * @summary Simple test for -XX:+CheckMemoryInitialization doesn't crash VM
+ * @run main/othervm -XX:+UseConcMarkSweepGC -XX:+CheckMemoryInitialization TestMemoryInitializationWithCMS
+ */
+
+public class TestMemoryInitializationWithCMS {
+
+ public static void main(String args[]) {
+ TestMemoryInitialization.main(args);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/gc/TestMemoryInitializationWithSerial.java Thu Jun 29 14:35:30 2017 -0400
@@ -0,0 +1,39 @@
+
+/*
+ * Copyright (c) 2002, 2017 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 TestMemoryInitializationWithSerial`
+ * @key gc
+ * @bug 4668531
+ * @requires vm.debug & vm.gc.Serial
+ * @summary Simple test for -XX:+CheckMemoryInitialization doesn't crash VM
+ * @run main/othervm -XX:+UseSerialGC -XX:+CheckMemoryInitialization TestMemoryInitializationWithSerial
+ */
+
+public class TestMemoryInitializationWithSerial {
+
+ public static void main(String args[]) {
+ TestMemoryInitialization.main(args);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/gc/TestStackOverflow.java Thu Jun 29 14:35:30 2017 -0400
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2002, 2017 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 TestStackOverflow
+ * @key gc
+ * @bug 4396719
+ * @summary Test verifies only that VM doesn't crash but throw expected Error.
+ * @run main/othervm TestStackOverflow
+ */
+
+public class TestStackOverflow {
+ final static int LOOP_LENGTH = 1000000;
+ final static int LOGGING_STEP = 10000;
+
+ public static void main(String args[]) {
+ Object object = null;
+
+ for (int i = 0; i < LOOP_LENGTH; i++) {
+
+ // Check progress
+ if (i % LOGGING_STEP == 0) {
+ System.out.println(i);
+ }
+ try {
+ Object array[] = {object, object, object, object, object};
+ object = array;
+ } catch (OutOfMemoryError e) {
+ object = null;
+ System.out.println("Caught OutOfMemoryError.");
+ return;
+ } catch (StackOverflowError e) {
+ object = null;
+ System.out.println("Caught StackOverflowError.");
+ return;
+ }
+ }
+ }
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/gc/cslocker/TestCSLocker.java Thu Jun 29 14:35:30 2017 -0400
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 2007, 2017 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 TestCSLocker
+ * @key gc
+ * @bug 6186200
+ * @summary This short test check RFE 6186200 changes. One thread locked
+ * @summary completely in JNI CS, while other is trying to allocate memory
+ * @summary provoking GC. OOM means FAIL, deadlock means PASS.
+ * @run main/native/othervm -Xmx256m TestCSLocker
+ */
+
+public class TestCSLocker extends Thread
+{
+ static int timeout = 5000;
+ public static void main(String args[]) throws Exception {
+ long startTime = System.currentTimeMillis();
+
+ // start garbage producer thread
+ GarbageProducer garbageProducer = new GarbageProducer(1000000, 10);
+ garbageProducer.start();
+
+ // start CS locker thread
+ CSLocker csLocker = new CSLocker();
+ csLocker.start();
+
+ // check timeout to success deadlocking
+ while(System.currentTimeMillis() < startTime + timeout) {
+ System.out.println("sleeping...");
+ sleep(1000);
+ }
+
+ csLocker.unlock();
+ garbageProducer.interrupt();
+ }
+}
+
+class GarbageProducer extends Thread
+{
+ private int size;
+ private int sleepTime;
+
+ GarbageProducer(int size, int sleepTime) {
+ this.size = size;
+ this.sleepTime = sleepTime;
+ }
+
+ public void run() {
+ boolean isRunning = true;
+
+ while (isRunning) {
+ try {
+ int[] arr = null;
+ arr = new int[size];
+ sleep(sleepTime);
+ } catch (InterruptedException e) {
+ isRunning = false;
+ }
+ }
+ }
+}
+
+class CSLocker extends Thread
+{
+ static { System.loadLibrary("TestCSLocker"); }
+
+ public void run() {
+ int[] a = new int[10];
+ a[0] = 1;
+ if (!lock(a)) {
+ throw new RuntimeException("failed to acquire CSLock");
+ }
+ }
+
+ native boolean lock(int[] array);
+ native void unlock();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/gc/cslocker/libTestCSLocker.c Thu Jun 29 14:35:30 2017 -0400
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2007, 2017 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>
+
+static volatile int release_critical = 0;
+
+JNIEXPORT jboolean JNICALL Java_CSLocker_lock
+ (JNIEnv *env, jobject obj, jintArray array)
+{
+ jboolean retval = JNI_TRUE;
+ void *nativeArray = (*env)->GetPrimitiveArrayCritical(env, array, 0);
+
+ if (nativeArray == NULL) {
+ retval = JNI_FALSE;
+ }
+
+ // deadblock
+ while (!release_critical) /* empty */;
+
+ (*env)->ReleasePrimitiveArrayCritical(env, array, nativeArray, 0);
+ return retval;
+}
+
+JNIEXPORT void JNICALL Java_CSLocker_unlock
+ (JNIEnv *env, jobject obj)
+{
+ release_critical = 1;
+}