1 /* 2 * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 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 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 import jdk.jpackage.test.TKit; 25 import jdk.jpackage.test.PackageTest; 26 import jdk.jpackage.test.PackageType; 27 import jdk.jpackage.test.LinuxHelper; 28 29 30 /** 31 * Test --linux-package-deps parameter. Output of the test should be 32 * apackagedepstestprereq_1.0-1_amd64.deb and packagedepstest_1.0-1_amd64.deb or 33 * apackagedepstestprereq-1.0-1.amd64.rpm and packagedepstest-1.0-1.amd64.rpm 34 * package bundles. The output packages should provide the same functionality as 35 * the default package. 36 * 37 * deb: Value of Depends property of packagedepstest package should contain 38 * apackagedepstestprereq word. 39 * 40 * rpm: Value of Requires property of packagedepstest package should contain 41 * apackagedepstestprereq word. 42 */ 43 44 45 /* 46 * @test 47 * @summary jpackage with --linux-package-deps 48 * @library ../helpers 49 * @key jpackagePlatformPackage 50 * @build jdk.jpackage.test.* 51 * @requires (os.family == "linux") 52 * @modules jdk.incubator.jpackage/jdk.incubator.jpackage.internal 53 * @run main/othervm/timeout=360 -Xmx512m PackageDepsTest 54 */ 55 public class PackageDepsTest { 56 57 public static void main(String[] args) { 58 // Pick the name of prerequisite package to be alphabetically 59 // preceeding the main package name. 60 // This is needed to make Bash script batch installing/uninstalling packages 61 // produced by jtreg tests install/uninstall packages in the right order. 62 final String PREREQ_PACKAGE_NAME = "apackagedepstestprereq"; 63 64 TKit.run(args, () -> { 65 new PackageTest() 66 .forTypes(PackageType.LINUX) 67 .configureHelloApp() 68 .addInitializer(cmd -> { 69 cmd.setArgumentValue("--name", PREREQ_PACKAGE_NAME); 70 }) 71 .run(); 72 73 new PackageTest() 74 .forTypes(PackageType.LINUX) 75 .configureHelloApp() 76 .addInitializer(cmd -> { 77 cmd.addArguments("--linux-package-deps", PREREQ_PACKAGE_NAME); 78 }) 79 .forTypes(PackageType.LINUX) 80 .addBundleVerifier(cmd -> { 81 TKit.assertTrue( 82 LinuxHelper.getPrerequisitePackages(cmd).contains( 83 PREREQ_PACKAGE_NAME), String.format( 84 "Check package depends on [%s] package", 85 PREREQ_PACKAGE_NAME)); 86 }) 87 .run(); 88 }); 89 } 90 }