test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/thread/cmon003/TestDescription.java
author iignatyev
Wed, 02 May 2018 16:43:56 -0700
changeset 49958 cc29d7717e3a
permissions -rw-r--r--
8199375: [TESTBUG] Open source vm testbase monitoring tests Reviewed-by: kvn, ihse, sspitsyn
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
49958
cc29d7717e3a 8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff changeset
     1
/*
cc29d7717e3a 8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff changeset
     2
 * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
cc29d7717e3a 8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
cc29d7717e3a 8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff changeset
     4
 *
cc29d7717e3a 8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
cc29d7717e3a 8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
cc29d7717e3a 8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff changeset
     7
 * published by the Free Software Foundation.
cc29d7717e3a 8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff changeset
     8
 *
cc29d7717e3a 8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
cc29d7717e3a 8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
cc29d7717e3a 8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
cc29d7717e3a 8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
cc29d7717e3a 8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff changeset
    13
 * accompanied this code).
cc29d7717e3a 8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff changeset
    14
 *
cc29d7717e3a 8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
cc29d7717e3a 8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
cc29d7717e3a 8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
cc29d7717e3a 8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff changeset
    18
 *
cc29d7717e3a 8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
cc29d7717e3a 8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
cc29d7717e3a 8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff changeset
    21
 * questions.
cc29d7717e3a 8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff changeset
    22
 */
cc29d7717e3a 8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff changeset
    23
cc29d7717e3a 8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff changeset
    24
cc29d7717e3a 8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff changeset
    25
/*
cc29d7717e3a 8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff changeset
    26
 * @test
cc29d7717e3a 8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff changeset
    27
 * @key stress
cc29d7717e3a 8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff changeset
    28
 *
cc29d7717e3a 8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff changeset
    29
 * @summary converted from VM Testbase nsk/monitoring/stress/thread/cmon003.
cc29d7717e3a 8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff changeset
    30
 * VM Testbase keywords: [stress, monitoring, nonconcurrent]
cc29d7717e3a 8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff changeset
    31
 * VM Testbase readme:
cc29d7717e3a 8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff changeset
    32
 * DESCRIPTION
cc29d7717e3a 8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff changeset
    33
 *     The test checks that waited time returned by ThreadInfo.getWaitedTime() is
cc29d7717e3a 8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff changeset
    34
 *     not greater than overall time of execution of a thread. Also, the test
cc29d7717e3a 8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff changeset
    35
 *     checks that waited time is not less than minimal time that each thread
cc29d7717e3a 8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff changeset
    36
 *     waits without notifications on Object.wait(long).
cc29d7717e3a 8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff changeset
    37
 *     Main thread starts a number of threads that is specified in "-threadCount"
cc29d7717e3a 8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff changeset
    38
 *     option. Each thread has three Object.wait(long) blocks; two of them do
cc29d7717e3a 8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff changeset
    39
 *     not receieve notifications, therefore a thread will be waiting for at least
cc29d7717e3a 8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff changeset
    40
 *     a few milliseconds. All threads access the same Integer variable
cc29d7717e3a 8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff changeset
    41
 *     ("calculated") and increase its value by one. Main thread waits until
cc29d7717e3a 8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff changeset
    42
 *     "calculated" becomes equal to number of started threads and then perform
cc29d7717e3a 8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff changeset
    43
 *     three checks.
cc29d7717e3a 8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff changeset
    44
 *     The test fails if "calculated" value is not equal to number of started
cc29d7717e3a 8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff changeset
    45
 *     threads. It also fails if value returned by ThreadInfo.getWaitedTime() in
cc29d7717e3a 8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff changeset
    46
 *     any thread is greater than overall time of execution of the thread. Also,
cc29d7717e3a 8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff changeset
    47
 *     the test fails if waited time is less than time waited in first and second
cc29d7717e3a 8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff changeset
    48
 *     Object.wait(long) methods (those objects do not receive notifications).
cc29d7717e3a 8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff changeset
    49
 *     Then the test repeats the procedure with starting threads and performing
cc29d7717e3a 8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff changeset
    50
 *     checks ITERATIONS times.
cc29d7717e3a 8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff changeset
    51
 *     All comparisions of time are made with precision specified in PRECISION
cc29d7717e3a 8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff changeset
    52
 *     constant. Values returned by ThreadInfo.getWaitedTime() and
cc29d7717e3a 8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff changeset
    53
 *     System.nanoTime() and may use different methods to sample time, so
cc29d7717e3a 8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff changeset
    54
 *     PRECISION is essential to compare those two times and is set to 3
cc29d7717e3a 8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff changeset
    55
 *     (milliseconds) by default.
cc29d7717e3a 8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff changeset
    56
 *     This particular test performs access to the MBeans' methods through custom
cc29d7717e3a 8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff changeset
    57
 *     MBeanServer.
cc29d7717e3a 8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff changeset
    58
 * COMMENTS
cc29d7717e3a 8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff changeset
    59
 *     Fixed the bug
cc29d7717e3a 8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff changeset
    60
 *     4983682 TEST BUG: cmon001/2/3 should call System.nanoTime for time
cc29d7717e3a 8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff changeset
    61
 *             comparison
cc29d7717e3a 8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff changeset
    62
 *     5070997: TEST_BUG: incorrect below-checking of thread waiting time
cc29d7717e3a 8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff changeset
    63
 *
cc29d7717e3a 8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff changeset
    64
 * @library /vmTestbase
cc29d7717e3a 8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff changeset
    65
 *          /test/lib
cc29d7717e3a 8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff changeset
    66
 * @run driver jdk.test.lib.FileInstaller . .
cc29d7717e3a 8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff changeset
    67
 * @run main/othervm
cc29d7717e3a 8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff changeset
    68
 *      nsk.monitoring.stress.thread.cmon001
cc29d7717e3a 8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff changeset
    69
 *      -testMode=server
cc29d7717e3a 8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff changeset
    70
 *      -MBeanServer=custom
cc29d7717e3a 8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff changeset
    71
 *      -threadCount=400
cc29d7717e3a 8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff changeset
    72
 */
cc29d7717e3a 8199375: [TESTBUG] Open source vm testbase monitoring tests
iignatyev
parents:
diff changeset
    73