< prev index next >

test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetSystemProperty/setsysprop002/setsysprop002.cpp

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


  59         }
  60     },
  61     {
  62         "nsk.jvmti.test.property.empty.new",
  63         {
  64             "initial value of nsk.jvmti.test.property.empty.new",
  65             "",
  66             "live phase value of nsk.jvmti.test.property.empty.new"
  67         }
  68     }
  69 };
  70 
  71 /* ============================================================================= */
  72 
  73 static int checkPropertyValue(jvmtiEnv* jvmti, const char phase[],
  74                                 const char name[], const char* expectedValue) {
  75     int success = NSK_TRUE;
  76     char* value = NULL;
  77 
  78     NSK_DISPLAY1("  property: %s\n", name);
  79     if (!NSK_JVMTI_VERIFY(
  80             NSK_CPP_STUB3(GetSystemProperty, jvmti, name, &value))) {
  81         return NSK_FALSE;
  82     }
  83     NSK_DISPLAY1("     value: \"%s\"\n", nsk_null_string(value));
  84 
  85     if (value == NULL
  86             || strcmp(value, expectedValue) != 0) {
  87         NSK_COMPLAIN4("In %s phase GetSystemProperty() returned unexpected value for property:\n"
  88                       "#   property name: %s\n"
  89                       "#   got value:     \"%s\"\n"
  90                       "#   expected:      \"%s\"\n",
  91                         phase, name,
  92                         nsk_null_string(value), expectedValue);
  93         success = NSK_FALSE;
  94     }
  95 
  96     if (!NSK_JVMTI_VERIFY(
  97             NSK_CPP_STUB2(Deallocate, jvmti, (unsigned char*)value))) {
  98         success = NSK_FALSE;
  99     }
 100 
 101     return success;
 102 }
 103 
 104 static int checkProperties(jvmtiEnv* jvmti, const char phase[], int step) {
 105     int success = NSK_TRUE;
 106     int i;
 107 
 108     NSK_DISPLAY0("Check previously set values of tested properties\n");
 109     for (i = 0; i < PROPERTIES_COUNT; i++) {
 110         if (!checkPropertyValue(jvmti, phase,
 111                             propDescList[i].name, propDescList[i].values[step-1])) {
 112             success = NSK_FALSE;
 113         }
 114     }
 115 
 116     NSK_DISPLAY1("Set new values for tested properties %s\n",
 117         (step > 1) ? "(negative)" : "");
 118     for (i = 0; i < PROPERTIES_COUNT; i++) {
 119         NSK_DISPLAY1("  property: %s\n", propDescList[i].name);
 120         NSK_DISPLAY1("     value: \"%s\"\n", propDescList[i].values[step]);
 121         if (step > 1) {
 122             if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_WRONG_PHASE,
 123                    NSK_CPP_STUB3(SetSystemProperty, jvmti,
 124                      propDescList[i].name, propDescList[i].values[step]))) {
 125                 success = NSK_FALSE;
 126             }
 127         } else {
 128             if (!NSK_JVMTI_VERIFY(
 129                    NSK_CPP_STUB3(SetSystemProperty, jvmti,
 130                      propDescList[i].name, propDescList[i].values[step]))) {
 131                 success = NSK_FALSE;
 132             }
 133         }
 134     }
 135 
 136     NSK_DISPLAY0("Check newly set values of tested properties\n");
 137     for (i = 0; i < PROPERTIES_COUNT; i++) {
 138         if (!checkPropertyValue(jvmti, phase, propDescList[i].name,
 139                 propDescList[i].values[1])) {
 140             success = NSK_FALSE;
 141         }
 142     }
 143 
 144     return success;
 145 }
 146 
 147 /* ============================================================================= */
 148 
 149 /** Agent algorithm. */
 150 static void JNICALL




  59         }
  60     },
  61     {
  62         "nsk.jvmti.test.property.empty.new",
  63         {
  64             "initial value of nsk.jvmti.test.property.empty.new",
  65             "",
  66             "live phase value of nsk.jvmti.test.property.empty.new"
  67         }
  68     }
  69 };
  70 
  71 /* ============================================================================= */
  72 
  73 static int checkPropertyValue(jvmtiEnv* jvmti, const char phase[],
  74                                 const char name[], const char* expectedValue) {
  75     int success = NSK_TRUE;
  76     char* value = NULL;
  77 
  78     NSK_DISPLAY1("  property: %s\n", name);
  79     if (!NSK_JVMTI_VERIFY(jvmti->GetSystemProperty(name, &value))) {

  80         return NSK_FALSE;
  81     }
  82     NSK_DISPLAY1("     value: \"%s\"\n", nsk_null_string(value));
  83 
  84     if (value == NULL
  85             || strcmp(value, expectedValue) != 0) {
  86         NSK_COMPLAIN4("In %s phase GetSystemProperty() returned unexpected value for property:\n"
  87                       "#   property name: %s\n"
  88                       "#   got value:     \"%s\"\n"
  89                       "#   expected:      \"%s\"\n",
  90                         phase, name,
  91                         nsk_null_string(value), expectedValue);
  92         success = NSK_FALSE;
  93     }
  94 
  95     if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)value))) {

  96         success = NSK_FALSE;
  97     }
  98 
  99     return success;
 100 }
 101 
 102 static int checkProperties(jvmtiEnv* jvmti, const char phase[], int step) {
 103     int success = NSK_TRUE;
 104     int i;
 105 
 106     NSK_DISPLAY0("Check previously set values of tested properties\n");
 107     for (i = 0; i < PROPERTIES_COUNT; i++) {
 108         if (!checkPropertyValue(jvmti, phase,
 109                             propDescList[i].name, propDescList[i].values[step-1])) {
 110             success = NSK_FALSE;
 111         }
 112     }
 113 
 114     NSK_DISPLAY1("Set new values for tested properties %s\n",
 115         (step > 1) ? "(negative)" : "");
 116     for (i = 0; i < PROPERTIES_COUNT; i++) {
 117         NSK_DISPLAY1("  property: %s\n", propDescList[i].name);
 118         NSK_DISPLAY1("     value: \"%s\"\n", propDescList[i].values[step]);
 119         if (step > 1) {
 120             if (!NSK_JVMTI_VERIFY_CODE(JVMTI_ERROR_WRONG_PHASE,
 121                    jvmti->SetSystemProperty(propDescList[i].name, propDescList[i].values[step]))) {

 122                 success = NSK_FALSE;
 123             }
 124         } else {
 125             if (!NSK_JVMTI_VERIFY(
 126                    jvmti->SetSystemProperty(propDescList[i].name, propDescList[i].values[step]))) {

 127                 success = NSK_FALSE;
 128             }
 129         }
 130     }
 131 
 132     NSK_DISPLAY0("Check newly set values of tested properties\n");
 133     for (i = 0; i < PROPERTIES_COUNT; i++) {
 134         if (!checkPropertyValue(jvmti, phase, propDescList[i].name,
 135                 propDescList[i].values[1])) {
 136             success = NSK_FALSE;
 137         }
 138     }
 139 
 140     return success;
 141 }
 142 
 143 /* ============================================================================= */
 144 
 145 /** Agent algorithm. */
 146 static void JNICALL


< prev index next >