hotspot/test/runtime/memory/RunUnitTestsConcurrently.java
author alanb
Thu, 01 Dec 2016 15:54:39 +0000
changeset 42309 21f9f3fbc302
parent 40631 ed82623d7831
permissions -rw-r--r--
8170599: compiler/** tests using ToolProvider.getSystemClassLoader failing Reviewed-by: hseigel
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
21554
20b1821f4fbd 8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff changeset
     1
/*
40631
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 36851
diff changeset
     2
 * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
21554
20b1821f4fbd 8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
20b1821f4fbd 8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff changeset
     4
 *
20b1821f4fbd 8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
20b1821f4fbd 8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
20b1821f4fbd 8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff changeset
     7
 * published by the Free Software Foundation.
20b1821f4fbd 8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff changeset
     8
 *
20b1821f4fbd 8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
20b1821f4fbd 8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20b1821f4fbd 8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
20b1821f4fbd 8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
20b1821f4fbd 8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff changeset
    13
 * accompanied this code).
20b1821f4fbd 8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff changeset
    14
 *
20b1821f4fbd 8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
20b1821f4fbd 8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
20b1821f4fbd 8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20b1821f4fbd 8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff changeset
    18
 *
20b1821f4fbd 8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20b1821f4fbd 8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
20b1821f4fbd 8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff changeset
    21
 * questions.
20b1821f4fbd 8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff changeset
    22
 */
20b1821f4fbd 8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff changeset
    23
20b1821f4fbd 8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff changeset
    24
/*
20b1821f4fbd 8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff changeset
    25
 * @test
20b1821f4fbd 8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff changeset
    26
 * @summary Test launches unit tests inside vm concurrently
40631
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 36851
diff changeset
    27
 * @library /test/lib
36851
03e2f4d0a421 8153737: Unsupported Module
chegar
parents: 33730
diff changeset
    28
 * @modules java.base/jdk.internal.misc
29678
dd2f3932c21e 8075586: Add @modules as needed to the open hotspot tests
ykantser
parents: 28190
diff changeset
    29
 *          java.management
40631
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 36851
diff changeset
    30
 * @build sun.hotspot.WhiteBox
21554
20b1821f4fbd 8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff changeset
    31
 * @run main ClassFileInstaller sun.hotspot.WhiteBox
25958
8dc85547d6d6 8011397: JTREG needs to copy additional WhiteBox class file to JTwork/scratch/sun/hotspot
mgerdin
parents: 21554
diff changeset
    32
 *                              sun.hotspot.WhiteBox$WhiteBoxPermission
21554
20b1821f4fbd 8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff changeset
    33
 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI RunUnitTestsConcurrently 30 15000
20b1821f4fbd 8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff changeset
    34
 */
20b1821f4fbd 8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff changeset
    35
40631
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 36851
diff changeset
    36
import jdk.test.lib.Platform;
21554
20b1821f4fbd 8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff changeset
    37
import sun.hotspot.WhiteBox;
20b1821f4fbd 8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff changeset
    38
20b1821f4fbd 8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff changeset
    39
public class RunUnitTestsConcurrently {
20b1821f4fbd 8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff changeset
    40
20b1821f4fbd 8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff changeset
    41
  private static WhiteBox wb;
20b1821f4fbd 8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff changeset
    42
  private static long timeout;
20b1821f4fbd 8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff changeset
    43
  private static long timeStamp;
20b1821f4fbd 8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff changeset
    44
20b1821f4fbd 8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff changeset
    45
  public static class Worker implements Runnable {
20b1821f4fbd 8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff changeset
    46
    @Override
20b1821f4fbd 8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff changeset
    47
    public void run() {
20b1821f4fbd 8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff changeset
    48
      while (System.currentTimeMillis() - timeStamp < timeout) {
20b1821f4fbd 8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff changeset
    49
        WhiteBox.getWhiteBox().runMemoryUnitTests();
20b1821f4fbd 8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff changeset
    50
      }
20b1821f4fbd 8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff changeset
    51
    }
20b1821f4fbd 8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff changeset
    52
  }
20b1821f4fbd 8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff changeset
    53
20b1821f4fbd 8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff changeset
    54
  public static void main(String[] args) throws InterruptedException {
20b1821f4fbd 8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff changeset
    55
    if (!Platform.isDebugBuild() || !Platform.is64bit()) {
20b1821f4fbd 8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff changeset
    56
      return;
20b1821f4fbd 8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff changeset
    57
    }
20b1821f4fbd 8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff changeset
    58
    wb = WhiteBox.getWhiteBox();
20b1821f4fbd 8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff changeset
    59
    System.out.println("Starting threads");
20b1821f4fbd 8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff changeset
    60
20b1821f4fbd 8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff changeset
    61
    int threads = Integer.valueOf(args[0]);
20b1821f4fbd 8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff changeset
    62
    timeout = Long.valueOf(args[1]);
20b1821f4fbd 8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff changeset
    63
20b1821f4fbd 8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff changeset
    64
    timeStamp = System.currentTimeMillis();
20b1821f4fbd 8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff changeset
    65
20b1821f4fbd 8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff changeset
    66
    Thread[] threadsArray = new Thread[threads];
20b1821f4fbd 8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff changeset
    67
    for (int i = 0; i < threads; i++) {
20b1821f4fbd 8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff changeset
    68
      threadsArray[i] = new Thread(new Worker());
20b1821f4fbd 8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff changeset
    69
      threadsArray[i].start();
20b1821f4fbd 8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff changeset
    70
    }
20b1821f4fbd 8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff changeset
    71
    for (int i = 0; i < threads; i++) {
20b1821f4fbd 8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff changeset
    72
      threadsArray[i].join();
20b1821f4fbd 8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff changeset
    73
    }
20b1821f4fbd 8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff changeset
    74
20b1821f4fbd 8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff changeset
    75
    System.out.println("Quitting test.");
20b1821f4fbd 8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff changeset
    76
  }
20b1821f4fbd 8027237: New tests on ReservedSpace/VirtualSpace classes
mgerdin
parents:
diff changeset
    77
}