From patchwork Fri Mar 25 07:33:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhao Gongyi X-Patchwork-Id: 1609304 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) 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=) Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KPv4C5kzTz9s5V for ; Fri, 25 Mar 2022 18:34:35 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 10BA53C72C1 for ; Fri, 25 Mar 2022 08:34:33 +0100 (CET) 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]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id 366E73C067B for ; Fri, 25 Mar 2022 08:34:27 +0100 (CET) Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by in-7.smtp.seeweb.it (Postfix) with ESMTPS id 6A66D2005D8 for ; Fri, 25 Mar 2022 08:34:23 +0100 (CET) Received: from canpemm500005.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4KPv3c2CcpzcbwW for ; Fri, 25 Mar 2022 15:34:04 +0800 (CST) Received: from ubuntu1804.huawei.com (10.67.174.63) by canpemm500005.china.huawei.com (7.192.104.229) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21; Fri, 25 Mar 2022 15:34:15 +0800 To: Date: Fri, 25 Mar 2022 15:33:33 +0800 Message-ID: <20220325073333.255193-1-zhaogongyi@huawei.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-Originating-IP: [10.67.174.63] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To canpemm500005.china.huawei.com (7.192.104.229) X-CFilter-Loop: Reflected X-Virus-Scanned: clamav-milter 0.102.4 at in-7.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=-0.0 required=7.0 tests=SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-7.smtp.seeweb.it Subject: [LTP] [PATCH] unlinkat01: Add SAFE_CLOSE before test return X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Zhao Gongyi via ltp From: Zhao Gongyi Reply-To: Zhao Gongyi Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" If we run the test with the option -i 10000, and the ulimit of open files little than 10000, the test would fail and report error of EMFILE. Signed-off-by: Zhao Gongyi --- testcases/kernel/syscalls/unlinkat/unlinkat01.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) -- 2.17.1 diff --git a/testcases/kernel/syscalls/unlinkat/unlinkat01.c b/testcases/kernel/syscalls/unlinkat/unlinkat01.c index 9e9a5d7db..4f5a6da1e 100644 --- a/testcases/kernel/syscalls/unlinkat/unlinkat01.c +++ b/testcases/kernel/syscalls/unlinkat/unlinkat01.c @@ -52,13 +52,14 @@ static struct tcase { static void run(unsigned int i) { + int fd_testfile3 = -1; /* tesfile2 will be unlinked by test0. */ if (access(testfile2, F_OK)) SAFE_FILE_PRINTF(testfile2, testfile2); /* testfile3 will be unlined by test1. */ if (access(testfile3, F_OK)) - SAFE_OPEN(testfile3, O_CREAT | O_RDWR, 0600); + fd_testfile3 = SAFE_OPEN(testfile3, O_CREAT | O_RDWR, 0600); /* subpathdir will be unlinked by test6. */ if (access(subpathdir, F_OK)) @@ -80,6 +81,8 @@ static void run(unsigned int i) if (!tc[i].fd) SAFE_CLOSE(fd); + if (fd_testfile3 > 0) + SAFE_CLOSE(fd_testfile3); } static void setup(void)