1 /* 2 * Copyright (c) 2010, 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 /* 25 * @test 26 * @bug 6575373 27 * @summary verify segment limit 28 * @compile -XDignore.symbol.file Utils.java SegmentLimit.java 29 * @run main SegmentLimit 30 * @author ksrini 31 */ 32 33 import java.io.File; 34 import java.util.ArrayList; 35 import java.util.List; 36 37 /* 38 * Run this against a large jar file. The packer should generate only 39 * one segment, parse the output of the packer to verify if this is indeed true. 40 */ 41 42 public class SegmentLimit { 43 44 public static void main(String... args) { 45 File out = new File("test" + Utils.PACK_FILE_EXT); 46 out.delete(); 47 runPack200(out); 48 } 49 50 static void runPack200(File outFile) { 51 File sdkHome = Utils.JavaSDK; 52 File testJar = new File(new File(sdkHome, "lib"), "tools.jar"); 53 54 System.out.println("using pack200: " + Utils.getPack200Cmd()); 55 56 List<String> cmdsList = new ArrayList<String>(); 57 cmdsList.add(Utils.getPack200Cmd()); 58 cmdsList.add("--effort=1"); 59 cmdsList.add("--verbose"); 60 cmdsList.add("--no-gzip"); 61 cmdsList.add("--segment-limit=-1"); 62 cmdsList.add(outFile.getName()); 63 cmdsList.add(testJar.getAbsolutePath()); 64 List<String> outList = Utils.runExec(cmdsList); 65 66 int count = 0; 67 for (String line : outList) { 68 System.out.println(line); 69 if (line.matches(".*Transmitted.*files of.*input bytes in a segment of.*bytes")) { 70 count++; 71 } 72 } 73 if (count != 1) { 74 throw new Error("test fails: check for 0 or multiple segments"); 75 } 76 } 77 } 78