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

Added option posixmq-flush

This commit is contained in:
Gerhard Rieger 2024-09-06 13:09:44 +02:00
parent 9bf5fc625c
commit 663a6bb012
7 changed files with 138 additions and 69 deletions

92
test.sh
View file

@ -16683,28 +16683,18 @@ esac
N=$((N+1))
# Test the POSIX MQ feature with continuous READ and priorization on Linux
NAME=LINUX_POSIXMQ_READ_PRIO
NAME=POSIXMQ_READ_PRIO
case "$TESTS" in
*%$N%*|*%functions%*|*%socket%*|*%posixmq%*|*%$NAME%*)
TEST="$NAME: POSIX-MQ (Linux) with prio"
TEST="$NAME: POSIX-MQ with prio"
# Run a client/sender that creates a POSIX-MQ and sends a normal message and
# then a client/sender with a higher priority message.
# Run a passive/listening/receiving/reading process and check if it receives
# both messages and in the prioritized order
if ! eval $NUMCOND; then :;
elif [ "$UNAME" != Linux ]; then
$PRINTF "test $F_n $TEST... ${YELLOW}Only on Linux${NORMAL}\n" $N
cant
elif ! F=$(testfeats POSIXMQ STDIO); then
$PRINTF "test $F_n $TEST... ${YELLOW}Feature $F not available in $SOCAT${NORMAL}\n" $N
cant
elif ! A=$(testaddrs POSIXMQ-SEND POSIXMQ-READ STDIO); then
$PRINTF "test $F_n $TEST... ${YELLOW}Address $A not available in $SOCAT${NORMAL}\n" $N
cant
elif ! o=$(testoptions mq-prio unlink-early unlink-close) >/dev/null; then
$PRINTF "test $F_n $TEST... ${YELLOW}Option $o not available in $SOCAT${NORMAL}\n" $N
elif ! cond=$(checkconds "" "" "" "POSIXMQ STDIO" "POSIXMQ-SEND POSIXMQ-READ STDIO" "mq-prio unlink-early unlink-close"); then
$PRINTF "test $F_n $TEST... ${YELLOW}$cond${NORMAL}\n" $N
cant
else
tf="$td/test$N.stdout"
@ -16725,7 +16715,7 @@ pid1=$!
relsleep 1
kill $pid1; wait
if [ $rc0a -ne 0 -o $rc0b -ne 0 ]; then
$PRINTF "$FAILED\n"
$PRINTF "$FAILED (rc0a=$rc0a, rc0b=$rc0b)\n"
echo "$CMD0a"
cat "${te}0a" >&2
echo "$CMD0b"
@ -16743,7 +16733,7 @@ elif $ECHO "$da 1\n$da 0" |diff - ${tf}1 >${tdiff}1; then
if [ "$DEBUG" ]; then cat "${te}1" >&2; fi
ok
else
$PRINTF "$FAILED\n"
$PRINTF "$FAILED (diff)\n"
echo "$CMD0a"
cat "${te}0a" >&2
echo "$CMD0b"
@ -16759,27 +16749,18 @@ fi # NUMCOND
esac
N=$((N+1))
# Test the POSIX MQ feature with RECV,fork on Linux
NAME=LINUX_POSIXMQ_RECV_FORK
# Test the POSIX MQ feature with RECV,fork
NAME=POSIXMQ_RECV_FORK
case "$TESTS" in
*%$N%*|*%functions%*|*%fork%*|*%socket%*|*%posixmq%*|*%$NAME%*)
TEST="$NAME: POSIX-MQ (Linux) RECV with fork"
TEST="$NAME: POSIX-MQ RECV with fork"
# Start a POSIX-MQ receiver with fork that creates a POSIX-MQ and stores its
# output.
# Run two clients/senders each with a message.
# Check if both messages are stored.
if ! eval $NUMCOND; then :;
elif [ "$UNAME" != Linux ]; then
$PRINTF "test $F_n $TEST... ${YELLOW}Only on Linux${NORMAL}\n" $N
cant
elif ! F=$(testfeats POSIXMQ STDIO); then
$PRINTF "test $F_n $TEST... ${YELLOW}Feature $F not available in $SOCAT${NORMAL}\n" $N
cant
elif ! A=$(testaddrs POSIXMQ-SEND POSIXMQ-RECEIVE STDIO); then
$PRINTF "test $F_n $TEST... ${YELLOW}Address $A not available in $SOCAT${NORMAL}\n" $N
cant
elif ! o=$(testoptions fork unlink-early unlink-close) >/dev/null; then
$PRINTF "test $F_n $TEST... ${YELLOW}Option $o not available in $SOCAT${NORMAL}\n" $N
elif ! cond=$(checkconds "" "" "" "POSIXMQ STDIO" "POSIXMQ-SEND POSIXMQ-READ STDIO" "fork unlink-early unlink-close"); then
$PRINTF "test $F_n $TEST... ${YELLOW}$cond${NORMAL}\n" $N
cant
else
tf="$td/test$N.stdout"
@ -16801,7 +16782,7 @@ rc1b=$?
relsleep 1
kill $pid0; wait
if [ $rc1a -ne 0 -o $rc1b -ne 0 ]; then
$PRINTF "$FAILED\n"
$PRINTF "$FAILED (rc1a=$rc1a, rc1b=$rc1b)\n"
echo "$CMD0"
cat "${te}0" >&2
echo "$CMD1a"
@ -16819,7 +16800,7 @@ elif $ECHO "$da 0\n$da 1" |diff - ${tf}0 >${tdiff}0; then
if [ "$DEBUG" ]; then cat "${te}1b" >&2; fi
ok
else
$PRINTF "$FAILED\n"
$PRINTF "$FAILED (diff)\n"
echo "$CMD0"
cat "${te}0" >&2
echo "$CMD1a"
@ -16835,11 +16816,11 @@ fi # NUMCOND
esac
N=$((N+1))
# Test the POSIX MQ feature with RECV,fork,max-children on Linux
NAME=LINUX_POSIXMQ_RECV_MAXCHILDREN
# Test the POSIX MQ feature with RECV,fork,max-children
NAME=POSIXMQ_RECV_MAXCHILDREN
case "$TESTS" in
*%$N%*|*%functions%*|*%fork%*|*%maxchildren%*|*%socket%*|*%posixmq%*|*%$NAME%*)
TEST="$NAME: POSIX-MQ (Linux) RECV with fork,max-children"
TEST="$NAME: POSIX-MQ RECV with fork,max-children"
# Start a POSIX-MQ receiver with fork that creates a POSIX-MQ and stores its
# output via sub processes that sleeps after writing.
# Run a client/sender that sends message 1;
@ -16847,17 +16828,8 @@ TEST="$NAME: POSIX-MQ (Linux) RECV with fork,max-children"
# write message 2 directly into output file;
# Check if the messages are stored in order of their numbers
if ! eval $NUMCOND; then :;
elif [ "$UNAME" != Linux ]; then
$PRINTF "test $F_n $TEST... ${YELLOW}Only on Linux${NORMAL}\n" $N
cant
elif ! F=$(testfeats POSIXMQ STDIO SYSTEM); then
$PRINTF "test $F_n $TEST... ${YELLOW}Feature $F not available in $SOCAT${NORMAL}\n" $N
cant
elif ! A=$(testaddrs POSIXMQ-SEND POSIXMQ-RECEIVE STDIO SYSTEM); then
$PRINTF "test $F_n $TEST... ${YELLOW}Address $A not available in $SOCAT${NORMAL}\n" $N
cant
elif ! o=$(testoptions fork max-children unlink-early unlink-close) >/dev/null; then
$PRINTF "test $F_n $TEST... ${YELLOW}Option $o not available in $SOCAT${NORMAL}\n" $N
elif ! cond=$(checkconds "" "" "" "POSIXMQ STDIO SYSTEM" "POSIXMQ-SEND POSIXMQ-RECEIVE STDIO SYSTEM" "fork max-children unlink-early unlink-close"); then
$PRINTF "test $F_n $TEST... ${YELLOW}$cond${NORMAL}\n" $N
cant
else
tf="$td/test$N.stdout"
@ -16882,7 +16854,7 @@ sleep 1 # as in SYSTEM
kill $(childpids $pid0) $pid0 2>/dev/null
wait 2>/dev/null
if [ $rc1a -ne 0 -o $rc1b -ne 0 ]; then
$PRINTF "$FAILED\n"
$PRINTF "$FAILED (rc1a=$rc1a, rc1b=$rc1b)\n"
echo "$CMD0"
cat "${te}0" >&2
echo "$CMD1a"
@ -16900,7 +16872,7 @@ elif $ECHO "$da 1\n$da 2\n$da 3" |diff - ${tf}0 >${tdiff}0; then
if [ "$DEBUG" ]; then cat "${te}1b" >&2; fi
ok
else
$PRINTF "$FAILED\n"
$PRINTF "$FAILED (diff)\n"
echo "$CMD0"
cat "${te}0" >&2
echo "$CMD1a"
@ -16916,11 +16888,11 @@ fi # NUMCOND
esac
N=$((N+1))
# Test the POSIX MQ feature with SEND,fork,max-children on Linux
NAME=LINUX_POSIXMQ_SEND_MAXCHILDREN
# Test the POSIX MQ feature with SEND,fork,max-children
NAME=POSIXMQ_SEND_MAXCHILDREN
case "$TESTS" in
*%$N%*|*%functions%*|*%fork%*|*%maxchildren%*|*%socket%*|*%posixmq%*|*%$NAME%*)
TEST="$NAME: POSIX-MQ (Linux) SEND with fork,max-children"
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
# Run a POSIX-MQ sender that two times forks and invokes a data generator
@ -16930,21 +16902,9 @@ TEST="$NAME: POSIX-MQ (Linux) SEND with fork,max-children"
# Check if the messages are stored in order of their numbers.
# The data generator is implemented as a receiver from an MQ with "1", "3"
if ! eval $NUMCOND; then :;
elif [ "$UNAME" != Linux ]; then
$PRINTF "test $F_n $TEST... ${YELLOW}Only on Linux${NORMAL}\n" $N
elif ! cond=$(checkconds "" "" "" "POSIXMQ STDIO SYSTEM" "POSIXMQ-SEND POSIXMQ-READ STDIO SYSTEM" "fork max-children mq-prio unlink-early unlink-close"); then
$PRINTF "test $F_n $TEST... ${YELLOW}$cond${NORMAL}\n" $N
cant
elif ! F=$(testfeats POSIXMQ STDIO SYSTEM); then
$PRINTF "test $F_n $TEST... ${YELLOW}Feature $F not available in $SOCAT${NORMAL}\n" $N
cant
elif ! A=$(testaddrs POSIXMQ-SEND POSIXMQ-READ STDIO SYSTEM); then
$PRINTF "test $F_n $TEST... ${YELLOW}Address $A not available in $SOCAT${NORMAL}\n" $N
cant
elif ! o=$(testoptions fork max-children mq-prio unlink-early unlink-close) >/dev/null; then
$PRINTF "test $F_n $TEST... ${YELLOW}Option $o not available in $SOCAT${NORMAL}\n" $N
cant
#elif ! runsposixmq >/dev/null; then
# $PRINTF "test $F_n $TEST... ${YELLOW}IPv4 not available${NORMAL}\n" $N
# cant
else
tf="$td/test$N.stdout"
te="$td/test$N.stderr"
@ -19252,6 +19212,8 @@ DCCP-CONNECT dccp4 PORT
#ROXY::127.0.0.1 tcp4 PORT
"
# Above tests introduced before or with 1.8.0.1
# Below test introduced with 1.8.0.2
# Test the readline.sh file overwrite vulnerability
NAME=READLINE_SH_OVERWRITE