Skip to content

Commit

Permalink
Don't assume that G1 is default in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
stefank committed Apr 24, 2024
1 parent 5246553 commit 58e0e63
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 3 deletions.
31 changes: 31 additions & 0 deletions test/hotspot/gtest/gc/g1/test_g1ServiceThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ static void stop_service_thread(G1ServiceThread* thread) {

// Test that a task that is added during runtime gets run.
TEST_VM(G1ServiceThread, test_add) {
if (!UseG1GC) {
return;
}

// Create thread and let it start.
G1ServiceThread* st = new G1ServiceThread();
os::naked_short_sleep(500);
Expand All @@ -73,6 +77,10 @@ TEST_VM(G1ServiceThread, test_add) {
// Test that a task that is added while the service thread is
// waiting gets run in a timely manner.
TEST_VM(G1ServiceThread, test_add_while_waiting) {
if (!UseG1GC) {
return;
}

// Make sure default tasks use long intervals so that the service thread
// is doing a long wait for the next execution.
AutoModifyRestore<uintx> f1(G1PeriodicGCInterval, 100000);
Expand All @@ -94,6 +102,10 @@ TEST_VM(G1ServiceThread, test_add_while_waiting) {

// Test that a task with negative timeout is not rescheduled.
TEST_VM(G1ServiceThread, test_add_run_once) {
if (!UseG1GC) {
return;
}

// Create thread and let it start.
G1ServiceThread* st = new G1ServiceThread();
os::naked_short_sleep(500);
Expand Down Expand Up @@ -127,6 +139,10 @@ class TestTask : public G1ServiceTask {
};

TEST_VM(G1ServiceTaskQueue, add_ordered) {
if (!UseG1GC) {
return;
}

G1ServiceTaskQueue queue;

int num_test_tasks = 5;
Expand Down Expand Up @@ -162,18 +178,33 @@ TEST_VM(G1ServiceTaskQueue, add_ordered) {
#ifdef ASSERT
TEST_VM_ASSERT_MSG(G1ServiceTaskQueue, remove_from_empty,
".*Should never try to verify empty queue") {
if (!UseG1GC) {
assert(false, "Fake assert: Should never try to verify empty queue");
return;
}

G1ServiceTaskQueue queue;
queue.remove_front();
}

TEST_VM_ASSERT_MSG(G1ServiceTaskQueue, get_from_empty,
".*Should never try to verify empty queue") {
if (!UseG1GC) {
assert(false, "Fake assert: Should never try to verify empty queue");
return;
}

G1ServiceTaskQueue queue;
queue.front();
}

TEST_VM_ASSERT_MSG(G1ServiceTaskQueue, set_time_in_queue,
".*Not allowed to update time while in queue") {
if (!UseG1GC) {
assert(false, "Fake assert: Not allowed to update time while in queue");
return;
}

G1ServiceTaskQueue queue;
TestTask a(100);
queue.add_ordered(&a);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
* @library /test/lib
* @build jdk.test.whitebox.WhiteBox
* @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
* @run main/othervm -Xlog:gc+region=trace -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions -Xmx1g -Xms1g
* -XX:VerifyGCType=full -XX:+VerifyDuringGC -XX:+VerifyAfterGC -XX:+WhiteBoxAPI -Xbootclasspath/a:.
* @run main/othervm -XX:+UseG1GC -Xlog:gc+region=trace -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions
* -Xmx1g -Xms1g -XX:VerifyGCType=full -XX:+VerifyDuringGC -XX:+VerifyAfterGC -XX:+WhiteBoxAPI -Xbootclasspath/a:.
* gc.g1.pinnedobjs.TestPinnedHumongousFragmentation
*/

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
* java.management
* @build jdk.test.whitebox.WhiteBox
* @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. -XX:+ZapUnusedHeapArea -Xlog:gc,gc+ergo+cset=trace gc.g1.pinnedobjs.TestPinnedObjectContents
* @run main/othervm -XX:+UseG1GC -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. -XX:+ZapUnusedHeapArea -Xlog:gc,gc+ergo+cset=trace gc.g1.pinnedobjs.TestPinnedObjectContents
*/

package gc.g1.pinnedobjs;
Expand Down

0 comments on commit 58e0e63

Please sign in to comment.