From patchwork Thu Sep 7 07:26:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 9941671 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 6221A604D5 for ; Thu, 7 Sep 2017 07:26:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5512B2847D for ; Thu, 7 Sep 2017 07:26:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4A3AD28533; Thu, 7 Sep 2017 07:26:16 +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 DC0E328534 for ; Thu, 7 Sep 2017 07:26:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753419AbdIGH0P (ORCPT ); Thu, 7 Sep 2017 03:26:15 -0400 Received: from mail-wr0-f193.google.com ([209.85.128.193]:38579 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752276AbdIGH0P (ORCPT ); Thu, 7 Sep 2017 03:26:15 -0400 Received: by mail-wr0-f193.google.com with SMTP id p37so1897496wrb.5 for ; Thu, 07 Sep 2017 00:26:14 -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=8djCC5knYuOAY5SdwOToYvZIru7e1yUvQEHo08Fk9lA=; b=ZVgzsHURD0e4c+PT8yeVn8rLFAbAQyFdU0v71WZnGENaGH+jQ23H/5nY+ymS/V3wON Z1t5CiW/pq5PsesHtV7VskawbU1GYXHtu6Bte5bdsJYRPeF3ETfpu0CwJXp2VjMpxSM1 z8IQNY4r0xN4CjW2p6eKCG9Qaun6XbShykH9uDeah+uRiItVGOHxh4aMjrK89Kjuq5BL XZ1Iq4M9XmYLWmBTtu8OX/gacJ2Z3O66oglb7bWuZ0j4TZiKPHjRT3pz7r2f9BO5QHwi x0vYO9jRQbjDtCJ1d9/kBmLh+BgHvcbXafcve/4mwOmL3A9a3j2Dn5u8r592S6GVDdqz CbPA== 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=8djCC5knYuOAY5SdwOToYvZIru7e1yUvQEHo08Fk9lA=; b=MnL6ce5Dc7u3Eg4nJv9HOQ0CfVsE3s/SF/6FV664rT1ZirjkQIFID0eDY4xGZpJuS1 sl8rq37AYtCzRzIWirXfufOmPZtTqZWJ2NmUitryNciy+zwR/vgpkH6fuQNDmJOu5NSc MkkdjtDh7iovX53SrnNYagvPE40c2H6PUNXOmIjWVTDjRQOHd9P/mFAVzX66awjSDVvv o23jDpdqcC5jh/f3ucaVMkIV9/8Zc9zH3oLraPBMwefwRZLwJyaCCRrOdWkvUNoePbqz 7t0Y5Lat3nd3jR3sfl0k1Fo4EbyB6UU+G+9y4herjqNzXS650Aul2dIrbVwXtx4u0xVp qBfw== X-Gm-Message-State: AHPjjUj/9Fm5ije3O6UzVqRPT95u1TIfPr6E+aA/PHcihtTX81tT8bt5 V5ggwL8K2xC0I5Ys X-Google-Smtp-Source: ADKCNb5RRlR307aDF32vC2ouQiLBkIM71rcHcPjEni0vVWdn2909j8lpot2gZfBALnAQT8bZw+XupQ== X-Received: by 10.223.169.83 with SMTP id u77mr1045450wrc.268.1504769173876; Thu, 07 Sep 2017 00:26:13 -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 61sm1394452wre.44.2017.09.07.00.26.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 07 Sep 2017 00:26:13 -0700 (PDT) From: Amir Goldstein To: Eryu Guan Cc: fstests@vger.kernel.org Subject: [PATCH v4 3/5] fsx: add support for recording operations to a file Date: Thu, 7 Sep 2017 10:26:36 +0300 Message-Id: <1504769198-4921-4-git-send-email-amir73il@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504769198-4921-1-git-send-email-amir73il@gmail.com> References: <1504769198-4921-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 Usually, fsx dumps an .fsxops file on failure with same basename as work file and possibly under dirctory specified by -P dirpath. The --record-ops[=opsfile] flag can be use to dump ops file also on success and to optionally specify the ops file name. Signed-off-by: Amir Goldstein --- ltp/fsx.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/ltp/fsx.c b/ltp/fsx.c index 4e733f9..67d76dc 100644 --- a/ltp/fsx.c +++ b/ltp/fsx.c @@ -180,6 +180,7 @@ int aio_rw(int rw, int fd, char *buf, unsigned len, unsigned offset); #endif const char *replayops = NULL; +const char *recordops = NULL; FILE * fsxlogf = NULL; FILE * replayopsf = NULL; char opsfile[1024]; @@ -1676,6 +1677,8 @@ usage(void) -W: mapped write operations DISabled\n\ -R: read() system calls only (mapped reads disabled)\n\ -Z: O_DIRECT (use -R, -W, -r and -w too)\n\ + --replay-ops opsfile: replay ops from recorded .fsxops file\n\ + --record-ops[=opsfile]: dump ops file also on success. optionally specify ops file name\n\ fname: this filename is REQUIRED (no default)\n"); exit(90); } @@ -1844,6 +1847,7 @@ __test_fallocate(int mode, const char *mode_str) static struct option longopts[] = { {"replay-ops", required_argument, 0, 256}, + {"record-ops", optional_argument, 0, 255}, { } }; @@ -2034,6 +2038,11 @@ main(int argc, char **argv) case 'Z': o_direct = O_DIRECT; break; + case 255: /* --record-ops */ + if (optarg) + strncpy(opsfile, optarg, sizeof(opsfile)); + recordops = opsfile; + break; case 256: /* --replay-ops */ replayops = optarg; break; @@ -2113,8 +2122,10 @@ main(int argc, char **argv) prterr(logfile); exit(93); } - strncat(opsfile, dirpath ? bname : fname, 256); - strcat(opsfile, ".fsxops"); + if (!*opsfile) { + strncat(opsfile, dirpath ? bname : fname, 256); + strcat(opsfile, ".fsxops"); + } unlink(opsfile); if (replayops) { @@ -2195,6 +2206,8 @@ main(int argc, char **argv) report_failure(99); } prt("All %lu operations completed A-OK!\n", testcalls); + if (recordops) + logdump(); exit(0); return 0;