mirror of
https://repo.or.cz/socat.git
synced 2025-01-09 14:32:33 +00:00
test.sh: prepared process checks
This commit is contained in:
parent
8fbff188e1
commit
c44985fb8d
1 changed files with 42 additions and 0 deletions
42
test.sh
42
test.sh
|
@ -1525,6 +1525,47 @@ testoptions () {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# check if a process with given pid exists; print its ps line
|
||||||
|
# if yes: prints line to stdout, returns 0
|
||||||
|
# if not: prints ev.message to stderr, returns 1
|
||||||
|
ifprocess () {
|
||||||
|
local l
|
||||||
|
case "$UNAME" in
|
||||||
|
Linux) l="$(ps -fade |grep "^.........$(printf %5u $1)")" ;;
|
||||||
|
esac
|
||||||
|
if [ -z "$l" ]; then
|
||||||
|
return 1;
|
||||||
|
fi
|
||||||
|
echo "$l"
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
# check if the given pid exists and has child processes
|
||||||
|
# if yes: prints child process lines to stdout, returns 0
|
||||||
|
# if not: prints ev.message to stderr, returns 1
|
||||||
|
childprocess () {
|
||||||
|
local l
|
||||||
|
case "$UNAME" in
|
||||||
|
Linux) l="$(ps -fade |grep "^...............$(printf %5u $1)")" ;;
|
||||||
|
esac
|
||||||
|
if [ -z "$l" ]; then
|
||||||
|
return 1;
|
||||||
|
fi
|
||||||
|
echo "$l"
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
# check if the given process line refers to a defunct (zombie) process
|
||||||
|
# yes: returns 0
|
||||||
|
# no: returns 1
|
||||||
|
isdefunct () {
|
||||||
|
local l
|
||||||
|
case "$UNAME" in
|
||||||
|
Linux) l="$(echo "$1" |grep ' <defunct>$')" ;;
|
||||||
|
esac
|
||||||
|
[ -n "$l" ];
|
||||||
|
}
|
||||||
|
|
||||||
unset HAVENOT_IP4
|
unset HAVENOT_IP4
|
||||||
# check if an IP4 loopback interface exists
|
# check if an IP4 loopback interface exists
|
||||||
runsip4 () {
|
runsip4 () {
|
||||||
|
@ -7739,6 +7780,7 @@ $CMD1 2>"${te}1" >"$tf" &
|
||||||
pid=$! # background process id
|
pid=$! # background process id
|
||||||
waittcp4port $PORT
|
waittcp4port $PORT
|
||||||
(echo "$da"; sleep 2) |$CMD2 2>"${te}2"
|
(echo "$da"; sleep 2) |$CMD2 2>"${te}2"
|
||||||
|
kill "$pid" 2>/dev/null; wait
|
||||||
if ! echo "$da" |diff - "$tf" >"$tdiff"; then
|
if ! echo "$da" |diff - "$tf" >"$tdiff"; then
|
||||||
$PRINTF "$FAILED: $SOCAT:\n"
|
$PRINTF "$FAILED: $SOCAT:\n"
|
||||||
echo "$CMD1"
|
echo "$CMD1"
|
||||||
|
|
Loading…
Reference in a new issue