From patchwork Fri Mar 9 07:29:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Stancek X-Patchwork-Id: 883497 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=redhat.com Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zyJtF6dCjz9scY for ; Fri, 9 Mar 2018 18:29:39 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 173193E7499 for ; Fri, 9 Mar 2018 08:29:36 +0100 (CET) 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 380CE3E6FEC for ; Fri, 9 Mar 2018 08:29:33 +0100 (CET) Received: from mx1.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) (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 7F5A3142BBE8 for ; Fri, 9 Mar 2018 08:29:31 +0100 (CET) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DBBE1818AAEB; Fri, 9 Mar 2018 07:29:29 +0000 (UTC) Received: from dustball.brq.redhat.com (unknown [10.43.17.9]) by smtp.corp.redhat.com (Postfix) with ESMTP id EC86A7C31; Fri, 9 Mar 2018 07:29:28 +0000 (UTC) From: Jan Stancek To: ltp@lists.linux.it Date: Fri, 9 Mar 2018 08:29:26 +0100 Message-Id: X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Fri, 09 Mar 2018 07:29:29 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Fri, 09 Mar 2018 07:29:29 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'jstancek@redhat.com' RCPT:'' 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_PASS, T_RP_MATCHES_RCVD autolearn=disabled version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-6.smtp.seeweb.it Cc: liwan@redhat.com Subject: [LTP] [PATCH v2] times03: don't assume process initial [us]time is 0 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" times() runs immediately after fork(), but syscall alone seems to be enough for some systems to already account ticks. For example on arm64 with 4.14: tst_test.c:980: INFO: Timeout per run is 0h 05m 00s times03.c:102: PASS: buf1.tms_utime = 0 times03.c:105: FAIL: buf1.tms_stime = 1 ... This patch replaces zero check with a comparison against a small enough number < 5 (which should be between 5ms and 50ms depending on CONFIG_HZ). Suggested-by: Cyril Hrubis Signed-off-by: Jan Stancek --- testcases/kernel/syscalls/times/times03.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/testcases/kernel/syscalls/times/times03.c b/testcases/kernel/syscalls/times/times03.c index 78d72d259ec1..c34faf5a2ff9 100644 --- a/testcases/kernel/syscalls/times/times03.c +++ b/testcases/kernel/syscalls/times/times03.c @@ -96,15 +96,15 @@ static void verify_times(void) if (times(&buf1) == -1) tst_brk(TBROK | TERRNO, "times()"); - if (buf1.tms_utime != 0) + if (buf1.tms_utime > 5) tst_res(TFAIL, "buf1.tms_utime = %li", buf1.tms_utime); else - tst_res(TPASS, "buf1.tms_utime = 0"); + tst_res(TPASS, "buf1.tms_utime > 5"); - if (buf1.tms_stime != 0) + if (buf1.tms_stime > 5) tst_res(TFAIL, "buf1.tms_stime = %li", buf1.tms_stime); else - tst_res(TPASS, "buf1.tms_stime = 0"); + tst_res(TPASS, "buf1.tms_stime > 5"); generate_utime(); generate_stime();