Skip to content

Commit

Permalink
Disable directoryfd test on systems without /proc
Browse files Browse the repository at this point in the history
Partial fix for #483
  • Loading branch information
krader1961 committed Apr 25, 2018
1 parent eb97b0e commit 3d29268
Showing 1 changed file with 21 additions and 16 deletions.
37 changes: 21 additions & 16 deletions src/cmd/ksh93/tests/directoryfd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,20 @@
# Roland Mainz <roland.mainz@nrubsig.org> #
# #
########################################################################

#
# Copyright (c) 2013, Roland Mainz. All rights reserved.
#
log_info 'TODO: Reenable the commented out tests below if and when mkdir/rmdir/cat builtins are enabled.'

#
# Tests for directory file descriptors
#
if [[ ! -d /proc ]]
then
log_warning "Skipping this test since the system does not have a /proc directory"
exit 0
fi

#
# The test module checks whether directory file descritors
# work
# The test module checks whether directory file descrpitors work.
#

function test_dirfd_basics1
{
mkdir 'test_dirfd_basics1'
Expand Down Expand Up @@ -79,7 +79,6 @@ function test_dirfd_basics1
cmd='{ print -n "foo2_" >[dirfd]/test1 ; dfd=$dirfd $SHELL -c "print appendix2 >>/dev/fd/\$dfd/test1" ; } {dirfd}<"./tmp"; cat tmp/test1'
stdoutpattern='foo2_appendix2'
)
log_info 'TODO: This is a test for mkdir/cat/rmdir builtins. We should reenable it if we choose to make these commands builtin.'
# (
# testname='createdir1_redirect'
# cmd='redirect {dirfd}<"./tmp" ; mkdir [dirfd]/test1 ; print "foo2" >tmp/test1/a ; cat [dirfd]/test1/a ; rm tmp/test1/a ; rmdir [dirfd]/test1'
Expand Down Expand Up @@ -114,17 +113,23 @@ log_info 'TODO: This is a test for mkdir/cat/rmdir builtins. We should reenable

rm -Rf 'tmp'

[[ "${out.stdout}" == ${tst.stdoutpattern} ]] || log_error "${testname}: Expected stdout to match $(printf '%q\n' "${tst.stdoutpattern}"), got $(printf '%q\n' "${out.stdout}")"
[[ "${out.stderr}" == '' ]] || log_error "${testname}: Expected empty stderr, got $(printf '%q\n' "${out.stderr}")"
(( out.res == 0 )) || log_error "${testname}: Unexpected exit code ${out.res}"
expect="${tst.stdoutpattern}"
actual="${out.stdout}"
[[ $actual == $expect ]] ||
log_error "${testname}: Expected stdout to match" "$expect" "$actual"
expect=''
actual="${out.stderr}"
[[ $actual == $expect ]] ||
log_error "${testname}: Expected empty stderr" "$expect" "$actual"
expect=0
actual=$out.res
(( actual == expect )) ||
log_error "${testname}: Unexpected exit code" "$expect" "$actual"
done
done

cd '..'
rmdir 'test_dirfd_basics1' || log_error "${0}: Cannot remove directory."

return 0
cd $TEST_DIR
}

# run tests
# Run tests.
test_dirfd_basics1

0 comments on commit 3d29268

Please sign in to comment.