< prev index next >

test/jtreg-ext/requires/VMProps.java

Print this page
@  rev 55754 : 8228434: jdk/net/Sockets/Test.java fails after JDK-8227642
|  Summary: Move container constant to separate test lib class
~  Reviewed-by: duke
o  rev 55753 : 8228434: jdk/net/Sockets/Test.java fails after JDK-8227642
|  Reviewed-by: duke
~


  29 import java.nio.file.Files;
  30 import java.nio.file.Path;
  31 import java.nio.file.Paths;
  32 import java.nio.file.StandardOpenOption;
  33 import java.util.ArrayList;
  34 import java.util.HashMap;
  35 import java.util.List;
  36 import java.util.Map;
  37 import java.util.Properties;
  38 import java.util.concurrent.Callable;
  39 import java.util.concurrent.TimeUnit;
  40 import java.util.function.Supplier;
  41 import java.util.regex.Matcher;
  42 import java.util.regex.Pattern;
  43 
  44 import sun.hotspot.code.Compiler;
  45 import sun.hotspot.cpuinfo.CPUInfo;
  46 import sun.hotspot.gc.GC;
  47 import sun.hotspot.WhiteBox;
  48 import jdk.test.lib.Platform;

  49 
  50 /**
  51  * The Class to be invoked by jtreg prior Test Suite execution to
  52  * collect information about VM.
  53  * Do not use any APIs that may not be available in all target VMs.
  54  * Properties set by this Class will be available in the @requires expressions.
  55  */
  56 public class VMProps implements Callable<Map<String, String>> {
  57     // value known to jtreg as an indicator of error state
  58     private static final String ERROR_STATE = "__ERROR__";
  59 
  60     private static final WhiteBox WB = WhiteBox.getWhiteBox();
  61 
  62     private static class SafeMap {
  63         private final Map<String, String> map = new HashMap<>();
  64 
  65         public void put(String key, Supplier<String> s) {
  66             String value;
  67             try {
  68                 value = s.get();


 438               isSupported = true;
 439            } else if (Platform.isS390x()) {
 440               isSupported = true;
 441            } else if (arch.equals("ppc64le")) {
 442               isSupported = true;
 443            }
 444         }
 445 
 446         if (isSupported) {
 447            try {
 448               isSupported = checkDockerSupport();
 449            } catch (Exception e) {
 450               isSupported = false;
 451            }
 452          }
 453 
 454         return "" + isSupported;
 455     }
 456 
 457     private boolean checkDockerSupport() throws IOException, InterruptedException {
 458         ProcessBuilder pb = new ProcessBuilder(Platform.DOCKER_COMMAND, "ps");
 459         Process p = pb.start();
 460         p.waitFor(10, TimeUnit.SECONDS);
 461 
 462         return (p.exitValue() == 0);
 463     }
 464 
 465     private String implementor() {
 466         try (InputStream in = new BufferedInputStream(new FileInputStream(
 467                 System.getProperty("java.home") + "/release"))) {
 468             Properties properties = new Properties();
 469             properties.load(in);
 470             String implementorProperty = properties.getProperty("IMPLEMENTOR");
 471             if (implementorProperty != null) {
 472                 return implementorProperty.replace("\"", "");
 473             }
 474             return errorWithMessage("Can't get 'IMPLEMENTOR' property from 'release' file");
 475         } catch (IOException e) {
 476             e.printStackTrace();
 477             return errorWithMessage("Failed to read 'release' file " + e);
 478         }




  29 import java.nio.file.Files;
  30 import java.nio.file.Path;
  31 import java.nio.file.Paths;
  32 import java.nio.file.StandardOpenOption;
  33 import java.util.ArrayList;
  34 import java.util.HashMap;
  35 import java.util.List;
  36 import java.util.Map;
  37 import java.util.Properties;
  38 import java.util.concurrent.Callable;
  39 import java.util.concurrent.TimeUnit;
  40 import java.util.function.Supplier;
  41 import java.util.regex.Matcher;
  42 import java.util.regex.Pattern;
  43 
  44 import sun.hotspot.code.Compiler;
  45 import sun.hotspot.cpuinfo.CPUInfo;
  46 import sun.hotspot.gc.GC;
  47 import sun.hotspot.WhiteBox;
  48 import jdk.test.lib.Platform;
  49 import jdk.test.lib.Container;
  50 
  51 /**
  52  * The Class to be invoked by jtreg prior Test Suite execution to
  53  * collect information about VM.
  54  * Do not use any APIs that may not be available in all target VMs.
  55  * Properties set by this Class will be available in the @requires expressions.
  56  */
  57 public class VMProps implements Callable<Map<String, String>> {
  58     // value known to jtreg as an indicator of error state
  59     private static final String ERROR_STATE = "__ERROR__";
  60 
  61     private static final WhiteBox WB = WhiteBox.getWhiteBox();
  62 
  63     private static class SafeMap {
  64         private final Map<String, String> map = new HashMap<>();
  65 
  66         public void put(String key, Supplier<String> s) {
  67             String value;
  68             try {
  69                 value = s.get();


 439               isSupported = true;
 440            } else if (Platform.isS390x()) {
 441               isSupported = true;
 442            } else if (arch.equals("ppc64le")) {
 443               isSupported = true;
 444            }
 445         }
 446 
 447         if (isSupported) {
 448            try {
 449               isSupported = checkDockerSupport();
 450            } catch (Exception e) {
 451               isSupported = false;
 452            }
 453          }
 454 
 455         return "" + isSupported;
 456     }
 457 
 458     private boolean checkDockerSupport() throws IOException, InterruptedException {
 459         ProcessBuilder pb = new ProcessBuilder(Container.ENGINE_COMMAND, "ps");
 460         Process p = pb.start();
 461         p.waitFor(10, TimeUnit.SECONDS);
 462 
 463         return (p.exitValue() == 0);
 464     }
 465 
 466     private String implementor() {
 467         try (InputStream in = new BufferedInputStream(new FileInputStream(
 468                 System.getProperty("java.home") + "/release"))) {
 469             Properties properties = new Properties();
 470             properties.load(in);
 471             String implementorProperty = properties.getProperty("IMPLEMENTOR");
 472             if (implementorProperty != null) {
 473                 return implementorProperty.replace("\"", "");
 474             }
 475             return errorWithMessage("Can't get 'IMPLEMENTOR' property from 'release' file");
 476         } catch (IOException e) {
 477             e.printStackTrace();
 478             return errorWithMessage("Failed to read 'release' file " + e);
 479         }


< prev index next >