1 /* 2 * Copyright (c) 2016, 2018, 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 8066652 27 * @requires os.family == "mac" 28 * @summary tests thread safe native function localtime_r is accessed by multiple 29 * threads at same time and zone id should not be "GMT+00:00" 30 * if default timezone is "GMT" and user specifies a fake timezone. 31 * @library /test/lib 32 * @build Bug8066652 33 * @run main Bug8066652Run 34 */ 35 36 import java.util.Map; 37 38 import jdk.test.lib.JDKToolLauncher; 39 import jdk.test.lib.Utils; 40 import jdk.test.lib.process.ProcessTools; 41 42 public class Bug8066652Run { 43 private static String cp = Utils.TEST_CLASSES; 44 private static ProcessBuilder pb = new ProcessBuilder(); 45 46 public static void main(String[] args) throws Throwable { 47 //set system TimeZone to GMT using environment variable TZ 48 Map<String, String> env = pb.environment(); 49 env.put("TZ", "GMT"); 50 System.out.println("Current TimeZone:" + pb.environment().get("TZ")); 51 JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("java"); 52 //Setting invalid TimeZone using VM option 53 launcher.addToolArg("-Duser.timezone=Foo/Bar") 54 .addToolArg("-cp") 55 .addToolArg(cp) 56 .addToolArg("Bug8066652"); 57 58 pb.command(launcher.getCommand()); 59 int exitCode = ProcessTools.executeCommand(pb) 60 .getExitValue(); 61 if (exitCode != 0) { 62 throw new RuntimeException("Unexpected exit code: " + exitCode); 63 } 64 } 65 } 66