changeset 58837:991acdf0e37f

8219686: jdk/jfr/event/runtime/TestShutdownEvent.java recording file length is 0 Reviewed-by: mgronlun, mseledtsov
author egahlin
date Thu, 30 Jan 2020 17:36:01 +0100
parents 2dbf459b5577
children 9211f6e20448
files test/jdk/jdk/jfr/event/runtime/TestShutdownEvent.java
diffstat 1 files changed, 29 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/test/jdk/jdk/jfr/event/runtime/TestShutdownEvent.java	Thu Jan 30 17:23:22 2020 +0100
+++ b/test/jdk/jdk/jfr/event/runtime/TestShutdownEvent.java	Thu Jan 30 17:36:01 2020 +0100
@@ -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
@@ -68,11 +68,25 @@
 
     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);
         }
     }
 
@@ -115,8 +129,8 @@
     }
 
     private interface ShutdownEventSubTest {
-        default boolean isApplicable() {
-            return true;
+        default int attempts() {
+            return 1;
         }
         void runTest();
         void verifyEvents(RecordedEvent event, int exitCode);
@@ -174,6 +188,11 @@
             // 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 {
@@ -207,14 +226,14 @@
         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) {