8242313: use reproducible random in hotspot svc tests
Reviewed-by: cjplummer
This commit is contained in:
parent
15464b36c3
commit
116fe806c3
@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -22,13 +22,16 @@
|
|||||||
* questions.
|
* questions.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
import jdk.test.lib.apps.LingeredApp;
|
import jdk.test.lib.apps.LingeredApp;
|
||||||
|
import jdk.test.lib.Utils;
|
||||||
|
|
||||||
public class LingeredAppWithNativeMethod extends LingeredApp {
|
public class LingeredAppWithNativeMethod extends LingeredApp {
|
||||||
|
|
||||||
public static final String THREAD_NAME = "NoFramePointerJNIFib";
|
public static final String THREAD_NAME = "NoFramePointerJNIFib";
|
||||||
private static final int UPPER_BOUND = 55;
|
private static final int UPPER_BOUND = 55;
|
||||||
private static final int LOWER_BOUND = 40;
|
private static final int LOWER_BOUND = 40;
|
||||||
|
private static final Random RNG = Utils.getRandomInstance();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
// JNI library compiled with no frame pointer info
|
// JNI library compiled with no frame pointer info
|
||||||
@ -43,9 +46,9 @@ public class LingeredAppWithNativeMethod extends LingeredApp {
|
|||||||
// Results of fibonacci calculation from JNI are
|
// Results of fibonacci calculation from JNI are
|
||||||
// reported via callback(). That's where the process
|
// reported via callback(). That's where the process
|
||||||
// of calculating fibonacci restarts.
|
// of calculating fibonacci restarts.
|
||||||
int num = (int) (Math.random() * UPPER_BOUND);
|
int num = (int) (RNG.nextDouble() * UPPER_BOUND);
|
||||||
while (num < LOWER_BOUND) {
|
while (num < LOWER_BOUND) {
|
||||||
num = (int) (Math.random() * UPPER_BOUND);
|
num = (int) (RNG.nextDouble() * UPPER_BOUND);
|
||||||
}
|
}
|
||||||
System.out.print("fib(" + num + ") = ");
|
System.out.print("fib(" + num + ") = ");
|
||||||
callJNI(this, num);
|
callJNI(this, num);
|
||||||
|
@ -34,6 +34,7 @@ import jdk.test.lib.process.OutputAnalyzer;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @test
|
* @test
|
||||||
|
* @key randomness
|
||||||
* @bug 8208091
|
* @bug 8208091
|
||||||
* @requires (os.family == "linux") & (vm.hasSA)
|
* @requires (os.family == "linux") & (vm.hasSA)
|
||||||
* @library /test/lib
|
* @library /test/lib
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -28,6 +28,7 @@ import java.util.Random;
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* @test
|
* @test
|
||||||
|
* @key randomness
|
||||||
* @bug 8016304
|
* @bug 8016304
|
||||||
* @summary Make sure no deadlock is reported for this program which has no deadlocks.
|
* @summary Make sure no deadlock is reported for this program which has no deadlocks.
|
||||||
* @modules java.base/jdk.internal.misc
|
* @modules java.base/jdk.internal.misc
|
||||||
@ -48,8 +49,9 @@ public class TestFalseDeadLock {
|
|||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
bean = ManagementFactory.getThreadMXBean();
|
bean = ManagementFactory.getThreadMXBean();
|
||||||
Thread[] threads = new Thread[500];
|
Thread[] threads = new Thread[500];
|
||||||
|
Random random = Utils.getRandomInstance();
|
||||||
for (int i = 0; i < threads.length; i++) {
|
for (int i = 0; i < threads.length; i++) {
|
||||||
Test t = new Test();
|
Test t = new Test(random.nextLong());
|
||||||
threads[i] = new Thread(t);
|
threads[i] = new Thread(t);
|
||||||
threads[i].start();
|
threads[i].start();
|
||||||
}
|
}
|
||||||
@ -67,8 +69,12 @@ public class TestFalseDeadLock {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static class Test implements Runnable {
|
public static class Test implements Runnable {
|
||||||
|
private final long seed;
|
||||||
|
public Test(long seed) {
|
||||||
|
this.seed = seed;
|
||||||
|
}
|
||||||
public void run() {
|
public void run() {
|
||||||
Random r = Utils.getRandomInstance();
|
Random r = new Random(seed);
|
||||||
while (running) {
|
while (running) {
|
||||||
try {
|
try {
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
|
Loading…
Reference in New Issue
Block a user