From patchwork Wed Aug 23 15:49:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 9917653 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 969A7603FA for ; Wed, 23 Aug 2017 15:49:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 87BF2285C3 for ; Wed, 23 Aug 2017 15:49:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7B9F8289D7; Wed, 23 Aug 2017 15:49:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AD539285C3 for ; Wed, 23 Aug 2017 15:49:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932157AbdHWPs5 (ORCPT ); Wed, 23 Aug 2017 11:48:57 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:34355 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932103AbdHWPsy (ORCPT ); Wed, 23 Aug 2017 11:48:54 -0400 Received: by mail-wm0-f67.google.com with SMTP id r187so556529wma.1; Wed, 23 Aug 2017 08:48:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Hn6Zv2Un82vih00wTp16WhHoJ/cU4Y4nH5IKH+C5Yow=; b=M2rDst4Ep7TogjlyQAPZC+fPdroI4QxQOPDFBd26LT08g6ujclGIIlNUwjdQIrfHnw BvDM0M3kVfIBwNge7I3yWgrIIXS/PevWcB//7o/5UQP1jr5VTGbiBcDfDEYC1DD5plka 8ShuDR+8toXoaDyWATO4JFXK+DSv60q88EGveTtu0x1K2yTX1iPMWhqiJ1qAaQypOgOF Swf6fGGbHk6HtUESvYVUstraiEgfpJptFA8vhjbx7XMS59kVgv4UmGg9sZEVI1eITPDi RRsmhy86gJt7ThcpKujT252bRxVNtDbkPQaSXiM9MlOBg3br5q6xlpNZGsNSyBIHZGxH iZ3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Hn6Zv2Un82vih00wTp16WhHoJ/cU4Y4nH5IKH+C5Yow=; b=jVqwFqs6bL24hbSAe5lAp1nKY8dzBg4kriGbYhR7l4bZYWBJSitNywNlvTDx+GMIml 9lzT1YY1hJpgpThGEPPxgCcBvTwYjyg/UcaMTbYZdEdsE2ReERsz4PsjmoPPQq/VLdoq ikdFLGgs40A6V3p6xyviCvQC2HPhRx86tAf1BtTFNGaHh+6sjNqCkr+P4cwLnQE1NwUG whZdq18AUGSfb14FusRNMnZ7xLqImb5z+iseP1pucSQasIs4DfmKs2yAzo0ClM+fOw4R 3jxzdrkvfc79FEf+/X7TfKnNisqxUBfd+m2eagLMhIFRgO7kH5l5VzmXA8JU0AHUKNzV 8tGw== X-Gm-Message-State: AHYfb5iybpPZfevRA1eRmxsTd7j5TRiKnuuEgBUxC6Sij1SWbyCejiGi iwh35up3mwYmz9t4 X-Received: by 10.28.24.83 with SMTP id 80mr1866614wmy.86.1503503332819; Wed, 23 Aug 2017 08:48:52 -0700 (PDT) Received: from localhost.localdomain (bzq-79-182-137-119.red.bezeqint.net. [79.182.137.119]) by smtp.gmail.com with ESMTPSA id a6sm1938879wrh.51.2017.08.23.08.48.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 23 Aug 2017 08:48:52 -0700 (PDT) From: Amir Goldstein To: Eryu Guan Cc: Josef Bacik , Christoph Hellwig , fstests@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [RFC][PATCH 3/8] fsx: fixes to random seed Date: Wed, 23 Aug 2017 18:49:12 +0300 Message-Id: <1503503357-26234-4-git-send-email-amir73il@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503503357-26234-1-git-send-email-amir73il@gmail.com> References: <1503503357-26234-1-git-send-email-amir73il@gmail.com> Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Not sure why, but with initstate()/setstate(), sfx generates same events regadless of the input seed argument. Change to use srandom() to fix the problem. Add pid to auto random seed, so parallel fsx executions with auto seed will use different seed values. At this time there are 6 tests that use sfx, out of which: 2 use -S 0 as seed (gettime()) - generic/{075,112} 2 do not specify seed (default = 1) - generic/{091,263} 1 uses explicit constant seed - generic/127 1 uses explicit $RANDOM seed - generic/231 This change affects all those tests. The tests that intended to randomize the seed will now really randomize the seed. The tests that intended to use a constant seed will still use a constant seed, but resulting event sequence will be different than before this change. Signed-off-by: Amir Goldstein --- ltp/fsx.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ltp/fsx.c b/ltp/fsx.c index 3713bbe..572df75 100644 --- a/ltp/fsx.c +++ b/ltp/fsx.c @@ -116,7 +116,6 @@ int fd; /* fd for our test file */ blksize_t block_size = 0; off_t file_size = 0; off_t biggest = 0; -char state[256]; unsigned long testcalls = 0; /* calls to function "test" */ unsigned long simulatedopcount = 0; /* -b flag */ @@ -1909,8 +1908,10 @@ main(int argc, char **argv) break; case 'S': seed = getnum(optarg, &endp); - if (seed == 0) + if (seed == 0) { seed = time(0) % 10000; + seed += (int)getpid(); + } if (!quiet) fprintf(stdout, "Seed set to %d\n", seed); if (seed < 0) @@ -1948,8 +1949,7 @@ main(int argc, char **argv) signal(SIGUSR1, cleanup); signal(SIGUSR2, cleanup); - initstate(seed, state, 256); - setstate(state); + srandom(seed); fd = open(fname, O_RDWR|(lite ? 0 : O_CREAT|O_TRUNC)|o_direct, 0666); if (fd < 0) {