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

Satisfy some deprecation warnings of newer Linux distributions

This commit is contained in:
Gerhard Rieger 2025-01-17 14:43:35 +01:00
parent 3f4b171523
commit 416fe38e33
4 changed files with 35 additions and 52 deletions

59
test.sh
View file

@ -112,6 +112,17 @@ MICROS=${S}${uS}
MICROS=${MICROS##0000}; MICROS=${MICROS##00}; MICROS=${MICROS##0}
# changed below again
divide_uint_by_1000000 () {
x=$1
if [ ${#x} -ge 7 ]; then
echo ${x%??????}.${x: -6};
else
y=000000$x;
f=${y: -6};
echo 0.$f;
fi
}
_MICROS=$((MICROS+999999)); SECONDs="${_MICROS%??????}"
[ -z "$SECONDs" ] && SECONDs=0
[ "$DEFS" ] && echo "SECONDs=\"$SECONDs\"" >&2
@ -193,7 +204,7 @@ PATH=$PATH:/sbin # RHEL6:ip
case "$0" in
*/*) PATH="${0%/*}:$PATH"
esac
PATH=.:$PATH # for usleep,relsleep
PATH=.:$PATH # for relsleep
[ "$DEFS" ] && echo "PATH=\"$PATH\"" >&2
#OPENSSL_RAND="-rand /dev/egd-pool"
@ -308,47 +319,6 @@ tolower () {
esac
}
if ! which usleep >/dev/null 2>&1; then
cat >usleep <<EOF
#! /usr/bin/env bash
# temporary script from Socat test.sh:
# sleep for a number of µs
u=\$1
l=\${#u}
i=0
[ "\$l" -gt 6 ] && i=\${u%??????}
u0=000000\$u
s=\${i}.\${u0: -6:6};
#echo \$s
sleep \$s
EOF
chmod a+x usleep
fi
# precision sleep; takes seconds with fractional part; sleep does this on all test platforms
if false; then
psleep () {
local T="$1"
[ "$T" = 0 ] && T=0.000002
#$SOCAT -T "$T" PIPE PIPE 2>/dev/null
sleep "$T"
}
# time in microseconds to wait in some situations
if ! type usleep >/dev/null 2>&1 ||
usleep 0 2>&1 |grep -q deprecated; then
usleep () {
local n="$1"
case "$n" in
*???????) S="${n%??????}"; uS="${n:${#n}-6}" ;;
*) S=0; uS="00000$n"; uS="${uS:${#uS}-6}" ;;
esac
#$SOCAT -T "$S.$uS" PIPE PIPE 2>/dev/null
sleep "$S.$uS"
}
fi
#USLEEP=usleep
fi
# calculate the time i*MICROS, output as float number for us with -t
reltime () {
local n="$1"
@ -361,11 +331,12 @@ reltime () {
echo "$S.$uS"
}
# A sleep with configurable clocking ($vat_t)
# A sleep with configurable clocking ($val_t)
# val_t should be at least the time that a Socat invocation, no action, and
# termination takes
relsleep () {
usleep $(($1*MICROS))
#sleep $(($1*MICROS/1000000))
sleep $(divide_uint_by_1000000 $(($1*MICROS)) )
}
cat >relsleep <<-'EOF'