From patchwork Thu Oct 22 07:33:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Xu X-Patchwork-Id: 1386009 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) 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=cn.fujitsu.com 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 4CGzdD17Cmz9sVN for ; Thu, 22 Oct 2020 18:34:05 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 5C1D73C3196 for ; Thu, 22 Oct 2020 09:33:52 +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 8F4343C25F7 for ; Thu, 22 Oct 2020 09:33:50 +0200 (CEST) Received: from heian.cn.fujitsu.com (mail.cn.fujitsu.com [183.91.158.132]) by in-5.smtp.seeweb.it (Postfix) with ESMTP id 6363160098E for ; Thu, 22 Oct 2020 09:33:48 +0200 (CEST) X-IronPort-AV: E=Sophos;i="5.77,403,1596470400"; d="scan'208";a="100401608" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 22 Oct 2020 15:33:46 +0800 Received: from G08CNEXMBPEKD04.g08.fujitsu.local (unknown [10.167.33.201]) by cn.fujitsu.com (Postfix) with ESMTP id 0752E4CE1505; Thu, 22 Oct 2020 15:33:42 +0800 (CST) Received: from localhost.localdomain (10.167.220.84) by G08CNEXMBPEKD04.g08.fujitsu.local (10.167.33.201) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 22 Oct 2020 15:33:41 +0800 From: Yang Xu To: , Date: Thu, 22 Oct 2020 15:33:49 +0800 Message-ID: <1603352029-11446-1-git-send-email-xuyang2018.jy@cn.fujitsu.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <5F913024.7050303@cn.fujitsu.com> References: <5F913024.7050303@cn.fujitsu.com> MIME-Version: 1.0 X-Originating-IP: [10.167.220.84] X-ClientProxiedBy: G08CNEXCHPEKD06.g08.fujitsu.local (10.167.33.205) To G08CNEXMBPEKD04.g08.fujitsu.local (10.167.33.201) X-yoursite-MailScanner-ID: 0752E4CE1505.A9AEF X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: xuyang2018.jy@cn.fujitsu.com X-Spam-Status: No, score=0.3 required=7.0 tests=KHOP_HELO_FCRDNS, SPF_HELO_NONE, SPF_NONE autolearn=disabled version=3.4.4 X-Virus-Scanned: clamav-milter 0.102.4 at in-5.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-5.smtp.seeweb.it Subject: [LTP] [PATCH v2] Remove ftime and sys/timeb.h 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: , Cc: ltp@lists.linux.it Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" The two case uses ftime to get the current milliseconds and it was used to generate random value. Using gettimeofday() to get the microseconds can reach the same aim. This also fixes the travis build error[1] on Fedora:Rawhide because the has been deprecated[2]. [1] https://travis-ci.org/github/linux-test-project/ltp/jobs/737698948 [2] https://www.spinics.net/lists/fedora-devel/msg279545.html Reviewed-by: Li Wang Acked-by: Jan Stancek Acked-by: Xiao Yang Signed-off-by: Yang Xu --- v1->v2 1.Remove useless "% 1000000" since the range of tv_usec is 0~999999. 2.case suseconds_t to unsigned int testcases/kernel/mem/hugetlb/lib/hugetlb.c | 12 ++++++------ testcases/kernel/sched/tool/trace_sched.c | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/testcases/kernel/mem/hugetlb/lib/hugetlb.c b/testcases/kernel/mem/hugetlb/lib/hugetlb.c index 4bb2d500e..1204f21d2 100644 --- a/testcases/kernel/mem/hugetlb/lib/hugetlb.c +++ b/testcases/kernel/mem/hugetlb/lib/hugetlb.c @@ -35,7 +35,7 @@ #include #include #include -#include +#include #include #include "hugetlb.h" @@ -52,7 +52,7 @@ int getipckey(void) char *curdir = NULL; size_t size = 0; key_t ipc_key; - struct timeb time_info; + struct timeval time_info; curdir = getcwd(curdir, size); if (curdir == NULL) @@ -67,11 +67,11 @@ int getipckey(void) * project identifier is a "random character" produced by * generating a random number between 0 and 25 and then adding * that to the ascii value of 'a'. The "seed" for the random - * number is the millisecond value that is set in the timeb - * structure after calling ftime(). + * number is the microseconds value that is set in the timeval + * structure after calling gettimeofday(). */ - ftime(&time_info); - srandom((unsigned int)time_info.millitm); + gettimeofday(&time_info, NULL); + srandom((unsigned int)time_info.tv_usec); ipc_key = ftok(curdir, ascii_a + random() % 26); if (ipc_key == -1) diff --git a/testcases/kernel/sched/tool/trace_sched.c b/testcases/kernel/sched/tool/trace_sched.c index 71caf239a..85c4b23ad 100644 --- a/testcases/kernel/sched/tool/trace_sched.c +++ b/testcases/kernel/sched/tool/trace_sched.c @@ -52,7 +52,7 @@ #include #include #include -#include +#include #include #include @@ -199,7 +199,7 @@ void *thread_func(void *args) static int sched_policy; /* scheduling policy as set by user/default */ struct sched_param ssp; /* set schedule priority. */ struct sched_param gsp; /* gsp schedule priority. */ - struct timeb tptr; /* tptr.millitm will be used to seed srand. */ + struct timeval tptr; /* tptr.tv_usec will be used to seed srand. */ thread_sched_t *locargptr = /* local ptr to the arguments. */ (thread_sched_t *) args; @@ -215,8 +215,8 @@ void *thread_func(void *args) ssp.sched_priority = 0; else { /* Set a random value between max_priority and min_priority */ - ftime(&tptr); - srand((tptr.millitm) % 1000); + gettimeofday(&tptr, NULL); + srand((unsigned int)tptr.tv_usec); set_priority = (min_priority + (int)((float)max_priority * rand() / (RAND_MAX + 1.0)));