From patchwork Sun Sep 23 09:40:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 973653 X-Patchwork-Delegate: petr.vorel@gmail.com 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=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=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="huT5matv"; dkim-atps=neutral Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42J2Q51mrBz9s9G for ; Sun, 23 Sep 2018 19:40:44 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id E2C1A3E70C2 for ; Sun, 23 Sep 2018 11:40:41 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-7.smtp.seeweb.it (in-7.smtp.seeweb.it [217.194.8.7]) by picard.linux.it (Postfix) with ESMTP id 540EA3E7095 for ; Sun, 23 Sep 2018 11:40:40 +0200 (CEST) Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by in-7.smtp.seeweb.it (Postfix) with ESMTPS id 9EAF02001A7 for ; Sun, 23 Sep 2018 11:40:39 +0200 (CEST) Received: by mail-wr1-x42c.google.com with SMTP id t15so8858174wrx.1 for ; Sun, 23 Sep 2018 02:40:39 -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; bh=YB7hILo+kyCaAmEyX3IRB88rpTOfDl1atb2fEytjSzI=; b=huT5matv/44MBKeKDQ8I4X/4ugOJinFHOnNid0amPWofkTcfJUUoRJjE474jKXSfXe pU9k6T1LZD9yrBDpQFMFYINzEDhcz8RagwwFH/iah6N2Zod9NKmUhOc8C+zKeSJToFIo CDC2gG36IGWafeM3N+huonf0re/sShRX+3WqA2bbCnfyFm29xBqwC6ggn29niY4BgBq1 VmwVRjFEAtG8hQ+V/390sBJxBo4wFK41sbHqs71VmM/IRiwLepoz/BrKK3kfZmt3Wgzz m6ecaDURH5Ms4VEErBKFmJFd5WhI+BY/h4wczIIvLxbafsH/l0WeI3ndpXsdo3iCIKgt 0oRA== 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; bh=YB7hILo+kyCaAmEyX3IRB88rpTOfDl1atb2fEytjSzI=; b=mdBU+SqK0MHmWle2cfSPUptLzfLB6OsOq2xlGRh0Kq92bDSV3OYLNITXc48IVt/o9N uKqk/AGFX+o2zD5kDziYtcr20RQIo0qeeLbocVPECIBI/pb9Ysl+NM07xOEDf/j26uug 4buxJcwvMIQVuLzYSvl3KGQ2L4coxyij+/hN93eUQx1K8cQinPyHp1sfnIt9iyXbSP1U TOG38Eb1WKZCpBtjRPU9ROjKdidgFPOltSrcTpKILwzTfgVsghzor7pjGM9NbuFPthKN YUXJvp+1FsgObUco9XjQNNmWn4RqkQrw8EvPz3sU+14eC/qpWT0hl9zIJIvUe+5mFrXI tupg== X-Gm-Message-State: ABuFfoiPseaGLZylzP4Bl3OZCJjzPez975yaQrHOQnzRKKwJKYYCpI+e DSr3rza3D3+l9Ou5ICEmLz4= X-Google-Smtp-Source: ACcGV60Yr//RgUlRwIFtfx7sXMrUd1N/yYoeBOjGXinhSvr0FiIX5YxoNb4sO5ARNNziHA4y4le0Rg== X-Received: by 2002:adf:b243:: with SMTP id y3-v6mr4450851wra.90.1537695639126; Sun, 23 Sep 2018 02:40:39 -0700 (PDT) Received: from localhost.localdomain ([141.226.14.107]) by smtp.gmail.com with ESMTPSA id c8sm13739468wrx.92.2018.09.23.02.40.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 23 Sep 2018 02:40:38 -0700 (PDT) From: Amir Goldstein To: Jan Kara Date: Sun, 23 Sep 2018 12:40:32 +0300 Message-Id: <20180923094032.32078-1-amir73il@gmail.com> X-Mailer: git-send-email 2.17.1 X-Virus-Scanned: clamav-milter 0.99.2 at in-7.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, SPF_PASS autolearn=disabled version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-7.smtp.seeweb.it Cc: ltp@lists.linux.it Subject: [LTP] [PATCH v2][RFC] syscalls/fanotify03: simplify test 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" Re-init fanotify fd on every test iteration instead of storing and restoring fd_notify from duplicated fd_notify_backup. Signed-off-by: Amir Goldstein --- Jan, Do you see any problem with this "simplification"? Does this test need to have the fanotify fd preserved between test iterations? I would rather make this change instead of adding the missing cleanup for fd_notify_backup, because it sits better with my plans to re-structure this test [1]. Thanks, Amir. [1] https://github.com/amir73il/ltp/commits/fanotify_sb .../kernel/syscalls/fanotify/fanotify03.c | 52 +++++++++---------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/testcases/kernel/syscalls/fanotify/fanotify03.c b/testcases/kernel/syscalls/fanotify/fanotify03.c index 83cd26640..59dedbe21 100644 --- a/testcases/kernel/syscalls/fanotify/fanotify03.c +++ b/testcases/kernel/syscalls/fanotify/fanotify03.c @@ -138,15 +138,33 @@ static void check_child(void) tst_res(TFAIL, "child %s", tst_strstatus(child_ret)); } -void test01(void) +static void setup_mark(void) { - int tst_count, fd_notify_backup = -1; + fd_notify = SAFE_FANOTIFY_INIT(FAN_CLASS_CONTENT, O_RDONLY); + + if (fanotify_mark(fd_notify, FAN_MARK_ADD, + FAN_ACCESS_PERM | FAN_OPEN_PERM, + AT_FDCWD, fname) < 0) { + if (errno == EINVAL) { + tst_brk(TCONF | TERRNO, + "CONFIG_FANOTIFY_ACCESS_PERMISSIONS not " + "configured in kernel?"); + } else { + tst_brk(TBROK | TERRNO, + "fanotify_mark (%d, FAN_MARK_ADD, " + "FAN_ACCESS_PERM | FAN_OPEN_PERM, " + "AT_FDCWD, %s) failed.", + fd_notify, fname); + } + } +} +void test01(void) +{ + int tst_count; int ret, len = 0, i = 0, test_num = 0; - if (fd_notify_backup == -1) { - fd_notify_backup = SAFE_DUP(fd_notify); - } + setup_mark(); run_child(); tst_count = 0; @@ -229,33 +247,15 @@ void test01(void) } check_child(); - /* We got SIGCHLD while running, resetup fd_notify */ - if (fd_notify == -1) { - fd_notify = fd_notify_backup; - fd_notify_backup = -1; - } + + if (fd_notify > 0) + SAFE_CLOSE(fd_notify); } static void setup(void) { sprintf(fname, "fname_%d", getpid()); SAFE_FILE_PRINTF(fname, "1"); - - fd_notify = SAFE_FANOTIFY_INIT(FAN_CLASS_CONTENT, O_RDONLY); - - if (fanotify_mark(fd_notify, FAN_MARK_ADD, FAN_ACCESS_PERM | - FAN_OPEN_PERM, AT_FDCWD, fname) < 0) { - if (errno == EINVAL) { - tst_brk(TCONF | TERRNO, - "CONFIG_FANOTIFY_ACCESS_PERMISSIONS not " - "configured in kernel?"); - } else { - tst_brk(TBROK | TERRNO, - "fanotify_mark (%d, FAN_MARK_ADD, FAN_ACCESS_PERM | " - "FAN_OPEN_PERM, AT_FDCWD, %s) failed.", fd_notify, fname); - } - } - } static void cleanup(void)