001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017:
018: /**
019: * @author Serguei S.Zapreyev
020: * @version $Revision$
021: */package java.lang;
022:
023: import java.io.File;
024:
025: import junit.framework.TestCase;
026:
027: /*
028: * Created on March 29, 2006
029: *
030: * This RuntimeAdditionalTest class is used to test the Core API Runtime class
031: *
032: */
033:
034: /**
035: * ###############################################################################
036: * ###############################################################################
037: * TODO: 1.
038: * ###############################################################################
039: * ###############################################################################
040: */
041:
042: public class RuntimeAdditionalTest36 extends TestCase {
043: /**
044: * check the process exit code has a waited value
045: */
046: public void test_35() { // it can hang the test set run
047: System.out.println("==test_35===");
048: String cmnd = null;
049: if (RuntimeAdditionalTest0.os.equals("Win")) {
050: cmnd = RuntimeAdditionalTest0.cm + " /C ";
051: try {
052: //for (int i = 0; i < Short.MAX_VALUE / 30; i++) {
053: //for (int i = 0; i < Short.MAX_VALUE / 100; i++) {
054: for (int i = 0; i < Short.MAX_VALUE / 150; i++) {
055: Process pi3 = Runtime.getRuntime().exec(
056: cmnd + "\"exit "
057: + Integer.toString(i - 500) + "\"");
058: int j = pi3.waitFor();
059: /*System.out.println("sent " + Integer.toString(i - 500)
060: + " | received " + pi3.waitFor());*/
061: if (j != (i - 500)) {
062: fail("ERROR(test_35): exiValue "
063: + pi3.exitValue() + " should be "
064: + (i - 500));
065: }
066: }
067: } catch (Exception eeee) {
068: eeee.printStackTrace();
069: fail("ERROR (test_35): unexpected exception.");
070: }
071: } else if (RuntimeAdditionalTest0.os.equals("Lin")) {
072: try {
073: for (int i = 500; i < Short.MAX_VALUE / 100/*30*/; i++) {
074: //Process pi3 = Runtime.getRuntime().exec("java RuntimeAdditionalSupport1 " +
075: // Integer.toString(i-500));
076: //\\//\\Process pi3 = Runtime.getRuntime().exec("java -cp
077: // \""+System.getProperty("java.class.path")+"\" RuntimeAdditionalSupport1 " +
078: // Integer.toString(i-500));
079: // Process pi3 = Runtime
080: // .getRuntime()
081: // .exec(
082: // "java "
083: // + (System.getProperty(
084: // "java.class.path").length() > 0 ? "-cp "
085: // + System
086: // .getProperty("java.class.path")
087: // : "") + " RuntimeAdditionalSupport1 "
088: // + Integer.toString(i - 500));
089: String ttt = System
090: .getProperty("vm.boot.class.path")
091: + (System.getProperty("java.class.path")
092: .length() > 0 ? File.pathSeparator
093: + System
094: .getProperty("java.class.path")
095: : "");
096: Process pi3 = Runtime
097: .getRuntime()
098: .exec(
099: "java -Xbootclasspath/a:"
100: + ttt
101: + " -cp "
102: + ttt
103: + " java.lang.RuntimeAdditionalSupport1 "
104: + Integer.toString(i - 500));
105: int j = pi3.waitFor();
106: /*System.out.println("sent " + Integer.toString(i - 500)
107: + " | received " + pi3.waitFor() + " (" + j + ")"
108: + ((i - 500) & 0xFF));*/
109: if (j != ((i - 500) & 0xFF)) {
110: fail("ERROR(test_35): exiValue "
111: + pi3.exitValue() + " should be "
112: + ((i - 500) & 0xFF));
113: }
114: }
115: } catch (Exception eeee) {
116: eeee.printStackTrace();
117: fail("ERROR (test_35): unexpected exception.");
118: }
119: } else {
120: fail("WARNING (test_1): unknown operating system.");
121: }
122: }
123:
124: }
|