mirror of
https://git.proxmox.com/git/mirror_iproute2
synced 2025-10-21 23:32:24 +00:00

The change to limit the read size from /dev/urandom is a tradeoff. Reading too much can trigger an issue, but so it could if the suggested 250 random chars would not contain enough [:alpha:] chars. If they contain: a) >=6 all is ok b) [1-5] the devname would be shorter than expected (non fatal). c) 0 things would break In loops of hundreds of thousands it always was (a) for my, but since if occuring in a test it might be hard to track what happened avoid this issue by retrying on the length condition. Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
140 lines
1.9 KiB
Bash
140 lines
1.9 KiB
Bash
|
|
export DEST="127.0.0.1"
|
|
|
|
ts_log()
|
|
{
|
|
echo "$@"
|
|
}
|
|
|
|
ts_err()
|
|
{
|
|
ts_log "$@" | tee >> $ERRF
|
|
}
|
|
|
|
ts_cat()
|
|
{
|
|
cat "$@"
|
|
}
|
|
|
|
ts_err_cat()
|
|
{
|
|
ts_cat "$@" | tee >> $ERRF
|
|
}
|
|
|
|
ts_skip()
|
|
{
|
|
exit 127
|
|
}
|
|
|
|
ts_tc()
|
|
{
|
|
SCRIPT=$1; shift
|
|
DESC=$1; shift
|
|
|
|
$TC $@ 2> $STD_ERR > $STD_OUT
|
|
|
|
if [ -s $STD_ERR ]; then
|
|
ts_err "${SCRIPT}: ${DESC} failed:"
|
|
ts_err "command: $TC $@"
|
|
ts_err "stderr output:"
|
|
ts_err_cat $STD_ERR
|
|
if [ -s $STD_OUT ]; then
|
|
ts_err "stdout output:"
|
|
ts_err_cat $STD_OUT
|
|
fi
|
|
elif [ -s $STD_OUT ]; then
|
|
echo "${SCRIPT}: ${DESC} succeeded with output:"
|
|
cat $STD_OUT
|
|
else
|
|
echo "${SCRIPT}: ${DESC} succeeded"
|
|
fi
|
|
}
|
|
|
|
ts_ip()
|
|
{
|
|
SCRIPT=$1; shift
|
|
DESC=$1; shift
|
|
|
|
$IP $@ 2> $STD_ERR > $STD_OUT
|
|
RET=$?
|
|
|
|
if [ -s $STD_ERR ] || [ "$RET" != "0" ]; then
|
|
ts_err "${SCRIPT}: ${DESC} failed:"
|
|
ts_err "command: $IP $@"
|
|
ts_err "stderr output:"
|
|
ts_err_cat $STD_ERR
|
|
if [ -s $STD_OUT ]; then
|
|
ts_err "stdout output:"
|
|
ts_err_cat $STD_OUT
|
|
fi
|
|
elif [ -s $STD_OUT ]; then
|
|
echo "${SCRIPT}: ${DESC} succeeded with output:"
|
|
cat $STD_OUT
|
|
else
|
|
echo "${SCRIPT}: ${DESC} succeeded"
|
|
fi
|
|
}
|
|
|
|
ts_qdisc_available()
|
|
{
|
|
HELPOUT=`$TC qdisc add $1 help 2>&1`
|
|
if [ "`echo $HELPOUT | grep \"^Unknown qdisc\"`" ]; then
|
|
return 0;
|
|
else
|
|
return 1;
|
|
fi
|
|
}
|
|
|
|
rand_dev()
|
|
{
|
|
rnd=""
|
|
while [ ${#rnd} -ne 6 ]; do
|
|
rnd="$(head -c 250 /dev/urandom | tr -dc '[:alpha:]' | head -c 6)"
|
|
done
|
|
echo "dev-$rnd"
|
|
}
|
|
|
|
pr_failed()
|
|
{
|
|
echo " [FAILED]"
|
|
ts_err "matching failed"
|
|
}
|
|
|
|
pr_success()
|
|
{
|
|
echo " [SUCCESS]"
|
|
}
|
|
|
|
test_on()
|
|
{
|
|
echo -n "test on: \"$1\""
|
|
if cat "$STD_OUT" | grep -qE "$1"
|
|
then
|
|
pr_success
|
|
else
|
|
pr_failed
|
|
fi
|
|
}
|
|
|
|
test_on_not()
|
|
{
|
|
echo -n "test on: \"$1\""
|
|
if cat "$STD_OUT" | grep -vqE "$1"
|
|
then
|
|
pr_success
|
|
else
|
|
pr_failed
|
|
fi
|
|
}
|
|
|
|
test_lines_count()
|
|
{
|
|
echo -n "test on lines count ($1): "
|
|
if cat "$STD_OUT" | wc -l | grep -q "$1"
|
|
then
|
|
pr_success
|
|
else
|
|
pr_failed
|
|
fi
|
|
}
|