< prev index next >

test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/general_functions/GF01/gf01t001/gf01t001.cpp

Print this page
rev 52050 : [mq]: refactor


  60             NSK_DISPLAY1("CHECK PASSED: found highly recommended system property \"%s\" as expected\n",
  61                 expected_props[i]);
  62             return 1; /* the property found */
  63         }
  64     }
  65 
  66     NSK_DISPLAY1("\tsystem property \"%s\" not found among highly recommended ones\n",
  67         prop);
  68     return 0; /* the property not found */
  69 }
  70 
  71 static void checkProps(jvmtiEnv *jvmti_env, const char *stepMsg) {
  72     jint count;
  73     char **propKeys;
  74     char *prop;
  75     int i;
  76     int foundProps = 0;
  77 
  78     NSK_DISPLAY1("%s: Getting system property keys ...\n",
  79         stepMsg);
  80     if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB3(GetSystemProperties,
  81             jvmti_env, &count, &propKeys))) {
  82         result = STATUS_FAILED;
  83         return;
  84     }
  85     NSK_DISPLAY1("%d keys obtained\n",
  86         count);
  87 
  88     if (count < PROP_NUM) {
  89         result = STATUS_FAILED;
  90         NSK_COMPLAIN2("TEST FAILED: GetSystemProperties() returns %d system property keys\n\texpected at least %d",
  91             count, PROP_NUM);
  92     }
  93 
  94     for (i=0; i< count; i++) {
  95         NSK_DISPLAY2("%d) getting property for the key \"%s\":\n",
  96             i+1, propKeys[i]);
  97        if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB3(GetSystemProperty,
  98                jvmti_env, (const char*) propKeys[i], &prop))) {
  99            result = STATUS_FAILED;
 100            return;
 101         }
 102         NSK_DISPLAY1("\tproperty=\"%s\"\n",
 103             prop);
 104 
 105         foundProps += findProp(propKeys[i]);
 106 
 107         NSK_DISPLAY0("\tdeallocating system property\n");
 108         if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(Deallocate,
 109                 jvmti_env, (unsigned char*) prop))) {
 110             result = STATUS_FAILED;
 111             return;
 112         }
 113 
 114         NSK_DISPLAY0("\tdeallocating the system property key\n\n");
 115         if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(Deallocate,
 116                 jvmti_env, (unsigned char*) propKeys[i]))) {
 117             result = STATUS_FAILED;
 118             return;
 119         }
 120     }
 121 
 122 /*    NSK_DISPLAY0("Deallocating the property key array ...\n");
 123     if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(Deallocate,
 124             jvmti_env, (unsigned char*) &propKeys))) {
 125         result = STATUS_FAILED;
 126         return;
 127     }*/
 128 
 129     if (foundProps != PROP_NUM) {
 130         result = STATUS_FAILED;
 131         NSK_COMPLAIN2("TEST FAILED: only %d highly recommended system properties found\n\tinstead of %d as expected\n",
 132             foundProps, PROP_NUM);
 133     }
 134 }
 135 
 136 /** callback functions **/
 137 void JNICALL
 138 VMInit(jvmtiEnv *jvmti_env, JNIEnv *env, jthread thr) {
 139     NSK_DISPLAY0("VMInit event received\n");
 140 
 141     checkProps(jvmti_env, ">>> b) TEST CASE \"VMInit\"");
 142 }
 143 
 144 void JNICALL


 168     return JNI_VERSION_1_8;
 169 }
 170 #endif
 171 jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
 172     jvmtiEnv *jvmti;
 173 
 174     /* init framework and parse options */
 175     if (!NSK_VERIFY(nsk_jvmti_parseOptions(options)))
 176         return JNI_ERR;
 177 
 178     /* create JVMTI environment */
 179     if (!NSK_VERIFY((jvmti =
 180             nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL))
 181         return JNI_ERR;
 182 
 183     NSK_DISPLAY0("setting event callbacks ...\n");
 184 
 185     (void) memset(&callbacks, 0, sizeof(callbacks));
 186     callbacks.VMInit = &VMInit;
 187     callbacks.VMDeath = &VMDeath;
 188     if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB3(SetEventCallbacks,
 189             jvmti, &callbacks, sizeof(callbacks))))
 190         return JNI_ERR;
 191 
 192     NSK_DISPLAY0("setting event callbacks done\nenabling events ...\n");
 193 
 194     if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(SetEventNotificationMode,
 195             jvmti, JVMTI_ENABLE, JVMTI_EVENT_VM_DEATH, NULL)))
 196         return JNI_ERR;
 197     if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB4(SetEventNotificationMode,
 198             jvmti, JVMTI_ENABLE, JVMTI_EVENT_VM_INIT, NULL)))
 199         return JNI_ERR;
 200 
 201     NSK_DISPLAY0("enabling events done\n\n");
 202 
 203     checkProps(jvmti, ">>> a) TEST CASE \"OnLoad\"");
 204 
 205     return JNI_OK;
 206 }
 207 
 208 }


  60             NSK_DISPLAY1("CHECK PASSED: found highly recommended system property \"%s\" as expected\n",
  61                 expected_props[i]);
  62             return 1; /* the property found */
  63         }
  64     }
  65 
  66     NSK_DISPLAY1("\tsystem property \"%s\" not found among highly recommended ones\n",
  67         prop);
  68     return 0; /* the property not found */
  69 }
  70 
  71 static void checkProps(jvmtiEnv *jvmti_env, const char *stepMsg) {
  72     jint count;
  73     char **propKeys;
  74     char *prop;
  75     int i;
  76     int foundProps = 0;
  77 
  78     NSK_DISPLAY1("%s: Getting system property keys ...\n",
  79         stepMsg);
  80     if (!NSK_JVMTI_VERIFY(jvmti_env->GetSystemProperties(&count, &propKeys))) {

  81         result = STATUS_FAILED;
  82         return;
  83     }
  84     NSK_DISPLAY1("%d keys obtained\n",
  85         count);
  86 
  87     if (count < PROP_NUM) {
  88         result = STATUS_FAILED;
  89         NSK_COMPLAIN2("TEST FAILED: GetSystemProperties() returns %d system property keys\n\texpected at least %d",
  90             count, PROP_NUM);
  91     }
  92 
  93     for (i=0; i< count; i++) {
  94         NSK_DISPLAY2("%d) getting property for the key \"%s\":\n",
  95             i+1, propKeys[i]);
  96        if (!NSK_JVMTI_VERIFY(jvmti_env->GetSystemProperty((const char*) propKeys[i], &prop))) {

  97            result = STATUS_FAILED;
  98            return;
  99         }
 100         NSK_DISPLAY1("\tproperty=\"%s\"\n",
 101             prop);
 102 
 103         foundProps += findProp(propKeys[i]);
 104 
 105         NSK_DISPLAY0("\tdeallocating system property\n");
 106         if (!NSK_JVMTI_VERIFY(jvmti_env->Deallocate((unsigned char*) prop))) {

 107             result = STATUS_FAILED;
 108             return;
 109         }
 110 
 111         NSK_DISPLAY0("\tdeallocating the system property key\n\n");
 112         if (!NSK_JVMTI_VERIFY(jvmti_env->Deallocate((unsigned char*) propKeys[i]))) {

 113             result = STATUS_FAILED;
 114             return;
 115         }
 116     }
 117 
 118 /*    NSK_DISPLAY0("Deallocating the property key array ...\n");
 119     if (!NSK_JVMTI_VERIFY(jvmti_env->Deallocate((unsigned char*) &propKeys))) {

 120         result = STATUS_FAILED;
 121         return;
 122     }*/
 123 
 124     if (foundProps != PROP_NUM) {
 125         result = STATUS_FAILED;
 126         NSK_COMPLAIN2("TEST FAILED: only %d highly recommended system properties found\n\tinstead of %d as expected\n",
 127             foundProps, PROP_NUM);
 128     }
 129 }
 130 
 131 /** callback functions **/
 132 void JNICALL
 133 VMInit(jvmtiEnv *jvmti_env, JNIEnv *env, jthread thr) {
 134     NSK_DISPLAY0("VMInit event received\n");
 135 
 136     checkProps(jvmti_env, ">>> b) TEST CASE \"VMInit\"");
 137 }
 138 
 139 void JNICALL


 163     return JNI_VERSION_1_8;
 164 }
 165 #endif
 166 jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
 167     jvmtiEnv *jvmti;
 168 
 169     /* init framework and parse options */
 170     if (!NSK_VERIFY(nsk_jvmti_parseOptions(options)))
 171         return JNI_ERR;
 172 
 173     /* create JVMTI environment */
 174     if (!NSK_VERIFY((jvmti =
 175             nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL))
 176         return JNI_ERR;
 177 
 178     NSK_DISPLAY0("setting event callbacks ...\n");
 179 
 180     (void) memset(&callbacks, 0, sizeof(callbacks));
 181     callbacks.VMInit = &VMInit;
 182     callbacks.VMDeath = &VMDeath;
 183     if (!NSK_JVMTI_VERIFY(jvmti->SetEventCallbacks(&callbacks, sizeof(callbacks))))

 184         return JNI_ERR;
 185 
 186     NSK_DISPLAY0("setting event callbacks done\nenabling events ...\n");
 187 
 188     if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_DEATH, NULL)))

 189         return JNI_ERR;
 190     if (!NSK_JVMTI_VERIFY(jvmti->SetEventNotificationMode(JVMTI_ENABLE, JVMTI_EVENT_VM_INIT, NULL)))

 191         return JNI_ERR;
 192 
 193     NSK_DISPLAY0("enabling events done\n\n");
 194 
 195     checkProps(jvmti, ">>> a) TEST CASE \"OnLoad\"");
 196 
 197     return JNI_OK;
 198 }
 199 
 200 }
< prev index next >