47 |
47 |
48 /* ============================================================================= */ |
48 /* ============================================================================= */ |
49 |
49 |
50 /** |
50 /** |
51 * Get timer info and optionally compares it with initial one. |
51 * Get timer info and optionally compares it with initial one. |
52 * @returns NSK_FALSE if any error occured. |
52 * @returns false if any error occured. |
53 */ |
53 */ |
54 static int checkTimerInfo(jvmtiEnv* jvmti, jvmtiTimerInfo* info, |
54 static bool checkTimerInfo(jvmtiEnv* jvmti, jvmtiTimerInfo* info, |
55 jvmtiTimerInfo* initInfo, const char where[]) { |
55 jvmtiTimerInfo* initInfo, const char where[]) { |
56 |
56 |
57 char buf[32], buf2[32]; |
57 char buf[32], buf2[32]; |
58 int success = NSK_TRUE; |
58 bool success = true; |
59 |
59 |
60 NSK_DISPLAY0("GetTimerInfo() for current JVMTI env\n"); |
60 NSK_DISPLAY0("GetTimerInfo() for current JVMTI env\n"); |
61 if (!NSK_JVMTI_VERIFY( |
61 if (!NSK_JVMTI_VERIFY( |
62 jvmti->GetTimerInfo(info))) { |
62 jvmti->GetTimerInfo(info))) { |
63 return NSK_FALSE; |
63 return false; |
64 } |
64 } |
65 NSK_DISPLAY0("Got timer info:\n"); |
65 NSK_DISPLAY0("Got timer info:\n"); |
66 |
66 |
67 NSK_DISPLAY1(" max_value: %s\n", |
67 NSK_DISPLAY1(" max_value: %s\n", |
68 julong_to_string((julong)info->max_value, buf)); |
68 julong_to_string((julong)info->max_value, buf)); |
77 "# got value: %s\n" |
77 "# got value: %s\n" |
78 "# initial: %s\n", |
78 "# initial: %s\n", |
79 where, "max_value", |
79 where, "max_value", |
80 julong_to_string((julong)info->max_value, buf), |
80 julong_to_string((julong)info->max_value, buf), |
81 julong_to_string((julong)initInfo->max_value, buf2)); |
81 julong_to_string((julong)initInfo->max_value, buf2)); |
82 success = NSK_FALSE; |
82 success = false; |
83 } |
83 } |
84 if (info->may_skip_forward != initInfo->may_skip_forward) { |
84 if (info->may_skip_forward != initInfo->may_skip_forward) { |
85 NSK_COMPLAIN4("In %s GetTimerInfo() returned different info:\n" |
85 NSK_COMPLAIN4("In %s GetTimerInfo() returned different info:\n" |
86 "# field: %s\n" |
86 "# field: %s\n" |
87 "# got value: %d\n" |
87 "# got value: %d\n" |
88 "# initial: %d\n", |
88 "# initial: %d\n", |
89 where, "may_skip_forward", |
89 where, "may_skip_forward", |
90 (int)info->may_skip_forward, |
90 (int)info->may_skip_forward, |
91 (int)initInfo->may_skip_forward); |
91 (int)initInfo->may_skip_forward); |
92 success = NSK_FALSE; |
92 success = false; |
93 } |
93 } |
94 if (info->may_skip_backward != initInfo->may_skip_backward) { |
94 if (info->may_skip_backward != initInfo->may_skip_backward) { |
95 NSK_COMPLAIN4("In %s GetTimerInfo() returned different info:\n" |
95 NSK_COMPLAIN4("In %s GetTimerInfo() returned different info:\n" |
96 "# field: %s\n" |
96 "# field: %s\n" |
97 "# got value: %d\n" |
97 "# got value: %d\n" |
98 "# initial: %d\n", |
98 "# initial: %d\n", |
99 where, "may_skip_backward", |
99 where, "may_skip_backward", |
100 (int)info->may_skip_backward, |
100 (int)info->may_skip_backward, |
101 (int)initInfo->may_skip_backward); |
101 (int)initInfo->may_skip_backward); |
102 success = NSK_FALSE; |
102 success = false; |
103 } |
103 } |
104 } |
104 } |
105 |
105 |
106 return success; |
106 return success; |
107 } |
107 } |
147 /** |
147 /** |
148 * Callback for VM_DEATH event. |
148 * Callback for VM_DEATH event. |
149 */ |
149 */ |
150 JNIEXPORT void JNICALL |
150 JNIEXPORT void JNICALL |
151 callbackVMDeath(jvmtiEnv* jvmti, JNIEnv* jni) { |
151 callbackVMDeath(jvmtiEnv* jvmti, JNIEnv* jni) { |
152 int success = NSK_TRUE; |
152 bool success = true; |
153 |
153 |
154 NSK_DISPLAY0(">>> Testcase #4: Check timer info in VM_DEATH callback\n"); |
154 NSK_DISPLAY0(">>> Testcase #4: Check timer info in VM_DEATH callback\n"); |
155 { |
155 { |
156 jvmtiTimerInfo info; |
156 jvmtiTimerInfo info; |
157 success = checkTimerInfo(jvmti, &info, &initInfo, "VM_DEATH callback"); |
157 success = checkTimerInfo(jvmti, &info, &initInfo, "VM_DEATH callback"); |
158 } |
158 } |
159 |
159 |
160 NSK_DISPLAY1("Disable events: %d events\n", EVENTS_COUNT); |
160 NSK_DISPLAY1("Disable events: %d events\n", EVENTS_COUNT); |
161 if (!nsk_jvmti_enableEvents(JVMTI_DISABLE, EVENTS_COUNT, events, NULL)) { |
161 if (!nsk_jvmti_enableEvents(JVMTI_DISABLE, EVENTS_COUNT, events, NULL)) { |
162 success = NSK_FALSE; |
162 success = false; |
163 } else { |
163 } else { |
164 NSK_DISPLAY0(" ... disabled\n"); |
164 NSK_DISPLAY0(" ... disabled\n"); |
165 } |
165 } |
166 |
166 |
167 if (success != NSK_TRUE) { |
167 if (!success) { |
168 NSK_DISPLAY1("Exit with FAIL exit status: %d\n", STATUS_FAIL); |
168 NSK_DISPLAY1("Exit with FAIL exit status: %d\n", STATUS_FAIL); |
169 NSK_BEFORE_TRACE(exit(STATUS_FAIL)); |
169 NSK_BEFORE_TRACE(exit(STATUS_FAIL)); |
170 } |
170 } |
171 } |
171 } |
172 |
172 |