From patchwork Thu Oct 18 12:52:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Kodanev X-Patchwork-Id: 985852 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=fail (p=none dis=none) header.from=oracle.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=oracle.com header.i=@oracle.com header.b="Qobzrf3/"; dkim-atps=neutral Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42bTG14Lghz9s8T for ; Thu, 18 Oct 2018 23:42:16 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 87B173E6103 for ; Thu, 18 Oct 2018 14:42:13 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-7.smtp.seeweb.it (in-7.smtp.seeweb.it [217.194.8.7]) by picard.linux.it (Postfix) with ESMTP id 799523E60E3 for ; Thu, 18 Oct 2018 14:42:11 +0200 (CEST) Received: from userp2120.oracle.com (userp2120.oracle.com [156.151.31.85]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by in-7.smtp.seeweb.it (Postfix) with ESMTPS id 912D4201130 for ; Thu, 18 Oct 2018 14:42:10 +0200 (CEST) Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w9ICd5sb155189 for ; Thu, 18 Oct 2018 12:42:08 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id; s=corp-2018-07-02; bh=FKEzclGXduFS6qGmw7vIXN92Uu6zdmtXz4AbpaTQ31s=; b=Qobzrf3/s2benXATX+ORv2kAvEf84odBmxjSHhamcLxnMvlCB14PFyOqWpmaduc9pv0s q472ERkyzQvfIevJlgCiSypfpXIFAzCM7b0Ah9VYyB5zoRbtJrGEBQF8x2DpbldYgW9N daZhpFo5hd16EMl3Hr8B4axTtqyzhMx0mtlSl/w9Y/PqMkpC6qpAddScPBxUf5TGJyEU bByKrzquwzfj3zuiPiIHCNaOioPhOXzB8j4/fjhg/qK0iLp0l8XiI6Vbmvwgv+fWOh4O Me0s+w7jX8vbJlnb/3sMne1RyJoQuzuxLCkYV1sa9I6ECBjn6kH/DPCF8iANpBlh0bqE bw== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp2120.oracle.com with ESMTP id 2n39brp38h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 18 Oct 2018 12:42:08 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w9ICg7P6024069 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 18 Oct 2018 12:42:07 GMT Received: from abhmp0006.oracle.com (abhmp0006.oracle.com [141.146.116.12]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w9ICg7K2029152 for ; Thu, 18 Oct 2018 12:42:07 GMT Received: from ak.ru.oracle.com (/10.162.80.29) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 18 Oct 2018 05:42:06 -0700 From: Alexey Kodanev To: ltp@lists.linux.it Date: Thu, 18 Oct 2018 15:52:10 +0300 Message-Id: <1539867130-14299-1-git-send-email-alexey.kodanev@oracle.com> X-Mailer: git-send-email 1.7.1 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9049 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=595 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810180114 X-Virus-Scanned: clamav-milter 0.99.2 at in-7.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, SPF_HELO_PASS, SPF_PASS autolearn=disabled version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-7.smtp.seeweb.it Subject: [LTP] [PATCH] lib/tst_test.sh: setup timeout per test run for the shell tests 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" Use LTP_TIMEOUT_MUL environment variable, similar to what we have in the C library. Basically, the patch puts the child process with kill command to the background to signal the test process group processes after the certain timeout, which is controlled by LTP_TIMEOUT_MUL. Signed-off-by: Alexey Kodanev Reviewed-by: Petr Vorel --- testcases/lib/tst_test.sh | 24 ++++++++++++++++++++++++ 1 files changed, 24 insertions(+), 0 deletions(-) diff --git a/testcases/lib/tst_test.sh b/testcases/lib/tst_test.sh index 7a41309..a7aa608 100644 --- a/testcases/lib/tst_test.sh +++ b/testcases/lib/tst_test.sh @@ -42,6 +42,11 @@ _tst_do_exit() { local ret=0 + if [ -n "$_tst_setup_timer_pid" ]; then + kill $_tst_setup_timer_pid + wait $_tst_setup_timer_pid 2>/dev/null + fi + if [ -n "$TST_SETUP_STARTED" -a -n "$TST_CLEANUP" -a \ -z "$TST_NO_CLEANUP" ]; then $TST_CLEANUP @@ -347,6 +352,23 @@ _tst_rescmp() fi } + +_tst_setup_timer() +{ + LTP_TIMEOUT_MUL=${LTP_TIMEOUT_MUL:-1} + + local sec=$((300 * LTP_TIMEOUT_MUL)) + local h=$((sec / 3600)) + local m=$((sec / 60 % 60)) + local s=$((sec % 60)) + local pid=$$ + + tst_res TINFO "timeout per run is ${h}h ${m}m ${s}s" + + sleep $sec && kill -INT -$pid & + _tst_setup_timer_pid=$! +} + tst_run() { local _tst_i @@ -406,6 +428,8 @@ tst_run() tst_brk TCONF "test requires kernel $TST_MIN_KVER+" fi + _tst_setup_timer + if [ "$TST_NEEDS_TMPDIR" = 1 ]; then if [ -z "$TMPDIR" ]; then export TMPDIR="/tmp"