126 mean += u;
127 variance += (u*u);
128 }
129 mean /= reps;
130 variance /= (reps - 1);
131
132 ASSERT_EQ(num, 1043618065) << "bad seed";
133 // tty->print_cr("mean of the 1st 10000 numbers: %f", mean);
134 int intmean = mean*100;
135 ASSERT_EQ(intmean, 50);
136 // tty->print_cr("variance of the 1st 10000 numbers: %f", variance);
137 int intvariance = variance*100;
138 ASSERT_EQ(intvariance, 33);
139 const double eps = 0.0001;
140 t = fabsd(mean - 0.5018);
141 ASSERT_LT(t, eps) << "bad mean";
142 t = (variance - 0.3355) < 0.0 ? -(variance - 0.3355) : variance - 0.3355;
143 ASSERT_LT(t, eps) << "bad variance";
144 }
145
146
147 #ifdef ASSERT
148 TEST_VM_ASSERT_MSG(os, page_size_for_region_with_zero_min_pages, "sanity") {
149 size_t region_size = 16 * os::vm_page_size();
150 os::page_size_for_region_aligned(region_size, 0); // should assert
151 }
152 #endif
|
126 mean += u;
127 variance += (u*u);
128 }
129 mean /= reps;
130 variance /= (reps - 1);
131
132 ASSERT_EQ(num, 1043618065) << "bad seed";
133 // tty->print_cr("mean of the 1st 10000 numbers: %f", mean);
134 int intmean = mean*100;
135 ASSERT_EQ(intmean, 50);
136 // tty->print_cr("variance of the 1st 10000 numbers: %f", variance);
137 int intvariance = variance*100;
138 ASSERT_EQ(intvariance, 33);
139 const double eps = 0.0001;
140 t = fabsd(mean - 0.5018);
141 ASSERT_LT(t, eps) << "bad mean";
142 t = (variance - 0.3355) < 0.0 ? -(variance - 0.3355) : variance - 0.3355;
143 ASSERT_LT(t, eps) << "bad variance";
144 }
145
146 #ifdef _WIN32
147 TEST(os, dll_addr_to_function_valid) {
148 char buf[128] = "";
149 int offset = -1;
150 address valid_function_pointer = (address) JNI_CreateJavaVM;
151 ASSERT_TRUE(os::dll_address_to_function_name(valid_function_pointer,
152 buf, sizeof(buf), &offset, true) == true);
153 ASSERT_TRUE(strstr(buf, "JNI_CreateJavaVM") != NULL);
154 ASSERT_TRUE(offset >= 0);
155 }
156
157 TEST(os, dll_addr_to_function_invalid) {
158 char buf[128];
159 int offset;
160 address invalid_function_pointers[] = { NULL, (address)1, (address)&offset };
161
162 for (int i = 0;
163 i < sizeof(invalid_function_pointers) / sizeof(address);
164 i ++)
165 {
166 address addr = invalid_function_pointers[i];
167 // We should fail but not crash
168 strcpy(buf, "blabla");
169 offset = 12;
170 ASSERT_TRUE(os::dll_address_to_function_name(addr, buf, sizeof(buf),
171 &offset, true) == false);
172 // buffer should contain "", offset should contain -1
173 ASSERT_TRUE(buf[0] == '\0');
174 ASSERT_TRUE(offset == -1);
175 }
176 }
177
178 #ifdef PLATFORM_PRINT_NATIVE_STACK
179 TEST(os, platform_print_native_stack) {
180 bufferedStream bs;
181 // Note: scratch buffer argument to os::platform_print_native_stack is not
182 // optional!
183 char scratch_buffer [255];
184 for (int i = 0; i < 3; i ++) {
185 ASSERT_TRUE(os::platform_print_native_stack(&bs, NULL, scratch_buffer,
186 sizeof(scratch_buffer)));
187 ASSERT_TRUE(bs.size() > 0);
188 // This may depend on debug information files being generated and available
189 // (e.g. not zipped).
190 ASSERT_TRUE(::strstr(bs.base(), "platform_print_native_stack") != NULL);
191 #ifdef _WIN32
192 // We have source information on Windows.
193 ASSERT_TRUE(::strstr(bs.base(), "os_windows_x86.cpp") != NULL);
194 #endif
195 }
196 }
197 #endif
198 #endif
199
200 #ifdef ASSERT
201 TEST_VM_ASSERT_MSG(os, page_size_for_region_with_zero_min_pages, "sanity") {
202 size_t region_size = 16 * os::vm_page_size();
203 os::page_size_for_region_aligned(region_size, 0); // should assert
204 }
205 #endif
|