From patchwork Tue Jan 2 07:28:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Ehrhardt X-Patchwork-Id: 854410 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3z9lzd4GDpz9t3M for ; Tue, 2 Jan 2018 18:28:45 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751932AbeABH2o (ORCPT ); Tue, 2 Jan 2018 02:28:44 -0500 Received: from youngberry.canonical.com ([91.189.89.112]:39809 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751809AbeABH2m (ORCPT ); Tue, 2 Jan 2018 02:28:42 -0500 Received: from 1.general.paelzer.uk.vpn ([10.172.196.172] helo=localhost.localdomain) by youngberry.canonical.com with esmtpsa (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1eWH05-00037j-Jp; Tue, 02 Jan 2018 07:28:41 +0000 From: Christian Ehrhardt To: Netdev Cc: Luca Boccassi , Christian Ehrhardt Subject: [PATCH 2/2] tests: make sure rand_dev suffix has 6 chars Date: Tue, 2 Jan 2018 08:28:38 +0100 Message-Id: <1514878118-21009-3-git-send-email-christian.ehrhardt@canonical.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1514878118-21009-1-git-send-email-christian.ehrhardt@canonical.com> References: <1514878118-21009-1-git-send-email-christian.ehrhardt@canonical.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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 --- 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()