diff options
author | Bryan Drewery <bryan@shatow.net> | 2018-11-17 03:46:21 +0300 |
---|---|---|
committer | Bryan Drewery <bryan@shatow.net> | 2018-11-19 22:13:07 +0300 |
commit | 37feff37e66d8b615e78afac1a3c8cec00a5a859 (patch) | |
tree | 1e05ac69afa086eac4f5f874c8e0151258f3920e /test | |
parent | beba8957a906b3d11da8953a6c0a0596ab196662 (diff) |
mapfile: Add test to ensure inner loop works properly
Diffstat (limited to 'test')
-rw-r--r-- | test/mapfile.sh | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/test/mapfile.sh b/test/mapfile.sh index ef4964fd..2ce34781 100644 --- a/test/mapfile.sh +++ b/test/mapfile.sh @@ -345,6 +345,7 @@ fi # It's possible that a nested one will try to read from a parent's handle. { rm -f "${TMP}" + TDIR=$(mktemp -dt mapfile) TMP=$(mktemp -t mapfile) i=0 @@ -356,15 +357,26 @@ fi expectedfds=$(procstat -f $$|wc -l) i=0 while mapfile_read_loop_redir n y; do + echo "OUTER 1: n=$n y=$y" >&2 echo "'${n}' '${y}'" | while mapfile_read_loop_redir m z; do + echo "INNER 1: m=$m z=$z" >&2 echo "'${m}' '${z}'" done done < "${TMP}" | while mapfile_read_loop_redir n y; do + echo "INNER 2: n=$n y=$y" >&2 assert "''$i''" "$n" "value should match double quoted 6 $i" assert "''$((i + 5))''" "$y" "value should match double quoted 6 $((i + 5))" + touch "${TDIR}/${i}" + i=$((i + 1)) + done + i=0 + until [ ${i} -eq 10 ]; do + [ -e "${TDIR}/${i}" ] + assert 0 $? "inner loop did not run i=$i; found: $(/bin/ls ${TDIR}):" i=$((i + 1)) done fds=$(procstat -f $$|wc -l) [ ${JAILED} -eq 0 ] && assert "${expectedfds}" "${fds}" "fd leak 7" + rm -rf "${TDIR}" } exit 0 |