zgu@7079: /* zgu@7079: * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. zgu@7079: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. zgu@7079: * zgu@7079: * This code is free software; you can redistribute it and/or modify it zgu@7079: * under the terms of the GNU General Public License version 2 only, as zgu@7079: * published by the Free Software Foundation. zgu@7079: * zgu@7079: * This code is distributed in the hope that it will be useful, but WITHOUT zgu@7079: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or zgu@7079: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License zgu@7079: * version 2 for more details (a copy is included in the LICENSE file that zgu@7079: * accompanied this code). zgu@7079: * zgu@7079: * You should have received a copy of the GNU General Public License version zgu@7079: * 2 along with this work; if not, write to the Free Software Foundation, zgu@7079: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. zgu@7079: * zgu@7079: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA zgu@7079: * or visit www.oracle.com if you need additional information or have any zgu@7079: * questions. zgu@7079: */ zgu@7079: zgu@7079: /* zgu@7079: * @test zgu@7079: * @bug 8055061 zgu@7079: * @key nmt zgu@7079: * @library /testlibrary zgu@7079: * @run main NMTWithCDS zgu@7079: */ zgu@7079: import com.oracle.java.testlibrary.*; zgu@7079: zgu@7079: public class NMTWithCDS { zgu@7079: zgu@7079: public static void main(String[] args) throws Exception { zgu@7079: ProcessBuilder pb; zgu@7079: pb = ProcessTools.createJavaProcessBuilder("-XX:SharedArchiveFile=./sample.jsa", "-Xshare:dump"); zgu@7079: OutputAnalyzer output = new OutputAnalyzer(pb.start()); zgu@7079: try { zgu@7079: output.shouldContain("Loading classes to share"); zgu@7079: output.shouldHaveExitValue(0); zgu@7079: zgu@7079: pb = ProcessTools.createJavaProcessBuilder( zgu@7079: "-XX:NativeMemoryTracking=detail", "-XX:SharedArchiveFile=./sample.jsa", "-Xshare:on", "-version"); zgu@7079: output = new OutputAnalyzer(pb.start()); zgu@7079: output.shouldContain("sharing"); zgu@7079: output.shouldHaveExitValue(0); zgu@7079: zgu@7079: } catch (RuntimeException e) { zgu@7079: // Report 'passed' if CDS was turned off. zgu@7079: output.shouldContain("Unable to use shared archive"); zgu@7079: output.shouldHaveExitValue(1); zgu@7079: } zgu@7079: } zgu@7079: }