changeset 54072:1ae0b76bb5df

8217744: [TESTBUG] JFR TestShutdownEvent fails on some systems due to process surviving SIGINT Summary: changed handling of cases when child process suvives the signal Reviewed-by: egahlin
author mseledtsov
date Tue, 29 Jan 2019 15:13:35 -0800
parents fc5a68ff2c0b
children b92b0baa7afd a4b7ea85d668
files test/jdk/jdk/jfr/event/runtime/TestShutdownEvent.java
diffstat 1 files changed, 18 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/test/jdk/jdk/jfr/event/runtime/TestShutdownEvent.java	Tue Jan 29 13:39:40 2019 -0800
+++ b/test/jdk/jdk/jfr/event/runtime/TestShutdownEvent.java	Tue Jan 29 15:13:35 2019 -0800
@@ -61,10 +61,9 @@
              new TestVMCrash(),
              new TestUnhandledException(),
              new TestRuntimeHalt(),
-             // exclude until JDK-8217744 is fixed
-             // new TestSig("TERM"),
-             // new TestSig("HUP"),
-             // new TestSig("INT")
+             new TestSig("TERM"),
+             new TestSig("HUP"),
+             new TestSig("INT")
     };
 
     public static void main(String[] args) throws Throwable {
@@ -87,7 +86,8 @@
                                 String.valueOf(subTestIndex));
         OutputAnalyzer output = ProcessTools.executeProcess(pb);
         System.out.println(output.getOutput());
-        System.out.println("Exit code: " + output.getExitValue());
+        int exitCode = output.getExitValue();
+        System.out.println("Exit code: " + exitCode);
 
         String recordingName = output.firstMatch("emergency jfr file: (.*.jfr)", 1);
         if (recordingName == null) {
@@ -102,7 +102,7 @@
 
         Asserts.assertEquals(filteredEvents.size(), 1);
         RecordedEvent event = filteredEvents.get(0);
-        subTests[subTestIndex].verifyEvents(event);
+        subTests[subTestIndex].verifyEvents(event, exitCode);
     }
 
     @SuppressWarnings("unused")
@@ -119,7 +119,7 @@
             return true;
         }
         void runTest();
-        void verifyEvents(RecordedEvent event);
+        void verifyEvents(RecordedEvent event, int exitCode);
     }
 
     // Basic stack trace validation, checking that the runTest method is part of the stack
@@ -139,7 +139,7 @@
         }
 
         @Override
-        public void verifyEvents(RecordedEvent event) {
+        public void verifyEvents(RecordedEvent event, int exitCode) {
             Events.assertField(event, "reason").equal("No remaining non-daemon Java threads");
         }
     }
@@ -152,7 +152,7 @@
         }
 
         @Override
-        public void verifyEvents(RecordedEvent event) {
+        public void verifyEvents(RecordedEvent event, int exitCode) {
             Events.assertField(event, "reason").equal("Shutdown requested from Java");
             validateStackTrace(event.getStackTrace());
         }
@@ -167,7 +167,7 @@
         }
 
         @Override
-        public void verifyEvents(RecordedEvent event) {
+        public void verifyEvents(RecordedEvent event, int exitCode) {
             Events.assertField(event, "reason").equal("VM Error");
             validateStackTrace(event.getStackTrace());
         }
@@ -180,7 +180,7 @@
         }
 
         @Override
-        public void verifyEvents(RecordedEvent event) {
+        public void verifyEvents(RecordedEvent event, int exitCode) {
             Events.assertField(event, "reason").equal("No remaining non-daemon Java threads");
         }
     }
@@ -193,7 +193,7 @@
         }
 
         @Override
-        public void verifyEvents(RecordedEvent event) {
+        public void verifyEvents(RecordedEvent event, int exitCode) {
             Events.assertField(event, "reason").equal("Shutdown requested from Java");
             validateStackTrace(event.getStackTrace());
         }
@@ -229,11 +229,15 @@
             } catch (IOException e) {
                 e.printStackTrace();
             }
-            Asserts.fail("Process survived the SIG" + signalName + " signal!");
+            System.out.println("Process survived the SIG" + signalName + " signal!");
         }
 
         @Override
-        public void verifyEvents(RecordedEvent event) {
+        public void verifyEvents(RecordedEvent event, int exitCode) {
+            if (exitCode == 0) {
+                System.out.println("Process exited normally with exit code 0, skipping the verification");
+                return;
+            }
             Events.assertField(event, "reason").equal("Shutdown requested from Java");
             Events.assertEventThread(event);
             Asserts.assertEquals(event.getThread().getJavaName(), "SIG" + signalName + " handler");