From patchwork Wed Aug 30 14:51:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 9929835 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 3A84960383 for ; Wed, 30 Aug 2017 14:51:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2C096283FF for ; Wed, 30 Aug 2017 14:51:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 20E7D286AB; Wed, 30 Aug 2017 14:51:31 +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 9AD48283FF for ; Wed, 30 Aug 2017 14:51:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751463AbdH3Ov1 (ORCPT ); Wed, 30 Aug 2017 10:51:27 -0400 Received: from mail-wr0-f194.google.com ([209.85.128.194]:35033 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751386AbdH3OvZ (ORCPT ); Wed, 30 Aug 2017 10:51:25 -0400 Received: by mail-wr0-f194.google.com with SMTP id a47so4317575wra.2; Wed, 30 Aug 2017 07:51:25 -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=XzOPjtzoJQLtbfcsxlxm6eKk5oJBo0WpA8bxjeNtwszkyo3LZdsoxygjaRTyCj7G5O VwnxTEUM1IQ/UsT6IlojRq8Fdkct3i5/2PjFtu1GrdezpPNjTthToXH6+tj8febPfg4Y /9cNqGpi0j9QrKUGf+JJ/kxetNGBu9lnfA+R4xDa0U7zPkxPnWiMtSV06JuK5cGR4cAr HVL/lDX5KX2z9f/0EQLit/WtWA1y7N08hoEA7+IWYy10jUH7vMjVXquO5nd0gJaNehlo s8WlLJrpwR4pSKZTVnPALuUA+lRrgt20GKKbODqbmuzxu5iOckmazY8FfA02gCn3JHFG blqg== 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=E+4VI3X2ArqLzYOaf3ydUzDT5rPRnQjsMkBc+Ub4T8rwAUKwSHMDtLIyCD4Zyiir2e qptZzLi+UkcigY9OUVM4q+Q2dYgXBE5qiabkxL5wDbu9PBxjtEONYt8Tk40TrePRWQ9C BZ7Fead2es4Mps/2P7G/NuZTHmU+Ctz1ak29Cn3HJ84VV15DcdE/Fi0r212wvh11bVmD xYFi9LX7FrhEWFACSTkMKCMK5sXEvcktTbgPljf1OC3Ggk843zzozKj6Kbh6i1sKH02I 2n8Xq0nOuBSuUNweHlYqw0HumcTFbkeeKRiOgfs1Ko17rxOqNPDsSLUFp0Z/L4z51ABx cjnQ== X-Gm-Message-State: AHYfb5g/vY6EZSGk8qw7SlsAy0yA+E0HlbfCkBdwqsaqukQJiAdFxbja BHEhiUZ4D8pQAg== X-Received: by 10.223.141.182 with SMTP id o51mr1169962wrb.199.1504104684422; Wed, 30 Aug 2017 07:51:24 -0700 (PDT) Received: from localhost.localdomain (bzq-166-168-31-246.red.bezeqint.net. [31.168.166.246]) by smtp.gmail.com with ESMTPSA id f42sm2606306wrf.27.2017.08.30.07.51.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 30 Aug 2017 07:51:23 -0700 (PDT) From: Amir Goldstein To: Eryu Guan Cc: Josef Bacik , "Darrick J . Wong" , Christoph Hellwig , fstests@vger.kernel.org, linux-xfs@vger.kernel.org Subject: [PATCH v2 03/14] fsx: fixes to random seed Date: Wed, 30 Aug 2017 17:51:35 +0300 Message-Id: <1504104706-11965-4-git-send-email-amir73il@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504104706-11965-1-git-send-email-amir73il@gmail.com> References: <1504104706-11965-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) {