From patchwork Fri Mar 2 15:48:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cyril Hrubis X-Patchwork-Id: 880607 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=213.254.12.146; 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=suse.cz Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3ztDJN6Qdyz9sW3 for ; Sat, 3 Mar 2018 02:49:38 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 6E0933E77C3 for ; Fri, 2 Mar 2018 16:49:36 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-4.smtp.seeweb.it (in-4.smtp.seeweb.it [IPv6:2001:4b78:1:20::4]) by picard.linux.it (Postfix) with ESMTP id 406B33E6269 for ; Fri, 2 Mar 2018 16:49:30 +0100 (CET) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by in-4.smtp.seeweb.it (Postfix) with ESMTPS id D3FBC10018B8 for ; Fri, 2 Mar 2018 16:49:29 +0100 (CET) Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 72A95AD00 for ; Fri, 2 Mar 2018 15:49:29 +0000 (UTC) From: Cyril Hrubis To: ltp@lists.linux.it Date: Fri, 2 Mar 2018 16:48:37 +0100 Message-Id: <20180302154841.4093-3-chrubis@suse.cz> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180302154841.4093-1-chrubis@suse.cz> References: <20180302154841.4093-1-chrubis@suse.cz> X-Virus-Scanned: clamav-milter 0.99.2 at in-4.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.2 required=7.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, SPF_PASS,T_RP_MATCHES_RCVD autolearn=disabled version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-4.smtp.seeweb.it Subject: [LTP] [COMMITTED] [PATCH 3/7] syscalls/inotify03: Fix && cleanup. 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" * We umount the device in the test hence we have to mount it there as well otherwise this will break the -i looping option * Make use of SAFE_MACROS() even in cleanup since we are using newlib * Get rid of TST_TOTAL, use test_cnt instead Signed-off-by: Cyril Hrubis --- testcases/kernel/syscalls/inotify/inotify03.c | 46 +++++++++++++-------------- 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/testcases/kernel/syscalls/inotify/inotify03.c b/testcases/kernel/syscalls/inotify/inotify03.c index 8077976b6..6bc5e7424 100644 --- a/testcases/kernel/syscalls/inotify/inotify03.c +++ b/testcases/kernel/syscalls/inotify/inotify03.c @@ -47,8 +47,6 @@ #if defined(HAVE_SYS_INOTIFY_H) #include -#define TST_TOTAL 3 - #define EVENT_MAX 1024 /* size of the event structure, not counting name */ #define EVENT_SIZE (sizeof(struct inotify_event)) @@ -74,21 +72,25 @@ void verify_inotify(void) int ret; int len, i, test_num; - int tst_count = 0; - - event_set[tst_count] = IN_UNMOUNT; - tst_count++; - event_set[tst_count] = IN_IGNORED; - tst_count++; + int test_cnt = 0; - /*check exit code from inotify_rm_watch */ - tst_count++; + SAFE_MOUNT(tst_device->dev, mntpoint, tst_device->fs_type, 0, NULL); + mount_flag = 1; - if (TST_TOTAL != tst_count) { - tst_brk(TBROK, - "TST_TOTAL and tst_count are not equal"); + wd = myinotify_add_watch(fd_notify, fname, IN_ALL_EVENTS); + if (wd < 0) { + tst_brk(TBROK | TERRNO, + "inotify_add_watch (%d, %s, IN_ALL_EVENTS) failed.", + fd_notify, fname); } - tst_count = 0; + + event_set[test_cnt] = IN_UNMOUNT; + test_cnt++; + event_set[test_cnt] = IN_IGNORED; + test_cnt++; + + /*check exit code from inotify_rm_watch */ + test_cnt++; tst_res(TINFO, "umount %s", tst_device->dev); TEST(tst_umount(mntpoint)); @@ -111,7 +113,7 @@ void verify_inotify(void) while (i < len) { struct inotify_event *event; event = (struct inotify_event *)&event_buf[i]; - if (test_num >= (TST_TOTAL - 1)) { + if (test_num >= (test_cnt - 1)) { tst_res(TFAIL, "get unnecessary event: wd=%d mask=%x " "cookie=%u len=%u", @@ -133,7 +135,7 @@ void verify_inotify(void) test_num++; i += EVENT_SIZE + event->len; } - for (; test_num < TST_TOTAL - 1; test_num++) { + for (; test_num < test_cnt - 1; test_num++) { tst_res(TFAIL, "don't get event: mask=%x ", event_set[test_num]); @@ -170,7 +172,6 @@ static void setup(void) SAFE_CLOSE(fd); fd_notify = myinotify_init(); - if (fd_notify < 0) { if (errno == ENOSYS) tst_brk(TCONF, @@ -180,17 +181,14 @@ static void setup(void) "inotify_init failed"); } - wd = myinotify_add_watch(fd_notify, fname, IN_ALL_EVENTS); - if (wd < 0) - tst_brk(TBROK | TERRNO, - "inotify_add_watch (%d, %s, IN_ALL_EVENTS) failed.", - fd_notify, fname); + tst_umount(mntpoint); + mount_flag = 0; } static void cleanup(void) { - if (fd_notify > 0 && close(fd_notify) == -1) - tst_res(TWARN | TERRNO, "close(%d) failed", fd_notify); + if (fd_notify > 0) + SAFE_CLOSE(fd_notify); if (mount_flag) { TEST(tst_umount(mntpoint));