1
0
Fork 0
mirror of https://repo.or.cz/socat.git synced 2025-07-11 22:23:24 +00:00

Fixed o-creat, o-excl, and o-cloexec with POSIXMQ-*

This commit is contained in:
Gerhard Rieger 2024-11-12 22:28:02 +01:00
parent 25d2f746d9
commit 1ea37d48c2
12 changed files with 83 additions and 68 deletions

62
test.sh
View file

@ -1038,7 +1038,7 @@ childprocess () {
local l
case "$1" in
[1-9]*) ;;
*) echo "childprocess \"$1\": not a number" >&2; exit 1 ;;
*) echo "childprocess \"$1\": not a number" >&2; exit -1 ;;
esac
case "$UNAME" in
AIX) l="$(ps -fade |grep "^........ ...... $(printf %6u $1)")" ;;
@ -1065,7 +1065,7 @@ childpids () {
if [ "X$1" = "X-r" ]; then recursive=1; shift; fi
case "$1" in
[1-9]*) ;;
*) echo "childpids \"$1\": not a number" >&2; exit 1 ;;
*) echo "childpids \"$1\": not a number" >&2; exit -1 ;;
esac
case "$UNAME" in
AIX) l="$(ps -fade |grep "^........ ...... $(printf %6u $1)" |awk '{print($2);}')" ;;
@ -16702,9 +16702,9 @@ te="$td/test$N.stderr"
tdiff="$td/test$N.diff"
da="test$N $(date) $RANDOM"
tq=/test$N
CMD0a="$TRACE $SOCAT --experimental $opts -u STDIO POSIXMQ-SEND:$tq,mq-prio=0,unlink-early"
CMD0b="$TRACE $SOCAT --experimental $opts -u STDIO POSIXMQ-SEND:$tq,mq-prio=1"
CMD1="$TRACE $SOCAT --experimental $opts -u POSIXMQ-READ:$tq,unlink-close STDIO"
CMD0a="$TRACE $SOCAT $opts -u STDIO POSIXMQ-SEND:$tq,mq-prio=0,unlink-early"
CMD0b="$TRACE $SOCAT $opts -u STDIO POSIXMQ-SEND:$tq,mq-prio=1"
CMD1="$TRACE $SOCAT $opts -u POSIXMQ-READ:$tq,unlink-close STDIO"
printf "test $F_n $TEST... " $N
echo "$da 0" |$CMD0a 2>"${te}0a"
rc0a=$?
@ -16768,9 +16768,9 @@ te="$td/test$N.stderr"
tdiff="$td/test$N.diff"
da="test$N $(date) $RANDOM"
tq=/test$N
CMD0="$TRACE $SOCAT --experimental $opts -u POSIXMQ-RECV:$tq,unlink-early,fork STDIO"
CMD1a="$TRACE $SOCAT --experimental $opts -u STDIO POSIXMQ-SEND:$tq"
CMD1b="$TRACE $SOCAT --experimental $opts -u STDIO POSIXMQ-SEND:$tq,unlink-close"
CMD0="$TRACE $SOCAT $opts -u POSIXMQ-RECV:$tq,unlink-early,fork STDIO"
CMD1a="$TRACE $SOCAT $opts -u STDIO POSIXMQ-SEND:$tq"
CMD1b="$TRACE $SOCAT $opts -u STDIO POSIXMQ-SEND:$tq,unlink-close"
printf "test $F_n $TEST... " $N
$CMD0 2>"${te}0" >"${tf}0" &
pid0=$!
@ -16837,9 +16837,9 @@ te="$td/test$N.stderr"
tdiff="$td/test$N.diff"
da="test$N $(date) $RANDOM"
tq=/test$N
CMD0="$TRACE $SOCAT --experimental $opts -u POSIXMQ-RECV:$tq,unlink-early,fork,max-children=1 SYSTEM:\"cat\ >>${tf}0;\ sleep\ 1\""
CMD1a="$TRACE $SOCAT --experimental $opts -u STDIO POSIXMQ-SEND:$tq"
CMD1b="$TRACE $SOCAT --experimental $opts -u STDIO POSIXMQ-SEND:$tq,unlink-close"
CMD0="$TRACE $SOCAT $opts -u POSIXMQ-RECV:$tq,unlink-early,fork,max-children=1 SYSTEM:\"cat\ >>${tf}0;\ sleep\ 1\""
CMD1a="$TRACE $SOCAT $opts -u STDIO POSIXMQ-SEND:$tq"
CMD1b="$TRACE $SOCAT $opts -u STDIO POSIXMQ-SEND:$tq,unlink-close"
printf "test $F_n $TEST... " $N
eval $CMD0 2>"${te}0" >"${tf}0" &
pid0=$!
@ -16893,8 +16893,8 @@ NAME=POSIXMQ_SEND_MAXCHILDREN
case "$TESTS" in
*%$N%*|*%functions%*|*%fork%*|*%maxchildren%*|*%socket%*|*%posixmq%*|*%$NAME%*)
TEST="$NAME: POSIX-MQ SEND with fork,max-children"
# Start a POSIX-MQ receiver that creates a POSIX-MQ and transfers data from
# there to an output file
# Start a POSIX-MQ receiver that creates a POSIX-MQ and transfers data from it
# to an output file
# Run a POSIX-MQ sender that two times forks and invokes a data generator
# for messages 1 and 3 in a shell process with some trailing sleep.
# Afterwards write message 2 directly into output file; message 3 should be
@ -16911,38 +16911,40 @@ te="$td/test$N.stderr"
tdiff="$td/test$N.diff"
da="test$N $(date) $RANDOM"
tq=/test$N
CMD0="$TRACE $SOCAT --experimental $opts -u POSIXMQ-READ:$tq,unlink-early STDIO"
CMD1="$TRACE $SOCAT --experimental $opts -U POSIXMQ-SEND:$tq,fork,max-children=1,interval=0.1 SYSTEM:\"./socat\ --experimental\ -u\ POSIXMQ-RECV\:$tq-data\ -;\ sleep\ 1\""
CMD1="$TRACE $SOCAT $opts -u POSIXMQ-READ:$tq,unlink-early STDIO"
CMD2="$TRACE $SOCAT $opts -U POSIXMQ-SEND:$tq,fork,max-children=1,interval=0.1 SYSTEM:\"./socat\ -u\ POSIXMQ-RECV\:$tq-data\ -;\ sleep\ 1\""
printf "test $F_n $TEST... " $N
# create data for the generator
echo "$da 1" |$SOCAT -u --experimental - POSIXMQ-SEND:$tq-data,unlink-early
echo "$da 3" |$SOCAT -u --experimental - POSIXMQ-SEND:$tq-data
eval $CMD0 2>"${te}0" >>"${tf}0" &
pid0=$!
relsleep 1
eval $CMD1 2>"${te}1" &
echo "$da 1" |$SOCAT -u - POSIXMQ-SEND:$tq-data,unlink-early 2>"${te}0a"
echo "$da 3" |$SOCAT -u - POSIXMQ-SEND:$tq-data 2>"${te}0b"
eval $CMD1 2>"${te}1" >>"${tf}1" &
pid1=$!
relsleep 1
eval $CMD2 2>"${te}2" &
pid2=$!
sleep 0.5
echo "$da 2" >>"${tf}0"
echo "$da 2" >>"${tf}1"
sleep 1 # as in SYSTEM
kill $pid0 $(childpids $pid0) $pid1 $(childpids $pid1) 2>/dev/null
kill $pid1 $(childpids $pid1) $pid2 $(childpids $pid2) 2>/dev/null
wait 2>/dev/null
$SOCAT -u --experimental /dev/null POSIXMQ-SEND:$tq-data,unlink-close
if $ECHO "$da 1\n$da 2\n$da 3" |diff - ${tf}0 >${tdiff}0; then
# remove the queues
$SOCAT -u /dev/null POSIXMQ-SEND:$tq-data,unlink-close 2>"${te}3a"
$SOCAT -u /dev/null POSIXMQ-SEND:$tq,unlink-close 2>"${te}3b"
if $ECHO "$da 1\n$da 2\n$da 3" |diff - ${tf}1 >${tdiff}1; then
$PRINTF "$OK\n"
if [ "$VERBOSE" ]; then echo "$CMD0"; fi
if [ "$DEBUG" ]; then cat "${te}0" >&2; fi
if [ "$VERBOSE" ]; then echo "$CMD1"; fi
if [ "$DEBUG" ]; then cat "${te}1" >&2; fi
if [ "$VERBOSE" ]; then echo "$CMD2"; fi
if [ "$DEBUG" ]; then cat "${te}2" >&2; fi
ok
else
$PRINTF "$FAILED\n"
echo "$CMD0"
cat "${te}0" >&2
echo "$CMD1"
cat "${te}1" >&2
echo "$CMD2"
cat "${te}2" >&2
echo "difference:" >&2
cat ${tdiff}0 >&2
cat ${tdiff}1 >&2
failed
fi
fi # NUMCOND