test/failure_handler/src/share/classes/jdk/test/failurehandler/jtreg/GatherDiagnosticInfoObserver.java
changeset 55320 670b4794f51e
parent 51280 a306c84e40fa
equal deleted inserted replaced
55319:c6498066a0a5 55320:670b4794f51e
     1 /*
     1 /*
     2  * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    24 package jdk.test.failurehandler.jtreg;
    24 package jdk.test.failurehandler.jtreg;
    25 
    25 
    26 import com.sun.javatest.Harness;
    26 import com.sun.javatest.Harness;
    27 import com.sun.javatest.Parameters;
    27 import com.sun.javatest.Parameters;
    28 import com.sun.javatest.TestResult;
    28 import com.sun.javatest.TestResult;
    29 import com.sun.javatest.InterviewParameters;
    29 import com.sun.javatest.regtest.config.RegressionParameters;
    30 import jdk.test.failurehandler.*;
    30 import jdk.test.failurehandler.*;
    31 
    31 
    32 import java.io.File;
    32 import java.io.File;
    33 import java.io.FileWriter;
    33 import java.io.FileWriter;
    34 import java.io.IOException;
    34 import java.io.IOException;
    44  */
    44  */
    45 public class GatherDiagnosticInfoObserver implements Harness.Observer {
    45 public class GatherDiagnosticInfoObserver implements Harness.Observer {
    46     public static final String LOG_FILENAME = "environment.log";
    46     public static final String LOG_FILENAME = "environment.log";
    47     public static final String ENVIRONMENT_OUTPUT = "environment.html";
    47     public static final String ENVIRONMENT_OUTPUT = "environment.html";
    48 
    48 
    49     private String compileJdk;
    49     private Path compileJdk;
    50     private String testJdk;
    50     private Path testJdk;
    51 
    51 
    52     /*
    52     /*
    53      * The harness calls this method after each test.
    53      * The harness calls this method after each test.
    54      */
    54      */
    55     @Override
    55     @Override
    78         }
    78         }
    79         try {
    79         try {
    80             log.printf("%s ---%n", name);
    80             log.printf("%s ---%n", name);
    81             GathererFactory gathererFactory = new GathererFactory(
    81             GathererFactory gathererFactory = new GathererFactory(
    82                     OS.current().family, workDir, log,
    82                     OS.current().family, workDir, log,
    83                     Paths.get(testJdk), Paths.get(compileJdk));
    83                     testJdk, compileJdk);
    84             gatherEnvInfo(workDir, name, log,
    84             gatherEnvInfo(workDir, name, log,
    85                     gathererFactory.getEnvironmentInfoGatherer());
    85                     gathererFactory.getEnvironmentInfoGatherer());
    86         } catch (Throwable e) {
    86         } catch (Throwable e) {
    87             log.printf("ERROR: exception in observer %s:", name);
    87             log.printf("ERROR: exception in observer %s:", name);
    88             e.printStackTrace(log);
    88             e.printStackTrace(log);
   115     /*
   115     /*
   116      * The harness calls this method one time per run, not per test.
   116      * The harness calls this method one time per run, not per test.
   117      */
   117      */
   118     @Override
   118     @Override
   119     public void startingTestRun(Parameters params) {
   119     public void startingTestRun(Parameters params) {
   120         // TODO find a better way to get JDKs
   120         RegressionParameters rp = (RegressionParameters) params;
   121         InterviewParameters rp = (InterviewParameters) params;
   121         compileJdk = rp.getCompileJDK().getAbsoluteFile().toPath();
   122         Map<String, String> map = new HashMap<>();
   122         testJdk = rp.getTestJDK().getAbsoluteFile().toPath();
   123         rp.save(map);
       
   124         compileJdk = map.get("regtest.compilejdk");
       
   125         testJdk = map.get("regtest.testjdk");
       
   126     }
   123     }
   127 
   124 
   128     @Override
   125     @Override
   129     public void startingTest(TestResult tr) {
   126     public void startingTest(TestResult tr) {
   130         // no-op
   127         // no-op