[PATCH iproute2 v2 0/2] tests: fix issues in autopkgtest environment

STALE3141d

Revision v2 of 2 in this series.

4 messages, 2 authors, 2018-01-10 · open the first message on its own page

[PATCH iproute2 v2 0/2] tests: fix issues in autopkgtest environment

From: Christian Ehrhardt <hidden>
Date: 2018-01-10 15:11:40

Hi,
while working on Debian bug [1] and the Ubuntu counterpart of it
I found that the tests can throw a broken pipe warning.

I kept the associated check-and-retry of the length separate to
discuss the changes individually - feel free to squash them on
commit if preferred.

*Updates in v2*
tag with --subject-prefix='PATCH iproute2' to trigger the right
review queues in patchwork as requested by Luca Bocassi.

[1]: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=879854

Christian Ehrhardt (2):
  tests: read limited amount from /dev/urandom
  tests: make sure rand_dev suffix has 6 chars

 testsuite/lib/generic.sh | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

-- 
2.7.4

[PATCH iproute2 v2 1/2] tests: read limited amount from /dev/urandom

From: Christian Ehrhardt <hidden>
Date: 2018-01-10 15:11:40

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 <redacted>
---
 testsuite/lib/generic.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/testsuite/lib/generic.sh b/testsuite/lib/generic.sh
index b7de704..3645ff5 100644
--- a/testsuite/lib/generic.sh
+++ b/testsuite/lib/generic.sh
@@ -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()
-- 
2.7.4

[PATCH iproute2 v2 2/2] tests: make sure rand_dev suffix has 6 chars

From: Christian Ehrhardt <hidden>
Date: 2018-01-10 15:11:41

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 <redacted>
---
 testsuite/lib/generic.sh | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/testsuite/lib/generic.sh b/testsuite/lib/generic.sh
index 3645ff5..8cef20f 100644
--- a/testsuite/lib/generic.sh
+++ b/testsuite/lib/generic.sh
@@ -87,7 +87,11 @@ ts_qdisc_available()
 
 rand_dev()
 {
-    echo "dev-$(head -c 250 /dev/urandom | tr -dc '[:alpha:]' | head -c 6)"
+    rnd=""
+    while [ ${#rnd} -ne 6 ]; do
+        rnd="$(head -c 250 /dev/urandom | tr -dc '[:alpha:]' | head -c 6)"
+    done
+    echo "dev-$rnd"
 }
 
 pr_failed()
-- 
2.7.4

Re: [PATCH iproute2 v2 0/2] tests: fix issues in autopkgtest environment

From: Stephen Hemminger <stephen@networkplumber.org>
Date: 2018-01-10 16:31:22

On Wed, 10 Jan 2018 16:11:35 +0100
Christian Ehrhardt [off-list ref] wrote:
Hi,
while working on Debian bug [1] and the Ubuntu counterpart of it
I found that the tests can throw a broken pipe warning.

I kept the associated check-and-retry of the length separate to
discuss the changes individually - feel free to squash them on
commit if preferred.

*Updates in v2*
tag with --subject-prefix='PATCH iproute2' to trigger the right
review queues in patchwork as requested by Luca Bocassi.

[1]: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=879854

Christian Ehrhardt (2):
  tests: read limited amount from /dev/urandom
  tests: make sure rand_dev suffix has 6 chars

 testsuite/lib/generic.sh | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
Looks good. Applied.
The method of generating a name seems a bit overly complex.
Maybe using something like pwgen would be easier.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help