< prev index next >

test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/jni_interception/JI05/ji05t001/ji05t001.c

Print this page




 316         tries++;
 317         if (tries > TRIES) {
 318             NSK_COMPLAIN1("TEST FAILURE: failed to wait for the redirection in agent B after %d attempts\n",
 319                 TRIES);
 320             exit(STATUS_FAILED);
 321         }
 322     } while(redir[1] != 1);
 323 
 324     /* check the interception set in another JVMTI env */
 325     NSK_DISPLAY0("\n>>> TEST CASE #4) First JVMTI env: checking the redirection set in second JVMTI env ...\n");
 326     for (i=0; i<AGENTS; i++) {
 327         redir_calls[i] = 0;
 328     }
 329     provokeIntercept(env, "A");
 330     /* check that the previous interception has been overwritten */
 331     checkIntercept(0, 0, 1); /* expected interceptions: 1 */
 332     /* check the current interception set in another JVMTI env */
 333     checkIntercept(1, 0, 1); /* expected interceptions: 1 */
 334     NSK_DISPLAY0("\n<<< TEST CASE #4) done\n");
 335 
 336     NSK_DISPLAY1("\nagent A: returning exit code %d\n",
 337         exitCode);



 338     return exitCode;
 339 }
 340 
 341 static int agentB(void *context) {
 342     JNIEnv *env;
 343     jint res;
 344     int tries = 0;
 345     int i;
 346     int exitCode = PASSED;
 347 
 348     NSK_DISPLAY0("\nthe agent B started\n\tattaching the thread to the VM ...\n");
 349     if ((res =
 350             JNI_ENV_PTR(vm)->AttachCurrentThread(
 351                 JNI_ENV_ARG(vm, (void **) &env), (void *) 0)) != 0) {
 352         NSK_COMPLAIN1("TEST FAILURE: AttachCurrentThread() returns: %d\n",
 353             res);
 354         exit(STATUS_FAILED);
 355     }
 356 
 357     thrstarted[1] = 1;


 376     checkIntercept(0, 1, 1); /* expected interceptions: 1 */
 377     NSK_DISPLAY0("\n<<< TEST CASE #2) done\n");
 378 
 379     /* intercept the JNI function table */
 380     NSK_DISPLAY0("\n>>> TEST CASE #3) Second JVMTI env: checking the redirection set in the same env ...\n\
 381 \nagent B (second JVMTI env): redirecting the function table ...\n");
 382     doRedirect(env, jvmti[1], 1);
 383 
 384     for (i=0; i<AGENTS; i++) {
 385         redir_calls[i] = 0;
 386     }
 387     provokeIntercept(env, "B");
 388     /* check that the previous interception has been overwritten */
 389     checkIntercept(0, 1, 1); /* expected interceptions: 1 */
 390     /* check that the current interception has been set properly */
 391     checkIntercept(1, 1, 1); /* expected interceptions: 1 */
 392     NSK_DISPLAY0("\n<<< TEST CASE #3) done\n");
 393 
 394     redir[1] = 1;
 395 
 396     NSK_DISPLAY1("\nagent B: returning exit code %d\n",
 397         exitCode);



 398     return exitCode;
 399 }
 400 /*********************/
 401 
 402 /* callback functions */
 403 void JNICALL
 404 VMInitA(jvmtiEnv *jvmti_env, JNIEnv *env, jthread thread) {
 405     NSK_DISPLAY0("\nagent A: VMInit event\n");
 406 
 407     startAgent(0);
 408 }
 409 
 410 void JNICALL
 411 VMInitB(jvmtiEnv *jvmti_env, JNIEnv *env, jthread thread) {
 412     NSK_DISPLAY0("\nagent B: VMInit event\n");
 413 
 414     startAgent(1);
 415 }
 416 /*********************/
 417 




 316         tries++;
 317         if (tries > TRIES) {
 318             NSK_COMPLAIN1("TEST FAILURE: failed to wait for the redirection in agent B after %d attempts\n",
 319                 TRIES);
 320             exit(STATUS_FAILED);
 321         }
 322     } while(redir[1] != 1);
 323 
 324     /* check the interception set in another JVMTI env */
 325     NSK_DISPLAY0("\n>>> TEST CASE #4) First JVMTI env: checking the redirection set in second JVMTI env ...\n");
 326     for (i=0; i<AGENTS; i++) {
 327         redir_calls[i] = 0;
 328     }
 329     provokeIntercept(env, "A");
 330     /* check that the previous interception has been overwritten */
 331     checkIntercept(0, 0, 1); /* expected interceptions: 1 */
 332     /* check the current interception set in another JVMTI env */
 333     checkIntercept(1, 0, 1); /* expected interceptions: 1 */
 334     NSK_DISPLAY0("\n<<< TEST CASE #4) done\n");
 335 
 336     NSK_DISPLAY1("\nagent A: detaching and returning exit code %d\n",
 337         exitCode);
 338     if ((res = JNI_ENV_PTR(vm)->DetachCurrentThread(JNI_ENV_ARG1(vm))) != 0) {
 339         NSK_COMPLAIN1("TEST WARNING: agent A: DetachCurrentThread() returns: %d\n", res);
 340     }
 341     return exitCode;
 342 }
 343 
 344 static int agentB(void *context) {
 345     JNIEnv *env;
 346     jint res;
 347     int tries = 0;
 348     int i;
 349     int exitCode = PASSED;
 350 
 351     NSK_DISPLAY0("\nthe agent B started\n\tattaching the thread to the VM ...\n");
 352     if ((res =
 353             JNI_ENV_PTR(vm)->AttachCurrentThread(
 354                 JNI_ENV_ARG(vm, (void **) &env), (void *) 0)) != 0) {
 355         NSK_COMPLAIN1("TEST FAILURE: AttachCurrentThread() returns: %d\n",
 356             res);
 357         exit(STATUS_FAILED);
 358     }
 359 
 360     thrstarted[1] = 1;


 379     checkIntercept(0, 1, 1); /* expected interceptions: 1 */
 380     NSK_DISPLAY0("\n<<< TEST CASE #2) done\n");
 381 
 382     /* intercept the JNI function table */
 383     NSK_DISPLAY0("\n>>> TEST CASE #3) Second JVMTI env: checking the redirection set in the same env ...\n\
 384 \nagent B (second JVMTI env): redirecting the function table ...\n");
 385     doRedirect(env, jvmti[1], 1);
 386 
 387     for (i=0; i<AGENTS; i++) {
 388         redir_calls[i] = 0;
 389     }
 390     provokeIntercept(env, "B");
 391     /* check that the previous interception has been overwritten */
 392     checkIntercept(0, 1, 1); /* expected interceptions: 1 */
 393     /* check that the current interception has been set properly */
 394     checkIntercept(1, 1, 1); /* expected interceptions: 1 */
 395     NSK_DISPLAY0("\n<<< TEST CASE #3) done\n");
 396 
 397     redir[1] = 1;
 398 
 399     NSK_DISPLAY1("\nagent B: detaching and returning exit code %d\n",
 400         exitCode);
 401     if ((res = JNI_ENV_PTR(vm)->DetachCurrentThread(JNI_ENV_ARG1(vm))) != 0) {
 402         NSK_COMPLAIN1("TEST WARNING: agent B: DetachCurrentThread() returns: %d\n", res);
 403     }
 404     return exitCode;
 405 }
 406 /*********************/
 407 
 408 /* callback functions */
 409 void JNICALL
 410 VMInitA(jvmtiEnv *jvmti_env, JNIEnv *env, jthread thread) {
 411     NSK_DISPLAY0("\nagent A: VMInit event\n");
 412 
 413     startAgent(0);
 414 }
 415 
 416 void JNICALL
 417 VMInitB(jvmtiEnv *jvmti_env, JNIEnv *env, jthread thread) {
 418     NSK_DISPLAY0("\nagent B: VMInit event\n");
 419 
 420     startAgent(1);
 421 }
 422 /*********************/
 423 


< prev index next >