Skip to content

Commit

Permalink
8219686: jdk/jfr/event/runtime/TestShutdownEvent.java recording file …
Browse files Browse the repository at this point in the history
…length is 0

Reviewed-by: mgronlun, mseledtsov
  • Loading branch information
egahlin committed Jan 30, 2020
1 parent 9cfd632 commit cb636b2
Showing 1 changed file with 29 additions and 10 deletions.
39 changes: 29 additions & 10 deletions test/jdk/jdk/jfr/event/runtime/TestShutdownEvent.java
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2019, 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.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -68,11 +68,25 @@ public class TestShutdownEvent {

public static void main(String[] args) throws Throwable {
for (int i = 0; i < subTests.length; ++i) {
if (subTests[i].isApplicable()) {
runSubtest(i);
} else {
int attempts = subTests[i].attempts();
if (attempts == 0) {
System.out.println("Skipping non-applicable test: " + i);
}
for (int j = 0; j < attempts -1; j++) {
try {
runSubtest(i);
return;
} catch (Exception e) {
System.out.println("Failed: " + e.getMessage());
System.out.println();
System.out.println("Retry " + i + 1);
} catch (OutOfMemoryError | StackOverflowError e) {
System.out.println("Error");
// Can happen when parsing corrupt file. Abort test.
return;
}
}
runSubtest(i);
}
}

Expand Down Expand Up @@ -115,8 +129,8 @@ public static void main(String[] args) throws Exception {
}

private interface ShutdownEventSubTest {
default boolean isApplicable() {
return true;
default int attempts() {
return 1;
}
void runTest();
void verifyEvents(RecordedEvent event, int exitCode);
Expand Down Expand Up @@ -174,6 +188,11 @@ public void verifyEvents(RecordedEvent event, int exitCode) {
// see 8219082 for details (running the crashed VM with -Xint would solve the issue too)
//validateStackTrace(event.getStackTrace());
}

@Override
public int attempts() {
return 3;
}
}

private static class TestUnhandledException implements ShutdownEventSubTest {
Expand Down Expand Up @@ -207,14 +226,14 @@ private static class TestSig implements ShutdownEventSubTest {
private final String signalName;

@Override
public boolean isApplicable() {
public int attempts() {
if (Platform.isWindows()) {
return false;
return 0;
}
if (signalName.equals("HUP") && Platform.isSolaris()) {
return false;
return 0;
}
return true;
return 1;
}

public TestSig(String signalName) {
Expand Down

0 comments on commit cb636b2

Please sign in to comment.