From patchwork Wed Sep 11 16:52:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Clemens Famulla-Conrad X-Patchwork-Id: 1161157 X-Patchwork-Delegate: petr.vorel@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=lists.linux.it (client-ip=2001:1418:10:5::2; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=suse.de Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46T7Hc11rmz9sDB for ; Thu, 12 Sep 2019 02:52:41 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 72F303C2091 for ; Wed, 11 Sep 2019 18:52:37 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-6.smtp.seeweb.it (in-6.smtp.seeweb.it [IPv6:2001:4b78:1:20::6]) by picard.linux.it (Postfix) with ESMTP id 5D73F3C178C for ; Wed, 11 Sep 2019 18:52:35 +0200 (CEST) Received: from mx1.suse.de (mx2.suse.de [195.135.220.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by in-6.smtp.seeweb.it (Postfix) with ESMTPS id 96F111406CC9 for ; Wed, 11 Sep 2019 18:52:34 +0200 (CEST) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id A2A0AAFB4 for ; Wed, 11 Sep 2019 16:52:33 +0000 (UTC) From: Clemens Famulla-Conrad To: Petr Vorel , ltp@lists.linux.it Date: Wed, 11 Sep 2019 18:52:23 +0200 Message-Id: <20190911165225.2122-1-cfamullaconrad@suse.de> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20190911085536.25546-1-cfamullaconrad@suse.de> References: <20190911085536.25546-1-cfamullaconrad@suse.de> X-Virus-Scanned: clamav-milter 0.99.2 at in-6.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.0 required=7.0 tests=SPF_HELO_NONE,SPF_PASS autolearn=disabled version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-6.smtp.seeweb.it Subject: [LTP] [PATCH v2 1/3] tst_test.sh: Use LTP_TIMEOUT_MUL in TST_RETRY_FN() X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Because of timeout problems when using TST_RETRY_FN() we do now use LTP_TIMEOUT_MUL to adopt the timeout value. Introduced tst_adjut_timeout function to have a generic place to adopt timeout values. Signed-off-by: Clemens Famulla-Conrad Acked-by: Petr Vorel --- testcases/lib/tst_test.sh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/testcases/lib/tst_test.sh b/testcases/lib/tst_test.sh index e0b24c6b9..03692e503 100644 --- a/testcases/lib/tst_test.sh +++ b/testcases/lib/tst_test.sh @@ -164,7 +164,7 @@ TST_RETRY_FN_EXP_BACKOFF() { local tst_fun="$1" local tst_exp=$2 - local tst_sec=$(expr $3 \* 1000000) + local tst_sec=$(tst_adjust_timeout $(expr $3 \* 1000000)) local tst_delay=1 if [ $# -ne 3 ]; then @@ -371,12 +371,16 @@ _tst_rescmp() fi } - -_tst_setup_timer() +tst_adjust_timeout() { LTP_TIMEOUT_MUL=${LTP_TIMEOUT_MUL:-1} + local timeout=$1 + echo $(( timeout * LTP_TIMEOUT_MUL)) +} - local sec=$((300 * LTP_TIMEOUT_MUL)) +_tst_setup_timer() +{ + local sec=$(tst_adjust_timeout 300) local h=$((sec / 3600)) local m=$((sec / 60 % 60)) local s=$((sec % 60)) From patchwork Wed Sep 11 16:52:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Clemens Famulla-Conrad X-Patchwork-Id: 1161159 X-Patchwork-Delegate: petr.vorel@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=lists.linux.it (client-ip=213.254.12.146; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=suse.de Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46T7Hq0J23z9sDB for ; Thu, 12 Sep 2019 02:52:55 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 867703C20F1 for ; Wed, 11 Sep 2019 18:52:52 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-4.smtp.seeweb.it (in-4.smtp.seeweb.it [IPv6:2001:4b78:1:20::4]) by picard.linux.it (Postfix) with ESMTP id 2A7B03C20B5 for ; Wed, 11 Sep 2019 18:52:37 +0200 (CEST) Received: from mx1.suse.de (mx2.suse.de [195.135.220.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by in-4.smtp.seeweb.it (Postfix) with ESMTPS id 310351000D06 for ; Wed, 11 Sep 2019 18:52:29 +0200 (CEST) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id C6D66AFAE for ; Wed, 11 Sep 2019 16:52:36 +0000 (UTC) From: Clemens Famulla-Conrad To: Petr Vorel , ltp@lists.linux.it Date: Wed, 11 Sep 2019 18:52:24 +0200 Message-Id: <20190911165225.2122-2-cfamullaconrad@suse.de> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20190911165225.2122-1-cfamullaconrad@suse.de> References: <20190911085536.25546-1-cfamullaconrad@suse.de> <20190911165225.2122-1-cfamullaconrad@suse.de> X-Virus-Scanned: clamav-milter 0.99.2 at in-4.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.0 required=7.0 tests=SPF_HELO_NONE,SPF_PASS autolearn=disabled version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-4.smtp.seeweb.it Subject: [LTP] [PATCH v2 2/3] tst_test.c: Add tst_adjust_timeout() X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" This function is used to adjust timeout values with environment variables like LTP_TIMEOUT_MUL. Signed-off-by: Clemens Famulla-Conrad --- include/tst_test.h | 1 + lib/tst_test.c | 32 ++++++++++++++++++++------------ 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/include/tst_test.h b/include/tst_test.h index cdeaf6ad0..908015846 100644 --- a/include/tst_test.h +++ b/include/tst_test.h @@ -261,6 +261,7 @@ const char *tst_strsig(int sig); const char *tst_strstatus(int status); unsigned int tst_timeout_remaining(void); +unsigned int tst_adjust_timeout(unsigned int timeout); void tst_set_timeout(int timeout); diff --git a/lib/tst_test.c b/lib/tst_test.c index d2cf92608..1283dba1a 100644 --- a/lib/tst_test.c +++ b/lib/tst_test.c @@ -36,6 +36,7 @@ struct tst_test *tst_test; static const char *tid; static int iterations = 1; static float duration = -1; +static float timeout_mul = -1; static pid_t main_pid, lib_pid; static int mntpoint_mounted; static int ovl_mounted; @@ -1087,25 +1088,32 @@ unsigned int tst_timeout_remaining(void) return 0; } -void tst_set_timeout(int timeout) +unsigned int tst_adjust_timeout(unsigned int timeout) { - char *mul = getenv("LTP_TIMEOUT_MUL"); + char *mul; + if (timeout_mul == -1){ + mul = getenv("LTP_TIMEOUT_MUL"); + if (mul) { + timeout_mul = atof(mul); + if (timeout_mul < 1) + tst_brk(TBROK, + "Invalid timeout multiplier '%s'", + mul); + } else { + timeout_mul = 1; + } + } + return timeout * timeout_mul + 0.5; +} +void tst_set_timeout(int timeout) +{ if (timeout == -1) { tst_res(TINFO, "Timeout per run is disabled"); return; } - results->timeout = timeout; - - if (mul) { - float m = atof(mul); - - if (m < 1) - tst_brk(TBROK, "Invalid timeout multiplier '%s'", mul); - - results->timeout = results->timeout * m + 0.5; - } + results->timeout = tst_adjust_timeout(timeout); tst_res(TINFO, "Timeout per run is %uh %02um %02us", results->timeout/3600, (results->timeout%3600)/60, From patchwork Wed Sep 11 16:52:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Clemens Famulla-Conrad X-Patchwork-Id: 1161158 X-Patchwork-Delegate: petr.vorel@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=lists.linux.it (client-ip=2001:1418:10:5::2; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=suse.de Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46T7Hh0fpPz9sDB for ; Thu, 12 Sep 2019 02:52:47 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 6D8E03C20A7 for ; Wed, 11 Sep 2019 18:52:45 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-5.smtp.seeweb.it (in-5.smtp.seeweb.it [IPv6:2001:4b78:1:20::5]) by picard.linux.it (Postfix) with ESMTP id DB4933C2098 for ; Wed, 11 Sep 2019 18:52:37 +0200 (CEST) Received: from mx1.suse.de (mx2.suse.de [195.135.220.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by in-5.smtp.seeweb.it (Postfix) with ESMTPS id 1B998605633 for ; Wed, 11 Sep 2019 18:52:39 +0200 (CEST) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id F053DAFB4 for ; Wed, 11 Sep 2019 16:52:36 +0000 (UTC) From: Clemens Famulla-Conrad To: Petr Vorel , ltp@lists.linux.it Date: Wed, 11 Sep 2019 18:52:25 +0200 Message-Id: <20190911165225.2122-3-cfamullaconrad@suse.de> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20190911165225.2122-1-cfamullaconrad@suse.de> References: <20190911085536.25546-1-cfamullaconrad@suse.de> <20190911165225.2122-1-cfamullaconrad@suse.de> X-Virus-Scanned: clamav-milter 0.99.2 at in-5.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.0 required=7.0 tests=SPF_HELO_NONE,SPF_PASS autolearn=disabled version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-5.smtp.seeweb.it Subject: [LTP] [PATCH v2 3/3] tst_common.h: Use tst_adjust_timeout in TST_RETRY_FN() X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Because of timeout problems when using TST_RETRY_FN() we want a LTP_TIMEOUT_MUL adopted timeout value here as well. Signed-off-by: Clemens Famulla-Conrad --- include/tst_common.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/tst_common.h b/include/tst_common.h index c21505450..ca8f06d01 100644 --- a/include/tst_common.h +++ b/include/tst_common.h @@ -50,12 +50,14 @@ TST_RETRY_FN_EXP_BACKOFF(FUNC, ERET, 1) #define TST_RETRY_FN_EXP_BACKOFF(FUNC, ERET, MAX_DELAY) \ -({ int tst_delay_ = 1; \ +({ unsigned int tst_delay_, tst_max_delay_; \ + tst_delay_ = 1; \ + tst_max_delay_ = tst_adjust_timeout(MAX_DELAY * 1000000); \ for (;;) { \ typeof(FUNC) tst_ret_ = FUNC; \ if (tst_ret_ == ERET) \ break; \ - if (tst_delay_ < MAX_DELAY * 1000000) { \ + if (tst_delay_ < tst_max_delay_) { \ usleep(tst_delay_); \ tst_delay_ *= 2; \ } else { \