Index: vm/tests/kernel/java/lang/RuntimeAdditionalTest46.java =================================================================== --- vm/tests/kernel/java/lang/RuntimeAdditionalTest46.java (revision 0) +++ vm/tests/kernel/java/lang/RuntimeAdditionalTest46.java (revision 0) @@ -0,0 +1,111 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @author Serguei S.Zapreyev + * @version $Revision$ + */ +package java.lang; +import junit.framework.TestCase; +import java.io.IOException; +import java.io.InputStream; + +/** + * if total length of environment block exceeds 32K + */ +public class RuntimeAdditionalTest46 extends TestCase { + public static int nmbEnv = 90; + public final static String ENV_S = "env"; + public final static String ENV_S1 = "0123456789"; + + public void test_46() { + for (int k = 75; k < nmbEnv; k++) { + System.out.println("########################################################################## "+k); + int len = 0; + String [] envs = new String [k]; + for (int i = 0; i < k; i++) { + envs[i] = ENV_S+Integer.toString(i)+"="; + String s = ""; + for (int j = 0; j < i; j++) { + s = s + ENV_S1; + } + s = s+"a"; + envs[i] = envs[i] + s; + len+=envs[i].length(); + } + System.out.println("PUT LEN= "+len); + + try { + String r = ""; + //Process p = Runtime.getRuntime().exec("C:\\CygWin\\bin\\env", envs); + Process p = Runtime.getRuntime().exec("env", envs); + InputStream is = p.getInputStream(); + while (is.available()==0) {Thread.sleep(10);} + int ll = 0; + while ((ll=is.available())!=0) { + byte b[]= new byte[ll]; + is.read(b); + String ttt=new String(b); + r += ttt; + //System.out.print(ttt); + } + while(true){ + try{ + p.exitValue(); + }catch(Exception _){ + while ((ll=is.available())!=0) { + byte b[]= new byte[ll]; + is.read(b); + String ttt=new String(b); + r += ttt; + //System.out.print(ttt); + } + continue; + } + break; + } + int ans = p.exitValue(); + for (int j = 0; j < 10; j++) { + Thread.sleep(100); + while ((ll=is.available())!=0) { + byte b[]= new byte[ll]; + is.read(b); + String ttt=new String(b); + r += ttt; + //System.out.print(ttt); + } + } + System.out.println("GET LEN= "+r.length()); + if (ans != 0) { + fail("TEST FAILED: Incorrect exitValue: "+ans); + } + if (r.indexOf(ENV_S+Integer.toString(k-1)) == -1 && r.indexOf(ENV_S.toUpperCase()+Integer.toString(k-1)) == -1) { + fail("TEST FAILED: The last "+ENV_S+Integer.toString(k-1)+" environment variable is absent"); + } + } catch (IOException e) { + System.out.println(e.getMessage()); + System.out.println("TEST PASSED"); + return; + } catch (Exception e) { + e.printStackTrace(); + fail("TEST FAILED: Unexpected error: "+e); + } + } + System.out.println("TEST PASSED"); + } +} + Index: vm/tests/kernel/java/lang/RuntimeAdditionalTest47.java =================================================================== --- vm/tests/kernel/java/lang/RuntimeAdditionalTest47.java (revision 0) +++ vm/tests/kernel/java/lang/RuntimeAdditionalTest47.java (revision 0) @@ -0,0 +1,136 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @author Serguei S.Zapreyev + * @version $Revision$ + */ +package java.lang; +import junit.framework.TestCase; +import java.io.*; + +/** + * if length of command string exceeds 32K + */ + +public class RuntimeAdditionalTest47 extends TestCase { + public static int nmbARG = 50; + public final static String ARG_S = "arg"; + public final static String ARG_S1 = "0123456789"; + + public void test_47() { + int len = 0; + String [] ARGs = new String [nmbARG]; + for (int i = 0; i < nmbARG; i++) { + ARGs[i] = ARG_S+Integer.toString(i)+"_"; + String s = ""; + for (int j = 0; j < i; j++) { + s = s + ARG_S1; + } + s = s+"a"; + ARGs[i] = ARGs[i] + s; + len += ARGs[i].length(); + } + System.out.println("ARGS LEN= "+len); + + for (int k = 0; k < 8; k++) { + System.out.println("########################################################################## "+k); + String c=""; + String r=""; + String tttt = System.getProperty("vm.boot.class.path") + (System.getProperty("java.class.path").length() > 0 ? + File.pathSeparator + System.getProperty("java.class.path") : ""); + c += System.getProperty("java.home")+File.separator+"bin"+File.separator+"java" + + " -Xbootclasspath/a:" + tttt + " -classpath ." + File.pathSeparator + tttt + " java.lang.LocalApp "; + int len2 = c.length(); + for (int i = 0; i < nmbARG; i++) { + for (int j = 0; j <= k; j++) { + c += ARGs[i] + " "; + } + } + c += "ZAPREYEV"; + System.out.println("PUT ARGS= "+(/*4*/+(k+1)*nmbARG+1)); + System.out.println("PUT LEN= "+(c.length()-len2)); + try { + Process p = Runtime.getRuntime().exec(c); + InputStream is = p.getInputStream(); + while (is.available()==0) {Thread.sleep(10);} + int ll = 0; + while ((ll=is.available())!=0) { + byte b[]= new byte[ll]; + is.read(b); + String ttt=new String(b); + r += ttt; + //System.out.print(ttt); + } + while(true){ + try{ + p.exitValue(); + }catch(Exception _){ + while ((ll=is.available())!=0) { + byte b[]= new byte[ll]; + is.read(b); + String ttt=new String(b); + r += ttt; + //System.out.print(ttt); + } + continue; + } + break; + } + int ans = p.exitValue(); + for (int j = 0; j < 10; j++) { + Thread.sleep(100); + while ((ll=is.available())!=0) { + byte b[]= new byte[ll]; + is.read(b); + String ttt=new String(b); + r += ttt; + //System.out.print(ttt); + } + } if (ans != 77) { + fail("TEST FAILED: Incorrect exitValue: "+ans); + } + if (r.indexOf("ZAPREYEV") == -1) { + fail("TEST FAILED: Missing last argument"); + } + } catch (IOException e) { + break; + } catch (Exception e) { + e.printStackTrace(); + fail("TEST FAILED: Unexpected error: "+e); + } + } + System.out.println("TEST PASSED"); + } +} + + class LocalApp { + public static void main(String[] args) { + System.err.println("========LocalApp======"); + System.out.println("========LocalApp======"); + System.out.println("GET ARGS= "+args.length); + int length = 0; + for (int i = 0; i < args.length; i++) { + //System.out.println(args[i]); + length+=args[i].length()+1; + } + System.out.println("GET LEN= "+(length-1)); + System.out.println(args[args.length-1]); + System.exit(77); + } + } +