Skip to content
Permalink
Browse files
Renamved GetAllThreads/allthr02 to GetAllThreadsNullTest.
  • Loading branch information
lmesnik committed Mar 12, 2021
1 parent 84f2f5e commit 7df7744e7f9628d17654cdcc22e387eaff29b57b
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 50 deletions.
@@ -24,8 +24,8 @@
/*
* @test
*
* @summary converted from VM Testbase nsk/jvmti/GetAllThreads/allthr002.
* VM Testbase keywords: [quick, jpda, jvmti, noras]
* @summary converted from VM Testbase nsk/jvmti_env/GetAllThreads/allthr002.
* VM Testbase keywords: [quick, jpda, jvmti_env, noras]
* VM Testbase readme:
* DESCRIPTION
* The test exercises JVMTI function GetAllThreads(threadsCountPtr, threadsPtr)
@@ -36,35 +36,28 @@
* Ported from JVMDI.
*
* @library /test/lib
* @run main/othervm/native -agentlib:allthr02 allthr02
* @run main/othervm/native -agentlib:GetAllThreadsNullTest GetAllThreadsNullTest
*/

import java.io.PrintStream;

public class allthr02 {

final static int JCK_STATUS_BASE = 95;
public class GetAllThreadsNullTest {

static {
try {
System.loadLibrary("allthr02");
System.loadLibrary("GetAllThreadsNullTest");
} catch (UnsatisfiedLinkError ule) {
System.err.println("Could not load allthr002 library");
System.err.println("Could not load GetAllThreadsNullTest library");
System.err.println("java.library.path:"
+ System.getProperty("java.library.path"));
throw ule;
}
}

native static int check();
native static boolean check();

public static void main(String args[]) {

// produce JCK-like exit status.
System.exit(run(args, System.out) + JCK_STATUS_BASE);
if (!check()) {
throw new RuntimeException("GetAllThreads doesn't fail if one of parameter is NULL.");
}
}

public static int run(String args[], PrintStream out) {
return check();
}
}
@@ -28,66 +28,58 @@

extern "C" {


#define PASSED 0
#define STATUS_FAILED 2

static jvmtiEnv *jvmti = NULL;
static jint result = PASSED;
static jboolean printdump = JNI_FALSE;
static jvmtiEnv *jvmti_env = NULL;

jint Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) {
jint res;

if (options != NULL && strcmp(options, "printdump") == 0) {
printdump = JNI_TRUE;
}

res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1);
if (res != JNI_OK || jvmti == NULL) {
printf("Wrong result of a valid call to GetEnv!\n");
jint res = jvm->GetEnv((void **) &jvmti_env, JVMTI_VERSION_1_1);
if (res != JNI_OK || jvmti_env == NULL) {
printf("Wrong test_passed of a valid call to GetEnv!\n");
return JNI_ERR;
}

return JNI_OK;
}

JNIEXPORT jint JNICALL
Java_allthr02_check(JNIEnv *env, jclass cls) {
JNIEXPORT jboolean JNICALL
Java_GetAllThreadsNullTest_check(JNIEnv *env, jclass cls) {
jvmtiError err;
jint threadsCountPtr;
jthread *threadsPtr;
jboolean test_passed = JNI_TRUE;

if (jvmti == NULL) {
if (jvmti_env == NULL) {
printf("JVMTI client was not properly loaded!\n");
return STATUS_FAILED;
return JNI_FALSE;
}

if (printdump == JNI_TRUE) {
printf(">>> (threadsCountPtr) null pointer check ...\n");
}
err = jvmti->GetAllThreads(NULL, &threadsPtr);
printf(">>> (threadsCountPtr) null pointer check ...\n");

err = jvmti_env->GetAllThreads(NULL, &threadsPtr);
if (err != JVMTI_ERROR_NULL_POINTER) {
printf("(threadsCountPtr) error expected: JVMTI_ERROR_NULL_POINTER,\n");
printf(" got: %s (%d)\n", TranslateError(err), err);
result = STATUS_FAILED;
test_passed = JNI_FALSE;
}

if (printdump == JNI_TRUE) {
printf(">>> (threadsPtr) null pointer check ...\n");
}
err = jvmti->GetAllThreads(&threadsCountPtr, NULL);
printf(">>> (threadsPtr) null pointer check ...\n");

err = jvmti_env->GetAllThreads(&threadsCountPtr, NULL);
if (err != JVMTI_ERROR_NULL_POINTER) {
printf("(threadsPtr) error expected: JVMTI_ERROR_NULL_POINTER,\n");
printf(" got: %s (%d)\n", TranslateError(err), err);
result = STATUS_FAILED;
test_passed = JNI_FALSE;
}

if (printdump == JNI_TRUE) {
printf(">>> done\n");
err = jvmti_env->GetAllThreads(NULL, NULL);
if (err != JVMTI_ERROR_NULL_POINTER) {
printf("(threadsPtr) error expected: JVMTI_ERROR_NULL_POINTER,\n");
printf(" got: %s (%d)\n", TranslateError(err), err);
test_passed = JNI_FALSE;
}

return result;
printf(">>> done\n");

return test_passed;
}

}

0 comments on commit 7df7744

Please sign in to comment.