8178507: co-locate nsk.regression.gc tests

Convert four tonga tests into jtreg

Reviewed-by: lmesnik, iignatyev
This commit is contained in:
Alexander Harlap 2017-06-29 14:35:30 -04:00
parent 77bc4e75e3
commit e515046a32
8 changed files with 371 additions and 0 deletions

View File

@ -45,6 +45,7 @@ $(eval $(call IncludeCustomExtension, hotspot, test/JtregNative.gmk))
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 \

View File

@ -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!");
}
}

View File

@ -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;
}
}
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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;
}
}
}
}

View File

@ -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();
}

View File

@ -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;
}