< prev index next >

test/hotspot/jtreg/runtime/handshake/HandshakeTransitionTest.java

Print this page
rev 47492 : [mq]: Coleen-n-Test-Cleanup-4

@@ -20,15 +20,77 @@
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  *
  */
 
+import java.io.File;
+import java.nio.file.Paths;
+import java.time.Duration;
+
+import jdk.test.lib.process.ProcessTools;
+import jdk.test.lib.process.OutputAnalyzer;
+
 /*
- * @test HandshakeWalkStackFallbackTest
- * @requires (vm.simpleArch == "x64" | vm.simpleArch == "sparcv9")
+ * @test HandshakeTransitionTest
+ * @summary This does a sanity test of the poll in the native wrapper.
+ * @requires vm.debug
  * @library /testlibrary /test/lib
- * @build HandshakeWalkStackTest
- * @run main ClassFileInstaller sun.hotspot.WhiteBox
- *                              sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:+ThreadLocalHandshakes HandshakeWalkStackTest
+ * @build HandshakeTransitionTest
+ * @run main/native HandshakeTransitionTest
  */
 
+public class HandshakeTransitionTest {
+
+    public static native void someTime(int ms);
+
+    public static void main(String[] args) throws Exception {
+        String lib = System.getProperty("test.nativepath");
+        ProcessBuilder pb =
+            ProcessTools.createJavaProcessBuilder(
+                    true,
+                    "-Djava.library.path=" + lib,
+                    "-XX:+SafepointALot",
+                    "-XX:GuaranteedSafepointInterval=20",
+                    "-Xlog:ergo*",
+                    "-XX:ParallelGCThreads=1",
+                    "-XX:ConcGCThreads=1",
+                    "-XX:CICompilerCount=2",
+                    "HandshakeTransitionTest$Test");
+
+
+        OutputAnalyzer output = ProcessTools.executeProcess(pb);
+        output.reportDiagnosticSummary();
+        output.shouldHaveExitValue(0);
+        output.stdoutShouldContain("JOINED");
+    }
+
+    static class Test implements Runnable {
+        final static int testLoops = 2000;
+        final static int testSleep = 1; //ms
+
+        public static void main(String[] args) throws Exception {
+            System.loadLibrary("HandshakeTransitionTest");
+            Test test = new Test();
+            Thread[] threads = new Thread[64];
+            for (int i = 0; i<threads.length ; i++) {
+                threads[i] = new Thread(test);
+                threads[i].start();
+            }
+            for (Thread t : threads) {
+                t.join();
+            }
+            System.out.println("JOINED");
+        }
+
+        @Override
+        public void run() {
+            try {
+                for (int i = 0; i<testLoops ; i++) {
+                    someTime(testSleep);
+                }
+            } catch (Exception e) {
+                System.out.println(e.getMessage());
+                System.exit(1);
+            }
+        }
+    }
+}
< prev index next >