< prev index next >

test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetEnvironmentLocalStorage/setenvstor001/setenvstor001.cpp

Print this page
rev 52100 : 8212082: Remove the NSK_CPP_STUB macros for remaining vmTestbase/jvmti/[sS]*
Summary:
Reviewed-by:


  56 static StorageStructure storageData;
  57 static StorageStructure* initialStorage = &storageData;
  58 
  59 /* ============================================================================= */
  60 
  61 /** Fill storage data with given char */
  62 static void fillEnvStorage(StorageStructure* storage) {
  63     NSK_DISPLAY2("Fill storage data with char %c for size: %d bytes\n",
  64                 (char)STORAGE_DATA_CHAR, (int)STORAGE_DATA_SIZE);
  65     memset(storage->data, STORAGE_DATA_CHAR, STORAGE_DATA_SIZE);
  66     NSK_DISPLAY0("  ... ok\n");
  67 }
  68 
  69 /**
  70  * Set JVMTI environment local storage with given pinter.
  71  * @returns NSK_FALSE if any error occured.
  72  */
  73 static int setEnvStorage(jvmtiEnv* jvmti, StorageStructure* storage, const char where[]) {
  74 
  75     NSK_DISPLAY1("Set local storage for current JVMTI env: 0x%p\n", (void*)storage);
  76     if (!NSK_JVMTI_VERIFY(
  77             NSK_CPP_STUB2(SetEnvironmentLocalStorage, jvmti, storage))) {
  78         return NSK_FALSE;
  79     }
  80     NSK_DISPLAY0("  ... ok\n");
  81     return NSK_TRUE;
  82 }
  83 
  84 /**
  85  * Check JVMTI environment local storage.
  86  * @returns NSK_FALSE if any error occured.
  87  */
  88 static int checkEnvStorage(jvmtiEnv* jvmti, StorageStructure* initialStorage, const char where[]) {
  89     StorageStructure* storage = NULL;
  90 
  91     NSK_DISPLAY0("Get local storage for current JVMTI env\n");
  92     if (!NSK_JVMTI_VERIFY(
  93             NSK_CPP_STUB2(GetEnvironmentLocalStorage, jvmti, (void**)&storage))) {
  94         return NSK_FALSE;
  95     }
  96     NSK_DISPLAY1("  ... got storage: 0x%p\n", (void*)storage);
  97 
  98     if (storage != initialStorage) {
  99         NSK_COMPLAIN3("Wrong storage pointer returned for current JVMTI env in %s:\n"
 100                       "#   got pointer: %p\n"
 101                       "#   expected:    %p\n",
 102                         where,
 103                         (void*)storage, (void*)initialStorage);
 104         return NSK_FALSE;
 105     }
 106 
 107     {
 108         int changed = 0;
 109         int i;
 110 
 111         for (i = 0; i < STORAGE_DATA_SIZE; i++) {
 112             if (storage->data[i] != STORAGE_DATA_CHAR) {
 113                 changed++;


 199 }
 200 #endif
 201 jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
 202     jvmtiEnv* jvmti = NULL;
 203 
 204     if (!NSK_VERIFY(nsk_jvmti_parseOptions(options)))
 205         return JNI_ERR;
 206 
 207     timeout = nsk_jvmti_getWaitTime() * 60 * 1000;
 208 
 209     if (!NSK_VERIFY((jvmti =
 210             nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL))
 211         return JNI_ERR;
 212 
 213     {
 214         jvmtiEventCallbacks eventCallbacks;
 215 
 216         memset(&eventCallbacks, 0, sizeof(eventCallbacks));
 217         eventCallbacks.VMInit = callbackVMInit;
 218         eventCallbacks.VMDeath = callbackVMDeath;
 219         if (!NSK_JVMTI_VERIFY(
 220                 NSK_CPP_STUB3(SetEventCallbacks, jvmti,
 221                                     &eventCallbacks, sizeof(eventCallbacks)))) {
 222             return JNI_ERR;
 223         }
 224 
 225     }
 226 
 227     if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL)))
 228         return JNI_ERR;
 229 
 230     NSK_DISPLAY1(">>> Prepare storage data at pointer: 0x%p\n", initialStorage);
 231     fillEnvStorage(initialStorage);
 232 
 233     NSK_DISPLAY0(">>> Testcase #0: Set env storage in JVM_OnLoad()\n");
 234     if (!setEnvStorage(jvmti, initialStorage, "JVM_OnLoad()")) {
 235         nsk_jvmti_setFailStatus();
 236     }
 237 
 238     NSK_DISPLAY0(">>> Testcase #1: Check env storage in JVM_OnLoad()\n");
 239     if (!checkEnvStorage(jvmti, initialStorage, "JVM_OnLoad()")) {
 240         nsk_jvmti_setFailStatus();
 241     }


  56 static StorageStructure storageData;
  57 static StorageStructure* initialStorage = &storageData;
  58 
  59 /* ============================================================================= */
  60 
  61 /** Fill storage data with given char */
  62 static void fillEnvStorage(StorageStructure* storage) {
  63     NSK_DISPLAY2("Fill storage data with char %c for size: %d bytes\n",
  64                 (char)STORAGE_DATA_CHAR, (int)STORAGE_DATA_SIZE);
  65     memset(storage->data, STORAGE_DATA_CHAR, STORAGE_DATA_SIZE);
  66     NSK_DISPLAY0("  ... ok\n");
  67 }
  68 
  69 /**
  70  * Set JVMTI environment local storage with given pinter.
  71  * @returns NSK_FALSE if any error occured.
  72  */
  73 static int setEnvStorage(jvmtiEnv* jvmti, StorageStructure* storage, const char where[]) {
  74 
  75     NSK_DISPLAY1("Set local storage for current JVMTI env: 0x%p\n", (void*)storage);
  76     if (!NSK_JVMTI_VERIFY(jvmti->SetEnvironmentLocalStorage(storage))) {

  77         return NSK_FALSE;
  78     }
  79     NSK_DISPLAY0("  ... ok\n");
  80     return NSK_TRUE;
  81 }
  82 
  83 /**
  84  * Check JVMTI environment local storage.
  85  * @returns NSK_FALSE if any error occured.
  86  */
  87 static int checkEnvStorage(jvmtiEnv* jvmti, StorageStructure* initialStorage, const char where[]) {
  88     StorageStructure* storage = NULL;
  89 
  90     NSK_DISPLAY0("Get local storage for current JVMTI env\n");
  91     if (!NSK_JVMTI_VERIFY(jvmti->GetEnvironmentLocalStorage((void**)&storage))) {

  92         return NSK_FALSE;
  93     }
  94     NSK_DISPLAY1("  ... got storage: 0x%p\n", (void*)storage);
  95 
  96     if (storage != initialStorage) {
  97         NSK_COMPLAIN3("Wrong storage pointer returned for current JVMTI env in %s:\n"
  98                       "#   got pointer: %p\n"
  99                       "#   expected:    %p\n",
 100                         where,
 101                         (void*)storage, (void*)initialStorage);
 102         return NSK_FALSE;
 103     }
 104 
 105     {
 106         int changed = 0;
 107         int i;
 108 
 109         for (i = 0; i < STORAGE_DATA_SIZE; i++) {
 110             if (storage->data[i] != STORAGE_DATA_CHAR) {
 111                 changed++;


 197 }
 198 #endif
 199 jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
 200     jvmtiEnv* jvmti = NULL;
 201 
 202     if (!NSK_VERIFY(nsk_jvmti_parseOptions(options)))
 203         return JNI_ERR;
 204 
 205     timeout = nsk_jvmti_getWaitTime() * 60 * 1000;
 206 
 207     if (!NSK_VERIFY((jvmti =
 208             nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL))
 209         return JNI_ERR;
 210 
 211     {
 212         jvmtiEventCallbacks eventCallbacks;
 213 
 214         memset(&eventCallbacks, 0, sizeof(eventCallbacks));
 215         eventCallbacks.VMInit = callbackVMInit;
 216         eventCallbacks.VMDeath = callbackVMDeath;
 217         if (!NSK_JVMTI_VERIFY(jvmti->SetEventCallbacks(&eventCallbacks, sizeof(eventCallbacks)))) {


 218             return JNI_ERR;
 219         }
 220 
 221     }
 222 
 223     if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL)))
 224         return JNI_ERR;
 225 
 226     NSK_DISPLAY1(">>> Prepare storage data at pointer: 0x%p\n", initialStorage);
 227     fillEnvStorage(initialStorage);
 228 
 229     NSK_DISPLAY0(">>> Testcase #0: Set env storage in JVM_OnLoad()\n");
 230     if (!setEnvStorage(jvmti, initialStorage, "JVM_OnLoad()")) {
 231         nsk_jvmti_setFailStatus();
 232     }
 233 
 234     NSK_DISPLAY0(">>> Testcase #1: Check env storage in JVM_OnLoad()\n");
 235     if (!checkEnvStorage(jvmti, initialStorage, "JVM_OnLoad()")) {
 236         nsk_jvmti_setFailStatus();
 237     }
< prev index next >