|
| 1 | +/* |
| 2 | + * Copyright (c) 2013, 2020, 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 | +/* |
| 26 | + * @test |
| 27 | + * @summary Test that VM rejects and invalid replay file. |
| 28 | + * @library /test/lib |
| 29 | + * @requires vm.compMode != "Xint" |
| 30 | + * @modules java.base/jdk.internal.misc |
| 31 | + * java.management |
| 32 | + * @run driver TestInvalidReplayFile |
| 33 | + */ |
| 34 | + |
| 35 | +import jdk.test.lib.process.OutputAnalyzer; |
| 36 | +import jdk.test.lib.process.ProcessTools; |
| 37 | + |
| 38 | +import java.io.File; |
| 39 | +import java.io.FileWriter; |
| 40 | + |
| 41 | +public class TestInvalidReplayFile { |
| 42 | + |
| 43 | + |
| 44 | + public static void main(String[] args) throws Exception { |
| 45 | + |
| 46 | + // This test also serves as a very basic sanity test for release VMs (accepting the replay options and |
| 47 | + // attempting to read the replay file). Most of the tests in ciReplay use -XX:CICrashAt to induce artificial |
| 48 | + // crashes into the compiler, and that option is not available for release VMs. Therefore we cannot generate |
| 49 | + // replay files as a test in release builds. |
| 50 | + |
| 51 | + File f = new File("bogus-replay-file.txt"); |
| 52 | + FileWriter w = new FileWriter(f); |
| 53 | + w.write("Bogus 123"); |
| 54 | + w.flush(); |
| 55 | + w.close(); |
| 56 | + |
| 57 | + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( |
| 58 | + "-XX:+UnlockDiagnosticVMOptions", |
| 59 | + "-Xmx100M", |
| 60 | + "-XX:+ReplayCompiles", "-XX:ReplayDataFile=./bogus-replay-file.txt"); |
| 61 | + |
| 62 | + OutputAnalyzer output_detail = new OutputAnalyzer(pb.start()); |
| 63 | + output_detail.shouldNotHaveExitValue(0); |
| 64 | + output_detail.shouldContain("Error while parsing"); |
| 65 | + |
| 66 | + } |
| 67 | +} |
| 68 | + |
| 69 | + |
0 commit comments