Fri, 24 Apr 2020 03:58:51 +0100
Merge
vromero@1591 | 1 | /* |
vromero@1591 | 2 | * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. |
vromero@1591 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
vromero@1591 | 4 | * |
vromero@1591 | 5 | * This code is free software; you can redistribute it and/or modify it |
vromero@1591 | 6 | * under the terms of the GNU General Public License version 2 only, as |
vromero@1591 | 7 | * published by the Free Software Foundation. |
vromero@1591 | 8 | * |
vromero@1591 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
vromero@1591 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
vromero@1591 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
vromero@1591 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
vromero@1591 | 13 | * accompanied this code). |
vromero@1591 | 14 | * |
vromero@1591 | 15 | * You should have received a copy of the GNU General Public License version |
vromero@1591 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
vromero@1591 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
vromero@1591 | 18 | * |
vromero@1591 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
vromero@1591 | 20 | * or visit www.oracle.com if you need additional information or have any |
vromero@1591 | 21 | * questions. |
vromero@1591 | 22 | */ |
vromero@1591 | 23 | |
vromero@1591 | 24 | /* |
vromero@1591 | 25 | * @test |
vromero@1591 | 26 | * @bug 4846262 |
vromero@1591 | 27 | * @summary check that javac operates correctly in EBCDIC locale |
vromero@1591 | 28 | * @library /tools/javac/lib |
vromero@1591 | 29 | * @build ToolBox |
vromero@1591 | 30 | * @run main CheckEBCDICLocaleTest |
vromero@1591 | 31 | */ |
vromero@1591 | 32 | |
vromero@1591 | 33 | import java.io.File; |
vromero@1591 | 34 | import java.nio.file.Files; |
vromero@1591 | 35 | import java.nio.file.Paths; |
vromero@1591 | 36 | import java.util.Arrays; |
vromero@1591 | 37 | |
vromero@1591 | 38 | public class CheckEBCDICLocaleTest { |
vromero@1591 | 39 | |
vromero@1591 | 40 | private static final String TestSrc = |
vromero@1591 | 41 | "public class Test {\n" + |
vromero@1591 | 42 | " public void test() {\n" + |
vromero@1591 | 43 | " abcdefg\n" + |
vromero@1591 | 44 | " }\n" + |
vromero@1591 | 45 | "}"; |
vromero@1591 | 46 | |
vromero@1637 | 47 | private static final String TestOutTemplate = |
vromero@1637 | 48 | "output%1$sTest.java:3: error: not a statement\n" + |
vromero@1591 | 49 | " abcdefg\n" + |
vromero@1591 | 50 | " ^\n" + |
vromero@1637 | 51 | "output%1$sTest.java:3: error: ';' expected\n" + |
vromero@1591 | 52 | " abcdefg\n" + |
vromero@1591 | 53 | " ^\n" + |
vromero@1591 | 54 | "2 errors\n"; |
vromero@1591 | 55 | |
vromero@1591 | 56 | public static void main(String[] args) throws Exception { |
vromero@1591 | 57 | new CheckEBCDICLocaleTest().test(); |
vromero@1591 | 58 | } |
vromero@1591 | 59 | |
vromero@1591 | 60 | public void test() throws Exception { |
vromero@1591 | 61 | String native2asciiBinary = Paths.get( |
vromero@1591 | 62 | System.getProperty("test.jdk"),"bin", "native2ascii").toString(); |
vromero@1591 | 63 | |
vromero@1591 | 64 | ToolBox.createJavaFileFromSource(TestSrc); |
vromero@1591 | 65 | Files.createDirectory(Paths.get("output")); |
vromero@1591 | 66 | |
vromero@1591 | 67 | ToolBox.AnyToolArgs nativeCmdParams = |
vromero@1591 | 68 | new ToolBox.AnyToolArgs() |
vromero@1637 | 69 | .appendArgs(native2asciiBinary) |
vromero@1637 | 70 | .appendArgs(ToolBox.testToolVMOpts) |
vromero@1637 | 71 | .appendArgs("-reverse", "-encoding", "IBM1047", "Test.java", |
vromero@1637 | 72 | "output/Test.java"); |
vromero@1591 | 73 | ToolBox.executeCommand(nativeCmdParams); |
vromero@1591 | 74 | |
vromero@1591 | 75 | ToolBox.AnyToolArgs javacParams = |
vromero@1591 | 76 | new ToolBox.AnyToolArgs(ToolBox.Expect.FAIL) |
vromero@1637 | 77 | .appendArgs(ToolBox.javacBinary) |
vromero@1637 | 78 | .appendArgs(ToolBox.testToolVMOpts) |
vromero@1637 | 79 | .appendArgs("-J-Duser.language=en", |
vromero@1591 | 80 | "-J-Duser.region=US", "-J-Dfile.encoding=IBM1047", |
vromero@1637 | 81 | "output/Test.java") |
vromero@1591 | 82 | .setErrOutput(new File("Test.tmp")); |
vromero@1591 | 83 | ToolBox.executeCommand(javacParams); |
vromero@1591 | 84 | |
vromero@1637 | 85 | nativeCmdParams = new ToolBox.AnyToolArgs() |
vromero@1637 | 86 | .appendArgs(native2asciiBinary) |
vromero@1637 | 87 | .appendArgs(ToolBox.testToolVMOpts) |
vromero@1637 | 88 | .appendArgs("-encoding", "IBM1047", "Test.tmp", "Test.out"); |
vromero@1591 | 89 | ToolBox.executeCommand(nativeCmdParams); |
vromero@1591 | 90 | |
vromero@1637 | 91 | String goldenFile = String.format(TestOutTemplate, File.separator); |
vromero@1591 | 92 | ToolBox.compareLines(Paths.get("Test.out"), |
vromero@1637 | 93 | Arrays.asList(goldenFile.split("\n")), null, true); |
vromero@1591 | 94 | } |
vromero@1591 | 95 | |
vromero@1591 | 96 | } |