Path: blob/master/test/jdk/tools/jimage/JImageInfoTest.java
41144 views
/*1* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/*24* @test25* @summary Tests to verify jimage 'info' action26* @library /test/lib27* @modules jdk.jlink/jdk.tools.jimage28* @build jdk.test.lib.Asserts29* @run main JImageInfoTest30*/3132import java.util.Arrays;3334public class JImageInfoTest extends JImageCliTest {35public void testInfo() {36jimage("info", getImagePath())37.assertSuccess()38.resultChecker(r -> {39assertMatches("(?m)^\\s+Major Version: +[1-9]\\d*$.*", r.output);40assertMatches("(?m)^\\s+Minor Version: +\\d+$.*", r.output);41assertMatches("(?m)^\\s+Flags: +\\d+$.*", r.output);42assertMatches("(?m)^\\s+Resource Count: +\\d+$.*", r.output);43assertMatches("(?m)^\\s+Table Length: +\\d+$.*", r.output);44assertMatches("(?m)^\\s+Offsets Size: +\\d+$.*", r.output);45assertMatches("(?m)^\\s+Redirects Size: +\\d+$.*", r.output);46assertMatches("(?m)^\\s+Locations Size: +\\d+$.*", r.output);47assertMatches("(?m)^\\s+Strings Size: +\\d+$.*", r.output);48assertMatches("(?m)^\\s+Index Size: +\\d+$.*", r.output);49});50}5152public void testInfoHelp() {53for (String opt : Arrays.asList("-h", "--help")) {54jimage("info", opt)55.assertSuccess()56.resultChecker(r -> {57// info - descriptive text58assertMatches("\\s+info\\s+-\\s+.*", r.output);59});60}61}6263public void testInfoUnknownOption() {64jimage("info", "--unknown")65.assertFailure()66.assertShowsError();67}6869public static void main(String[] args) throws Throwable {70new JImageInfoTest().runTests();71}72}73747576