1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
|
#!/bin/bash
source tests/common.bash
TARGET=$tcasedir/pipe
if ! [ -x $TARGET ]; then
echo "target executable ( $TARGET ) is not found" >> $report
exit 1
fi
{ $TARGET & } | {
read parent child fdr fdw;
if [ -z "$parent" ] || [ -z "$child" ] || [ -z "$fdr" ] || [ -z "$fdw" ]; then
echo "unexpected output form target ( $TARGET )" >> $report
exit 1
fi
echo parent: $parent >> $report
echo child: $child >> $report
echo fdr: $fdr >> $report
echo fdw: $fdw >> $report
echo cmdline: "$lsof +E -p "$parent"" >> $report
$lsof +E -p "$parent" >> $report
{
{
echo expected pattern: ".* $parent .* ${fdr}r *FIFO .* pipe ${child},p[-a-z]*,${fdw}w"
$lsof +E -p "$parent" |
grep -q ".* $parent .* ${fdr}r *FIFO .* pipe ${child},p[-a-z]*,${fdw}w"
} && {
echo expected parent: ".* $child .* ${fdw}w *FIFO .* pipe ${parent},p[-a-z]*,${fdr}r"
$lsof +E -p "$parent" |
grep -q ".* $child .* ${fdw}w *FIFO .* pipe ${parent},p[-a-z]*,${fdr}r"
} && {
kill "$child"
exit 0
}
} >> $report
kill "$child"
exit 1
}
|