Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
8254042: gtest/GTestWrapper.java failed os.test_random
Reviewed-by: dholmes, stuefe, kbarrett
  • Loading branch information
coleenp committed Nov 30, 2020
1 parent 962f7a3 commit 4db05e9
Show file tree
Hide file tree
Showing 7 changed files with 4 additions and 14 deletions.
2 changes: 0 additions & 2 deletions src/hotspot/os/aix/os_aix.cpp
Expand Up @@ -2464,8 +2464,6 @@ void os::init(void) {

clock_tics_per_sec = sysconf(_SC_CLK_TCK);

init_random(1234567);

// _main_thread points to the thread that created/loaded the JVM.
Aix::_main_thread = pthread_self();

Expand Down
2 changes: 0 additions & 2 deletions src/hotspot/os/bsd/os_bsd.cpp
Expand Up @@ -2089,8 +2089,6 @@ void os::init(void) {

clock_tics_per_sec = CLK_TCK;

init_random(1234567);

Bsd::set_page_size(getpagesize());
if (Bsd::page_size() == -1) {
fatal("os_bsd.cpp: os::init: sysconf failed (%s)", os::strerror(errno));
Expand Down
2 changes: 0 additions & 2 deletions src/hotspot/os/linux/os_linux.cpp
Expand Up @@ -4394,8 +4394,6 @@ void os::init(void) {

clock_tics_per_sec = sysconf(_SC_CLK_TCK);

init_random(1234567);

Linux::set_page_size(sysconf(_SC_PAGESIZE));
if (Linux::page_size() == -1) {
fatal("os_linux.cpp: os::init: sysconf failed (%s)",
Expand Down
2 changes: 0 additions & 2 deletions src/hotspot/os/windows/os_windows.cpp
Expand Up @@ -4164,8 +4164,6 @@ void nx_check_protection() {
void os::init(void) {
_initial_pid = _getpid();

init_random(1234567);

win32::initialize_system_info();
win32::setmode_streams();
init_page_sizes((size_t) win32::vm_page_size());
Expand Down
1 change: 0 additions & 1 deletion src/hotspot/share/prims/whitebox.cpp
Expand Up @@ -299,7 +299,6 @@ static jint wb_stress_virtual_space_resize(size_t reserved_space_size,

int seed = os::random();
tty->print_cr("Random seed is %d", seed);
os::init_random(seed);

for (size_t i = 0; i < iterations; i++) {

Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/runtime/os.cpp
Expand Up @@ -72,7 +72,7 @@

OSThread* os::_starting_thread = NULL;
address os::_polling_page = NULL;
volatile unsigned int os::_rand_seed = 1;
volatile unsigned int os::_rand_seed = 1234567;
int os::_processor_count = 0;
int os::_initial_active_processor_count = 0;
size_t os::_page_sizes[os::page_sizes_max];
Expand Down
7 changes: 3 additions & 4 deletions test/hotspot/gtest/runtime/test_os.cpp
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -120,10 +120,10 @@ TEST(os, test_random) {
unsigned int seed = 1;

// tty->print_cr("seed %ld for %ld repeats...", seed, reps);
os::init_random(seed);
int num;
for (int k = 0; k < reps; k++) {
num = os::random();
// Use next_random so the calculation is stateless.
num = seed = os::next_random(seed);
double u = (double)num / m;
ASSERT_TRUE(u >= 0.0 && u <= 1.0) << "bad random number!";

Expand All @@ -148,7 +148,6 @@ TEST(os, test_random) {
ASSERT_LT(t, eps) << "bad variance";
}


#ifdef ASSERT
TEST_VM_ASSERT_MSG(os, page_size_for_region_with_zero_min_pages, "sanity") {
size_t region_size = 16 * os::vm_page_size();
Expand Down

1 comment on commit 4db05e9

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.