test/jdk/tools/jpackage/linux/base/Base.java
branchJDK-8200758-branch
changeset 57543 bcd1ab268a7d
parent 57446 5a5b85f00a63
child 57591 6805e0ef7453
equal deleted inserted replaced
57532:eb0bd96672f4 57543:bcd1ab268a7d
    20  * or visit www.oracle.com if you need additional information or have any
    20  * or visit www.oracle.com if you need additional information or have any
    21  * questions.
    21  * questions.
    22  */
    22  */
    23 
    23 
    24 import java.io.File;
    24 import java.io.File;
       
    25 import java.nio.file.Files;
    25 import java.util.ArrayList;
    26 import java.util.ArrayList;
    26 import java.util.List;
    27 import java.util.List;
    27 
    28 
    28 public class Base {
    29 public class Base {
    29 
    30 
    55         if (folder.exists()) {
    56         if (folder.exists()) {
    56             throw new AssertionError("Error: " + folder.getAbsolutePath() + " exist");
    57             throw new AssertionError("Error: " + folder.getAbsolutePath() + " exist");
    57         }
    58         }
    58     }
    59     }
    59 
    60 
    60     private static void init(String name, String ext) {
    61     static String getRpmArch() throws Exception {
       
    62         File out = File.createTempFile("rpmbuild", ".out");
       
    63         out.deleteOnExit();
       
    64         int code = JPackageHelper.execute(out, "rpmbuild", "-E=%{_target_cpu}");
       
    65         if (code != 0) {
       
    66             throw new AssertionError("Error: unable to get rpm arch");
       
    67         }
       
    68         return Files.readAllLines(out.toPath()).get(0);
       
    69     }
       
    70 
       
    71     private static void init(String name, String ext) throws Exception {
    61         TEST_NAME = name;
    72         TEST_NAME = name;
    62         EXT = ext;
    73         EXT = ext;
    63         if (EXT.equals("rpm")) {
    74         if (EXT.equals("rpm")) {
    64             OUTPUT = "output" + File.separator + TEST_NAME + "-1.0-1.x86_64." + EXT;
    75             OUTPUT = "output" + File.separator + TEST_NAME + "-1.0-1." + getRpmArch() + "." + EXT;
    65         } else {
    76         } else {
    66             OUTPUT = "output" + File.separator + TEST_NAME + "-1.0." + EXT;
    77             OUTPUT = "output" + File.separator + TEST_NAME + "-1.0." + EXT;
    67         }
    78         }
    68         CMD = new String[]{
    79         CMD = new String[]{
    69             "--package-type", EXT,
    80             "--package-type", EXT,