8242311: use reproducible random in hotspot runtime tests
Reviewed-by: iklam, mseledtsov
This commit is contained in:
parent
116fe806c3
commit
c73934d8c8
@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* @test
|
* @test
|
||||||
* @key nmt jcmd
|
* @key nmt jcmd randomness
|
||||||
* @library /test/lib
|
* @library /test/lib
|
||||||
* @modules java.base/jdk.internal.misc
|
* @modules java.base/jdk.internal.misc
|
||||||
* java.management
|
* java.management
|
||||||
@ -38,6 +38,7 @@ import java.util.Random;
|
|||||||
import jdk.test.lib.process.ProcessTools;
|
import jdk.test.lib.process.ProcessTools;
|
||||||
import jdk.test.lib.process.OutputAnalyzer;
|
import jdk.test.lib.process.OutputAnalyzer;
|
||||||
import jdk.test.lib.JDKToolFinder;
|
import jdk.test.lib.JDKToolFinder;
|
||||||
|
import jdk.test.lib.Utils;
|
||||||
import sun.hotspot.WhiteBox;
|
import sun.hotspot.WhiteBox;
|
||||||
|
|
||||||
public class HugeArenaTracking {
|
public class HugeArenaTracking {
|
||||||
@ -59,7 +60,7 @@ public class HugeArenaTracking {
|
|||||||
output = new OutputAnalyzer(pb.start());
|
output = new OutputAnalyzer(pb.start());
|
||||||
output.shouldContain("Test (reserved=2KB, committed=2KB)");
|
output.shouldContain("Test (reserved=2KB, committed=2KB)");
|
||||||
|
|
||||||
Random rand = new Random();
|
Random rand = Utils.getRandomInstance();
|
||||||
|
|
||||||
// Allocate 2GB+ from arena
|
// Allocate 2GB+ from arena
|
||||||
long total = 0;
|
long total = 0;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2014, 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
|
||||||
@ -24,7 +24,7 @@
|
|||||||
/*
|
/*
|
||||||
* @test
|
* @test
|
||||||
* @summary Stress test for malloc tracking
|
* @summary Stress test for malloc tracking
|
||||||
* @key nmt jcmd stress
|
* @key nmt jcmd stress randomness
|
||||||
* @library /test/lib
|
* @library /test/lib
|
||||||
* @modules java.base/jdk.internal.misc
|
* @modules java.base/jdk.internal.misc
|
||||||
* java.management
|
* java.management
|
||||||
@ -39,6 +39,7 @@ import java.util.List;
|
|||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import jdk.test.lib.JDKToolFinder;
|
import jdk.test.lib.JDKToolFinder;
|
||||||
import jdk.test.lib.Platform;
|
import jdk.test.lib.Platform;
|
||||||
|
import jdk.test.lib.Utils;
|
||||||
import jdk.test.lib.process.ProcessTools;
|
import jdk.test.lib.process.ProcessTools;
|
||||||
import jdk.test.lib.process.OutputAnalyzer;
|
import jdk.test.lib.process.OutputAnalyzer;
|
||||||
import sun.hotspot.WhiteBox;
|
import sun.hotspot.WhiteBox;
|
||||||
@ -159,6 +160,7 @@ public class MallocStressTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static class AllocThread extends Thread {
|
static class AllocThread extends Thread {
|
||||||
|
private final Random random = new Random(Utils.getRandomInstance().nextLong());
|
||||||
AllocThread() {
|
AllocThread() {
|
||||||
this.setName("MallocThread");
|
this.setName("MallocThread");
|
||||||
this.start();
|
this.start();
|
||||||
@ -166,7 +168,6 @@ public class MallocStressTest {
|
|||||||
|
|
||||||
// AllocThread only runs "Alloc" phase
|
// AllocThread only runs "Alloc" phase
|
||||||
public void run() {
|
public void run() {
|
||||||
Random random = new Random();
|
|
||||||
// MallocStressTest.phase == TestPhase.alloc
|
// MallocStressTest.phase == TestPhase.alloc
|
||||||
for (int loops = 0; loops < 100; loops++) {
|
for (int loops = 0; loops < 100; loops++) {
|
||||||
int r = random.nextInt(Integer.MAX_VALUE);
|
int r = random.nextInt(Integer.MAX_VALUE);
|
||||||
@ -201,7 +202,7 @@ public class MallocStressTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static class ReleaseThread extends Thread {
|
static class ReleaseThread extends Thread {
|
||||||
private Random random = new Random();
|
private final Random random = new Random(Utils.getRandomInstance().nextLong());
|
||||||
ReleaseThread() {
|
ReleaseThread() {
|
||||||
this.setName("ReleaseThread");
|
this.setName("ReleaseThread");
|
||||||
this.start();
|
this.start();
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2014, 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
|
||||||
@ -25,7 +25,7 @@
|
|||||||
* @test
|
* @test
|
||||||
* @bug 8054836
|
* @bug 8054836
|
||||||
* @summary Test to verify correctness of malloc tracking
|
* @summary Test to verify correctness of malloc tracking
|
||||||
* @key nmt jcmd
|
* @key nmt jcmd randomness
|
||||||
* @library /test/lib
|
* @library /test/lib
|
||||||
* @modules java.base/jdk.internal.misc
|
* @modules java.base/jdk.internal.misc
|
||||||
* java.management
|
* java.management
|
||||||
@ -41,6 +41,7 @@ import java.util.Random;
|
|||||||
import jdk.test.lib.process.ProcessTools;
|
import jdk.test.lib.process.ProcessTools;
|
||||||
import jdk.test.lib.process.OutputAnalyzer;
|
import jdk.test.lib.process.OutputAnalyzer;
|
||||||
import jdk.test.lib.JDKToolFinder;
|
import jdk.test.lib.JDKToolFinder;
|
||||||
|
import jdk.test.lib.Utils;
|
||||||
|
|
||||||
import sun.hotspot.WhiteBox;
|
import sun.hotspot.WhiteBox;
|
||||||
|
|
||||||
@ -58,7 +59,7 @@ public class MallocTrackingVerify {
|
|||||||
String pid = Long.toString(ProcessTools.getProcessId());
|
String pid = Long.toString(ProcessTools.getProcessId());
|
||||||
ProcessBuilder pb = new ProcessBuilder();
|
ProcessBuilder pb = new ProcessBuilder();
|
||||||
|
|
||||||
Random random = new Random();
|
Random random = Utils.getRandomInstance();
|
||||||
// Allocate small amounts of memory with random pseudo call stack
|
// Allocate small amounts of memory with random pseudo call stack
|
||||||
while (mallocd_total < MAX_ALLOC) {
|
while (mallocd_total < MAX_ALLOC) {
|
||||||
int size = random.nextInt(31) + 1;
|
int size = random.nextInt(31) + 1;
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* @test
|
* @test
|
||||||
|
* @key randomness
|
||||||
* @summary SharedArchiveConsistency
|
* @summary SharedArchiveConsistency
|
||||||
* @requires vm.cds
|
* @requires vm.cds
|
||||||
* @library /test/lib
|
* @library /test/lib
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2017, 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
|
||||||
@ -24,6 +24,7 @@
|
|||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import jdk.test.lib.Utils;
|
||||||
import sun.hotspot.WhiteBox;
|
import sun.hotspot.WhiteBox;
|
||||||
|
|
||||||
// All strings in archived classes are shared
|
// All strings in archived classes are shared
|
||||||
@ -43,7 +44,7 @@ public class GCStressApp {
|
|||||||
|
|
||||||
static void allocAlot() {
|
static void allocAlot() {
|
||||||
try {
|
try {
|
||||||
Random random = new Random();
|
Random random = Utils.getRandomInstance();
|
||||||
for (int i = 0; i < 1024 * 1024; i++) {
|
for (int i = 0; i < 1024 * 1024; i++) {
|
||||||
int len = random.nextInt(10000);
|
int len = random.nextInt(10000);
|
||||||
arr = new int[len];
|
arr = new int[len];
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2017, 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
|
||||||
@ -24,12 +24,13 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* @test
|
* @test
|
||||||
|
* @key randomness
|
||||||
* @summary
|
* @summary
|
||||||
* @requires vm.cds.archived.java.heap
|
* @requires vm.cds.archived.java.heap
|
||||||
* @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds
|
* @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds
|
||||||
* @build sun.hotspot.WhiteBox
|
* @build sun.hotspot.WhiteBox jdk.test.lib.Utils
|
||||||
* @compile GCStressApp.java
|
* @compile GCStressApp.java
|
||||||
* @run driver ClassFileInstaller -jar gcstress.jar GCStressApp
|
* @run driver ClassFileInstaller -jar gcstress.jar GCStressApp jdk.test.lib.Utils
|
||||||
* @run driver ClassFileInstaller -jar WhiteBox.jar sun.hotspot.WhiteBox
|
* @run driver ClassFileInstaller -jar WhiteBox.jar sun.hotspot.WhiteBox
|
||||||
* @run driver GCStressTest
|
* @run driver GCStressTest
|
||||||
*/
|
*/
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||||
* Copyright (c) 2019 SAP SE. All rights reserved.
|
* Copyright (c) 2019 SAP SE. 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.
|
||||||
*
|
*
|
||||||
@ -24,6 +24,7 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @test
|
* @test
|
||||||
|
* @key randomness
|
||||||
* @summary Test extended NullPointerException message for
|
* @summary Test extended NullPointerException message for
|
||||||
* classfiles generated with debug information. In this case the name
|
* classfiles generated with debug information. In this case the name
|
||||||
* of the variable containing the array is printed.
|
* of the variable containing the array is printed.
|
||||||
@ -36,6 +37,7 @@
|
|||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* @test
|
* @test
|
||||||
|
* @key randomness
|
||||||
* @summary Test extended NullPointerException message for class
|
* @summary Test extended NullPointerException message for class
|
||||||
* files generated without debugging information. The message lists
|
* files generated without debugging information. The message lists
|
||||||
* detailed information about the entity that is null.
|
* detailed information about the entity that is null.
|
||||||
@ -53,11 +55,13 @@ import java.io.ObjectInputStream;
|
|||||||
import java.io.ObjectOutputStream;
|
import java.io.ObjectOutputStream;
|
||||||
import java.lang.invoke.MethodHandles.Lookup;
|
import java.lang.invoke.MethodHandles.Lookup;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
import jdk.internal.org.objectweb.asm.ClassWriter;
|
import jdk.internal.org.objectweb.asm.ClassWriter;
|
||||||
import jdk.internal.org.objectweb.asm.Label;
|
import jdk.internal.org.objectweb.asm.Label;
|
||||||
import jdk.internal.org.objectweb.asm.MethodVisitor;
|
import jdk.internal.org.objectweb.asm.MethodVisitor;
|
||||||
import jdk.test.lib.Asserts;
|
import jdk.test.lib.Asserts;
|
||||||
|
import jdk.test.lib.Utils;
|
||||||
|
|
||||||
import static java.lang.invoke.MethodHandles.lookup;
|
import static java.lang.invoke.MethodHandles.lookup;
|
||||||
import static jdk.internal.org.objectweb.asm.Opcodes.ACC_PUBLIC;
|
import static jdk.internal.org.objectweb.asm.Opcodes.ACC_PUBLIC;
|
||||||
@ -89,6 +93,7 @@ public class NullPointerExceptionTest {
|
|||||||
ArrayList<String> names = new ArrayList<>();
|
ArrayList<String> names = new ArrayList<>();
|
||||||
ArrayList<String> curr;
|
ArrayList<String> curr;
|
||||||
static boolean hasDebugInfo = false;
|
static boolean hasDebugInfo = false;
|
||||||
|
static final Random rng = Utils.getRandomInstance();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
staticArray = new int[1][][][];
|
staticArray = new int[1][][][];
|
||||||
@ -1421,9 +1426,9 @@ public class NullPointerExceptionTest {
|
|||||||
// is null. Make sure we don't print the wrong value.
|
// is null. Make sure we don't print the wrong value.
|
||||||
String s = null;
|
String s = null;
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
byte[] val = (Math.random() < 0.5 ? s : (new String[1])[0]).getBytes();
|
byte[] val = (rng.nextDouble() < 0.5 ? s : (new String[1])[0]).getBytes();
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
checkMessage(e, "byte[] val = (Math.random() < 0.5 ? s : (new String[1])[0]).getBytes();", e.getMessage(),
|
checkMessage(e, "byte[] val = (rng.nextDouble() < 0.5 ? s : (new String[1])[0]).getBytes();", e.getMessage(),
|
||||||
"Cannot invoke \"String.getBytes()\"");
|
"Cannot invoke \"String.getBytes()\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1435,9 +1440,9 @@ public class NullPointerExceptionTest {
|
|||||||
int[][] b = new int[2][];
|
int[][] b = new int[2][];
|
||||||
long index = 0;
|
long index = 0;
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
int val = (Math.random() < 0.5 ? a[(int)index] : b[(int)index])[13];
|
int val = (rng.nextDouble() < 0.5 ? a[(int)index] : b[(int)index])[13];
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
checkMessage(e, "int val = (Math.random() < 0.5 ? a[(int)index] : b[(int)index])[13]", e.getMessage(),
|
checkMessage(e, "int val = (rng.nextDouble() < 0.5 ? a[(int)index] : b[(int)index])[13]", e.getMessage(),
|
||||||
"Cannot load from int array");
|
"Cannot load from int array");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1448,18 +1453,18 @@ public class NullPointerExceptionTest {
|
|||||||
int[][] a = new int[1][];
|
int[][] a = new int[1][];
|
||||||
int[][] b = new int[2][];
|
int[][] b = new int[2][];
|
||||||
long index = 0;
|
long index = 0;
|
||||||
int val = (Math.random() < 0.5 ? a : b)[(int)index][13];
|
int val = (rng.nextDouble() < 0.5 ? a : b)[(int)index][13];
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
checkMessage(e, "int val = (Math.random() < 0.5 ? a : b)[(int)index][13]", e.getMessage(),
|
checkMessage(e, "int val = (rng.nextDouble() < 0.5 ? a : b)[(int)index][13]", e.getMessage(),
|
||||||
"Cannot load from int array because \"<array>[...]\" is null");
|
"Cannot load from int array because \"<array>[...]\" is null");
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
C c1 = new C();
|
C c1 = new C();
|
||||||
C c2 = new C();
|
C c2 = new C();
|
||||||
(Math.random() < 0.5 ? c1 : c2).to_d.num = 77;
|
(rng.nextDouble() < 0.5 ? c1 : c2).to_d.num = 77;
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
checkMessage(e, "(Math.random() < 0.5 ? c1 : c2).to_d.num = 77;", e.getMessage(),
|
checkMessage(e, "(rng.nextDouble() < 0.5 ? c1 : c2).to_d.num = 77;", e.getMessage(),
|
||||||
"Cannot assign field \"num\" because \"to_d\" is null");
|
"Cannot assign field \"num\" because \"to_d\" is null");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user