test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/contention/TC05/tc05t001/tc05t001.cpp
changeset 58025 cfd0f43fdf5f
parent 52949 c78a17d24618
equal deleted inserted replaced
58024:6eb44470aa98 58025:cfd0f43fdf5f
     1 /*
     1 /*
     2  * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2004, 2019, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    37  * Please, do not increase it anymore if the test still fails with the message:
    37  * Please, do not increase it anymore if the test still fails with the message:
    38  *  "(waitedTime - waitTime) >= (EXPECTED_TIMEOUT * 1000000) - EXPECTED_TIMEOUT_ACCURACY_NS"
    38  *  "(waitedTime - waitTime) >= (EXPECTED_TIMEOUT * 1000000) - EXPECTED_TIMEOUT_ACCURACY_NS"
    39  */
    39  */
    40 static const jlong EXPECTED_TIMEOUT_ACCURACY_NS = 300000;
    40 static const jlong EXPECTED_TIMEOUT_ACCURACY_NS = 300000;
    41 
    41 
    42 static const jlong EXPECTED_ACCURACY = 10;
    42 #if (defined(WIN32) || defined(_WIN32))
       
    43 static const jlong EXPECTED_ACCURACY = 16; // 16ms is longest clock update interval
       
    44 #else
       
    45 static const jlong EXPECTED_ACCURACY = 10; // high frequency clock updates expected
       
    46 #endif
    43 
    47 
    44 /* scaffold objects */
    48 /* scaffold objects */
    45 static jlong timeout = 0;
    49 static jlong timeout = 0;
    46 
    50 
    47 /* test objects */
    51 /* test objects */
   262 
   266 
   263     NSK_DISPLAY1("Time frame between the events: %s ns\n",
   267     NSK_DISPLAY1("Time frame between the events: %s ns\n",
   264         jlong_to_string(waitedTime - waitTime, buffer));
   268         jlong_to_string(waitedTime - waitTime, buffer));
   265     if (!(NSK_VERIFY((waitedTime - waitTime) >= (EXPECTED_TIMEOUT * 1000000) - EXPECTED_TIMEOUT_ACCURACY_NS))) {
   269     if (!(NSK_VERIFY((waitedTime - waitTime) >= (EXPECTED_TIMEOUT * 1000000) - EXPECTED_TIMEOUT_ACCURACY_NS))) {
   266 #if (defined(WIN32) || defined(_WIN32))
   270 #if (defined(WIN32) || defined(_WIN32))
   267         /* Do not fail on Windows as spurious wakeups are expected. The JDK-6313903 was closed as "Won't Fix". */
   271         /* Do not fail on Windows as early returns are expected and wait() treats them as spurious wakeups. */
   268 #else
   272 #else
   269         nsk_jvmti_setFailStatus();
   273         nsk_jvmti_setFailStatus();
   270 #endif
   274 #endif
   271         printf("waitedTime: %" LL "d,  waitTime: %" LL "d, waitedTime - waitTime: %" LL "d\n",
   275         printf("waitedTime: %" LL "d,  waitTime: %" LL "d, waitedTime - waitTime: %" LL "d\n",
   272                 waitedTime, waitTime, waitedTime - waitTime);
   276                 waitedTime, waitTime, waitedTime - waitTime);