From patchwork Thu Aug 16 12:00:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Palethorpe X-Patchwork-Id: 958250 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.com Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41rlK10LPDz9s2P for ; Thu, 16 Aug 2018 22:00:36 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 0EC3D3E64F0 for ; Thu, 16 Aug 2018 14:00:34 +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 358C53E64D7 for ; Thu, 16 Aug 2018 14:00:32 +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 7FC7D10009FF for ; Thu, 16 Aug 2018 14:00:31 +0200 (CEST) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id EF453ACCD; Thu, 16 Aug 2018 12:00:30 +0000 (UTC) From: Richard Palethorpe To: ltp@lists.linux.it Date: Thu, 16 Aug 2018 14:00:17 +0200 Message-Id: <20180816120020.11042-1-rpalethorpe@suse.com> X-Mailer: git-send-email 2.18.0 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_PASS autolearn=disabled version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-4.smtp.seeweb.it Cc: Richard Palethorpe Subject: [LTP] [PATCH v3 1/4] lib: Allow user to easily get LTP_TIMEOUT_MUL value X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.18 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" Signed-off-by: Richard Palethorpe --- include/tst_test.h | 1 + lib/tst_test.c | 23 ++++++++++++++--------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/include/tst_test.h b/include/tst_test.h index 98dacf387..0ad9025f2 100644 --- a/include/tst_test.h +++ b/include/tst_test.h @@ -217,6 +217,7 @@ const char *tst_strsig(int sig); */ const char *tst_strstatus(int status); +float tst_timeout_mul(void); void tst_set_timeout(int timeout); #ifndef TST_NO_DEFAULT_MAIN diff --git a/lib/tst_test.c b/lib/tst_test.c index 2f3d357d2..f760e05b3 100644 --- a/lib/tst_test.c +++ b/lib/tst_test.c @@ -992,26 +992,31 @@ static void sigint_handler(int sig LTP_ATTRIBUTE_UNUSED) } } -void tst_set_timeout(int timeout) +float tst_timeout_mul(void) { char *mul = getenv("LTP_TIMEOUT_MUL"); - 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; + return m; + } + + return 1; +} + +void tst_set_timeout(int timeout) +{ + if (timeout == -1) { + tst_res(TINFO, "Timeout per run is disabled"); + return; } + results->timeout = timeout * tst_timeout_mul() + 0.5; + tst_res(TINFO, "Timeout per run is %uh %02um %02us", results->timeout/3600, (results->timeout%3600)/60, results->timeout % 60);