8219158: use 'test.root' property instead of traversing test-src path
authoriignatyev
Fri, 22 Feb 2019 11:07:18 -0800
changeset 53903 68bbd727dd5f
parent 53902 7a6fd71449e7
child 53904 9c3fe09f69bc
8219158: use 'test.root' property instead of traversing test-src path Reviewed-by: dholmes
test/hotspot/jtreg/vmTestbase/gc/g1/unloading/GenClassesBuilder.java
test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/classload/GenClassesBuilder.java
test/hotspot/jtreg/vmTestbase/vm/mlvm/share/StratumClassesBuilder.java
test/hotspot/jtreg/vmTestbase/vm/runtime/defmeth/shared/BuildJar.java
test/lib/jdk/test/lib/Utils.java
--- a/test/hotspot/jtreg/vmTestbase/gc/g1/unloading/GenClassesBuilder.java	Fri Feb 22 10:13:34 2019 -0800
+++ b/test/hotspot/jtreg/vmTestbase/gc/g1/unloading/GenClassesBuilder.java	Fri Feb 22 11:07:18 2019 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2019, 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
@@ -35,12 +35,13 @@
  */
 public class GenClassesBuilder {
     public static void main(String[] args) {
-        Path template = testRoot().resolve("vmTestbase")
-                                  .resolve("gc")
-                                  .resolve("g1")
-                                  .resolve("unloading")
-                                  .resolve("ClassNNN.java.template")
-                                  .toAbsolutePath();
+        Path template = Paths.get(Utils.TEST_ROOT)
+                             .resolve("vmTestbase")
+                             .resolve("gc")
+                             .resolve("g1")
+                             .resolve("unloading")
+                             .resolve("ClassNNN.java.template")
+                             .toAbsolutePath();
         Path dir = Paths.get(".").toAbsolutePath();
         String count = "1000";
         if (Files.notExists(template)) {
@@ -52,14 +53,6 @@
             throw new Error("can't generate classPool.jar", e);
         }
     }
-
-    private static Path testRoot() {
-        Path p = Paths.get(Utils.TEST_SRC);
-        while (!Files.exists(p.resolve("TEST.ROOT"))) {
-            p = p.getParent();
-        }
-        return p;
-    }
 }
 
 
--- a/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/classload/GenClassesBuilder.java	Fri Feb 22 10:13:34 2019 -0800
+++ b/test/hotspot/jtreg/vmTestbase/nsk/monitoring/stress/classload/GenClassesBuilder.java	Fri Feb 22 11:07:18 2019 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2019, 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
@@ -79,12 +79,13 @@
         } catch (IOException e) {
             throw new Error("can't create dirs for" + dir, e);
         }
-        Path pattern = testRoot().resolve("vmTestbase")
-                                 .resolve("nsk")
-                                 .resolve("monitoring")
-                                 .resolve("share")
-                                 .resolve("LoadableClass.pattern")
-                                 .toAbsolutePath();
+        Path pattern = Paths.get(Utils.TEST_ROOT)
+                            .resolve("vmTestbase")
+                            .resolve("nsk")
+                            .resolve("monitoring")
+                            .resolve("share")
+                            .resolve("LoadableClass.pattern")
+                            .toAbsolutePath();
         if (Files.notExists(pattern)) {
             throw new Error("can't find pattern file: " + pattern);
         }
@@ -94,13 +95,5 @@
             throw new Error("can't generate classes", e);
         }
     }
-
-    private static Path testRoot() {
-        Path p = Paths.get(Utils.TEST_SRC);
-        while (!Files.exists(p.resolve("TEST.ROOT"))) {
-            p = p.getParent();
-        }
-        return p;
-    }
 }
 
--- a/test/hotspot/jtreg/vmTestbase/vm/mlvm/share/StratumClassesBuilder.java	Fri Feb 22 10:13:34 2019 -0800
+++ b/test/hotspot/jtreg/vmTestbase/vm/mlvm/share/StratumClassesBuilder.java	Fri Feb 22 11:07:18 2019 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 2019, 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
@@ -38,7 +38,7 @@
 
 public class StratumClassesBuilder {
     public static void main(String[] args) {
-        Path root = testRoot();
+        Path root = Paths.get(Utils.TEST_ROOT);
         Arrays.stream(args)
               .map(root::resolve)
               .forEach(StratumClassesBuilder::build);
@@ -113,12 +113,4 @@
         return file.getParent()
                    .resolve(filename.replaceFirst("\\.class$", ".smap"));
     }
-
-    private static Path testRoot() {
-        Path p = Paths.get(Utils.TEST_SRC);
-        while (!Files.exists(p.resolve("TEST.ROOT"))) {
-            p = p.getParent();
-        }
-        return p;
-    }
 }
--- a/test/hotspot/jtreg/vmTestbase/vm/runtime/defmeth/shared/BuildJar.java	Fri Feb 22 10:13:34 2019 -0800
+++ b/test/hotspot/jtreg/vmTestbase/vm/runtime/defmeth/shared/BuildJar.java	Fri Feb 22 11:07:18 2019 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2019, 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
@@ -41,13 +41,14 @@
  */
 public class BuildJar {
     public static void main(String[] args) {
-        Path manifest = testRoot().resolve("vmTestbase")
-                                  .resolve("vm")
-                                  .resolve("runtime")
-                                  .resolve("defmeth")
-                                  .resolve("shared")
-                                  .resolve("retransform.mf")
-                                  .toAbsolutePath();
+        Path manifest = Paths.get(Utils.TEST_ROOT)
+                             .resolve("vmTestbase")
+                             .resolve("vm")
+                             .resolve("runtime")
+                             .resolve("defmeth")
+                             .resolve("shared")
+                             .resolve("retransform.mf")
+                             .toAbsolutePath();
         if (Files.notExists(manifest)) {
             throw new Error("can't find manifest file: " + manifest);
         }
@@ -90,13 +91,5 @@
         }
         throw new Error("can't find " + file + " in " + Utils.TEST_CLASS_PATH);
     }
-
-    private static Path testRoot() {
-        Path p = Paths.get(Utils.TEST_SRC);
-        while (!Files.exists(p.resolve("TEST.ROOT"))) {
-            p = p.getParent();
-        }
-        return p;
-    }
 }
 
--- a/test/lib/jdk/test/lib/Utils.java	Fri Feb 22 10:13:34 2019 -0800
+++ b/test/lib/jdk/test/lib/Utils.java	Fri Feb 22 11:07:18 2019 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2019, 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
@@ -88,6 +88,11 @@
      */
     public static final String TEST_SRC = System.getProperty("test.src", "").trim();
 
+    /**
+     * Returns the value of 'test.root' system property.
+     */
+    public static final String TEST_ROOT = System.getProperty("test.root", "").trim();
+
     /*
      * Returns the value of 'test.jdk' system property
      */
@@ -96,12 +101,13 @@
     /*
      * Returns the value of 'compile.jdk' system property
      */
-    public static final String COMPILE_JDK= System.getProperty("compile.jdk", TEST_JDK);
+    public static final String COMPILE_JDK = System.getProperty("compile.jdk", TEST_JDK);
 
     /**
      * Returns the value of 'test.classes' system property
      */
     public static final String TEST_CLASSES = System.getProperty("test.classes", ".");
+
     /**
      * Defines property name for seed value.
      */
@@ -118,9 +124,9 @@
      */
     public static final long SEED = Long.getLong(SEED_PROPERTY_NAME, new Random().nextLong());
     /**
-    * Returns the value of 'test.timeout.factor' system property
-    * converted to {@code double}.
-    */
+     * Returns the value of 'test.timeout.factor' system property
+     * converted to {@code double}.
+     */
     public static final double TIMEOUT_FACTOR;
     static {
         String toFactor = System.getProperty("test.timeout.factor", "1.0");
@@ -128,9 +134,9 @@
     }
 
     /**
-    * Returns the value of JTREG default test timeout in milliseconds
-    * converted to {@code long}.
-    */
+     * Returns the value of JTREG default test timeout in milliseconds
+     * converted to {@code long}.
+     */
     public static final long DEFAULT_TEST_TIMEOUT = TimeUnit.SECONDS.toMillis(120);
 
     private Utils() {