Skip to content

Commit 6502024

Browse files
author
Damien Nadé
committed
Condition fifo type test. Not testing 1 & 2 for terminals, since they are /dev/null. Counting and printing disabled tests
1 parent cbf6373 commit 6502024

1 file changed

Lines changed: 25 additions & 12 deletions

File tree

unittest

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ PATH="$PATH:."
99

1010
shopt -s extdebug
1111
errors=0
12+
disabled=0
1213

1314
err_trap() {
1415
: $((errors+=1))
@@ -257,14 +258,11 @@ cumul_test() {
257258
)
258259

259260
dir=$(mktemp -d)
260-
fifo="$dir/fifo"
261261
file=$(mktemp --tmpdir="$dir")
262-
mkfifo "$fifo"
263262
declare -A types=(
264263
[link]="$dir/link1 $dir/link2"
265264
[file]="$file ${types[link]}"
266265
[directory]=". .. $dir $dir/linkdir"
267-
[pipe]="$fifo"
268266
[char]="c . 0 @"
269267
[unsignedint]=123
270268
[int]="1 123 0 -1 -938945349"
@@ -278,14 +276,23 @@ declare -A types=(
278276
[portnumber]=1234
279277
)
280278

279+
fifo="$dir/fifo"
280+
if mkfifo "$fifo"
281+
then
282+
types[pipe]=$fifo
283+
else
284+
printf "Could not create persistent fifo. Disabling pipe type test.\n"
285+
: $((disabled++))
286+
fi
287+
281288
for socket in /dev/log
282289
do
283290
[[ -S $socket ]] || continue
284291
types[socket]=$socket
285292
done
286293

287294
# Look for a terminal
288-
for stdfd in 0 1 2
295+
for stdfd in 0
289296
do
290297
[[ -t $stdfd ]] || continue
291298
types[terminal]=$stdfd
@@ -295,6 +302,7 @@ for t in terminal socket
295302
do
296303
if [[ ${types[$t]-unset} = unset ]]
297304
then
305+
: $((disabled++))
298306
printf "No %s found: won't test.\n" "$t"
299307
fi
300308
done
@@ -306,6 +314,7 @@ then
306314
types[host]+=" ${types[hostname]}"
307315
else
308316
printf "Cannot resolv localhost. Not testing hostname type.\n"
317+
: $((disabled++))
309318
fi
310319

311320
(cd "$dir" && ln -s "$file" link1 && ln -s asdf link2 && ln -s . linkdir)
@@ -372,18 +381,22 @@ rm -Rf "$dir"
372381
TEST=failure parse_option_wrapper "custom type (2)" --option asdf
373382
)
374383

384+
if [[ $disabled -ne 0 ]]
385+
then
386+
printf "%d disabled\n" "$disabled"
387+
fi
388+
375389
if [[ $errors -ne 0 ]]
376390
then
377391
printf "%d error(s) encountered. (See above)\n" "$errors"
378392
printf "Environment was:\n"
379-
printf "bash is "
380-
command -v bash
381-
bash --version
382-
printf "Bash settings were:\n"
383-
printf shopt\\n
384-
shopt
385-
printf 'set -o\n'
386-
set -o
393+
set -x
394+
{
395+
command -v bash
396+
bash --version
397+
shopt
398+
set -o
399+
} 2>&1
387400
exit 1
388401
else
389402
exit 0

0 commit comments

Comments
 (0)