tests: read limited amount from /dev/urandom

In some test environments like e.g. Ubuntu & Debian autopkgtest it
can happen that while generating random device names the pipes
between tr and head are considered dead while processing.
That prints (non fatal) issues like:
  Running ip/link/new_link.t [iproute2-this/4.13.0-17-generic]: tr:
write error: Broken pipe
  tr: write error
  PASS

This only happens if reading an infinite amount of chars with the
read from urandom, so reading a defined amount fixes the issue.

Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
This commit is contained in:
Christian Ehrhardt 2018-01-10 16:11:36 +01:00 committed by Stephen Hemminger
parent a8b970d7d2
commit 4afbeaeeaf

View File

@ -87,7 +87,7 @@ ts_qdisc_available()
rand_dev()
{
echo "dev-$(tr -dc "[:alpha:]" < /dev/urandom | head -c 6)"
echo "dev-$(head -c 250 /dev/urandom | tr -dc '[:alpha:]' | head -c 6)"
}
pr_failed()