jdk/test/java/lang/ProcessBuilder/InheritIO/InheritIO.sh
changeset 20191 f0e23e7272d6
child 26194 1570007fff27
equal deleted inserted replaced
20190:15c72885e3fd 20191:f0e23e7272d6
       
     1 #
       
     2 # Copyright (c) 2013, 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 # @test
       
    25 # @bug 8023130
       
    26 # @summary (process) ProcessBuilder#inheritIO does not work on Windows
       
    27 # @run shell InheritIO.sh
       
    28 
       
    29 if [ "x${TESTSRC}" = "x" ]; then
       
    30   echo "TESTSRC not set.  Test cannot execute.  Failed."
       
    31   exit 1
       
    32 fi
       
    33 
       
    34 if [ "x${TESTJAVA}" = "x" ]; then
       
    35   echo "TESTJAVA not set.  Test cannot execute.  Failed."
       
    36   exit 1
       
    37 fi
       
    38 
       
    39 
       
    40 JAVA="${TESTJAVA}/bin/java"
       
    41 JAVAC="${TESTJAVA}/bin/javac"
       
    42 
       
    43 cp -f ${TESTSRC}/InheritIO.java .
       
    44 
       
    45 # compile the class ourselves, so this can run as a standalone test
       
    46 
       
    47 ${JAVAC} InheritIO.java
       
    48 RES="$?"
       
    49 if [ ${RES} != 0 ]; then
       
    50     echo 'FAIL: Cannot compile InheritIO.java'
       
    51     exit ${RES}
       
    52 fi
       
    53 
       
    54 
       
    55 for TEST_NAME in TestInheritIO TestRedirectInherit
       
    56 do
       
    57     ${JAVA} ${TESTVMOPTS} -classpath . \
       
    58         'InheritIO$'${TEST_NAME} printf message > stdout.txt 2> stderr.txt
       
    59 
       
    60     RES="$?"
       
    61     if [ ${RES} != 0 ]; then
       
    62         echo 'FAIL: InheritIO$'${TEST_NAME}' failed with '${RES}
       
    63         exit ${RES}
       
    64     fi
       
    65 
       
    66     OUT_EXPECTED='message'
       
    67     OUT_RECEIVED=`cat stdout.txt`
       
    68     if [ "x${OUT_RECEIVED}" != "x${OUT_EXPECTED}" ]; then
       
    69         echo "FAIL: unexpected '${OUT_RECEIVED}' in stdout"
       
    70         exit 1
       
    71     fi
       
    72 
       
    73     ERR_EXPECTED='exit value: 0'
       
    74     ERR_RECEIVED=`cat stderr.txt`
       
    75     if [ "x${ERR_RECEIVED}" != "x${ERR_EXPECTED}" ]; then
       
    76         echo "FAIL: unexpected '${ERR_RECEIVED}' in stderr"
       
    77         exit 1
       
    78     fi
       
    79 done
       
    80 
       
    81 echo 'PASS: InheritIO works as expected'