From patchwork Tue Aug 17 06:49:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xie Ziyao X-Patchwork-Id: 1517586 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 ozlabs.org (Postfix) with ESMTPS id 4GphVG4Mn6z9sSn for ; Tue, 17 Aug 2021 16:49:58 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 673663C570A for ; Tue, 17 Aug 2021 08:49:56 +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]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id 3DC773C5722 for ; Tue, 17 Aug 2021 08:48:58 +0200 (CEST) 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 0C89620074F for ; Tue, 17 Aug 2021 08:48:55 +0200 (CEST) Received: from dggemv703-chm.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4GphST18g5zYqBN for ; Tue, 17 Aug 2021 14:48:25 +0800 (CST) Received: from dggpemm500022.china.huawei.com (7.185.36.162) by dggemv703-chm.china.huawei.com (10.3.19.46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Tue, 17 Aug 2021 14:48:33 +0800 Received: from ubuntu1804.huawei.com (10.67.174.209) by dggpemm500022.china.huawei.com (7.185.36.162) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Tue, 17 Aug 2021 14:48:33 +0800 From: Xie Ziyao To: Date: Tue, 17 Aug 2021 14:49:18 +0800 Message-ID: <20210817064924.127970-2-xieziyao@huawei.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210817064924.127970-1-xieziyao@huawei.com> References: <20210817064924.127970-1-xieziyao@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.67.174.209] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpemm500022.china.huawei.com (7.185.36.162) 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 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 1/7] epoll_ctl: Add docparse formatting and cleanup for epoll_ctl01 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: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Add docparse formatting and fix warnings from checkpatch.pl for epoll_ctl01. Signed-off-by: Xie Ziyao --- .../kernel/syscalls/epoll_ctl/epoll_ctl01.c | 28 +++++++++---------- 1 file changed, 13 insertions(+), 15 deletions(-) -- 2.17.1 diff --git a/testcases/kernel/syscalls/epoll_ctl/epoll_ctl01.c b/testcases/kernel/syscalls/epoll_ctl/epoll_ctl01.c index e199ac6ac..099a0f8dd 100644 --- a/testcases/kernel/syscalls/epoll_ctl/epoll_ctl01.c +++ b/testcases/kernel/syscalls/epoll_ctl/epoll_ctl01.c @@ -4,25 +4,22 @@ * Author: Xiao Yang */ -/* - * Test Name: epoll_ctl01.c +/*\ + * [Description] * - * Description: - * Testcase to check the basic functionality of the epoll_ctl(2). - * 1) when epoll_ctl(2) succeeds to register fd on the epoll instance and - * associates event with fd, epoll_wait(2) will get registered fd and - * event correctly. - * 2) when epoll_ctl(2) succeeds to chage event which is related to fd, - * epoll_wait(2) will get chaged event correctly. - * 3) when epoll_ctl(2) succeeds to deregister fd from the epoll instance - * epoll_wait(2) won't get deregistered fd and event. + * Check the basic functionality of the epoll_ctl: * + * - When epoll_ctl succeeds to register fd on the epoll instance and associates + * event with fd, epoll_wait will get registered fd and event correctly. + * - When epoll_ctl succeeds to change event which is related to fd, epoll_wait + * will get changed event correctly. + * - When epoll_ctl succeeds to deregister fd from the epoll instance epoll_wait + * won't get deregistered fd and event. */ -#include #include -#include -#include +#include + #include "tst_test.h" static int epfd; @@ -88,9 +85,10 @@ static void check_epoll_ctl(int opt, int exp_num) while (events) { int events_matched = 0; - memset(res_evs, 0, sizeof(res_evs)); + memset(res_evs, 0, sizeof(res_evs)); res = epoll_wait(epfd, res_evs, 2, -1); + if (res <= 0) { tst_res(TFAIL | TERRNO, "epoll_wait() returned %i", res); From patchwork Tue Aug 17 06:49:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xie Ziyao X-Patchwork-Id: 1517580 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=2001:1418:10:5::2; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (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 ozlabs.org (Postfix) with ESMTPS id 4GphT35wTyz9sRN for ; Tue, 17 Aug 2021 16:48:55 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 48ADC3C57BC for ; Tue, 17 Aug 2021 08:48:53 +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]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id 0C3DB3C56B2 for ; Tue, 17 Aug 2021 08:48:40 +0200 (CEST) Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) (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 AC11D20076E for ; Tue, 17 Aug 2021 08:48:39 +0200 (CEST) Received: from dggemv711-chm.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4GphN23qy4z88Mh for ; Tue, 17 Aug 2021 14:44:34 +0800 (CST) Received: from dggpemm500022.china.huawei.com (7.185.36.162) by dggemv711-chm.china.huawei.com (10.1.198.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Tue, 17 Aug 2021 14:48:33 +0800 Received: from ubuntu1804.huawei.com (10.67.174.209) by dggpemm500022.china.huawei.com (7.185.36.162) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Tue, 17 Aug 2021 14:48:33 +0800 From: Xie Ziyao To: Date: Tue, 17 Aug 2021 14:49:19 +0800 Message-ID: <20210817064924.127970-3-xieziyao@huawei.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210817064924.127970-1-xieziyao@huawei.com> References: <20210817064924.127970-1-xieziyao@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.67.174.209] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpemm500022.china.huawei.com (7.185.36.162) 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 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 2/7] epoll_ctl: Add docparse formatting and cleanup for epoll_ctl02 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: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" 1. Add docparse formatting. 2. Make use of TST_EXP_FAIL(...). 3. Add test for events=NULL. Signed-off-by: Xie Ziyao --- .../kernel/syscalls/epoll_ctl/epoll_ctl02.c | 87 +++++++------------ 1 file changed, 32 insertions(+), 55 deletions(-) -- 2.17.1 diff --git a/testcases/kernel/syscalls/epoll_ctl/epoll_ctl02.c b/testcases/kernel/syscalls/epoll_ctl/epoll_ctl02.c index 280fd6724..f477625a6 100644 --- a/testcases/kernel/syscalls/epoll_ctl/epoll_ctl02.c +++ b/testcases/kernel/syscalls/epoll_ctl/epoll_ctl02.c @@ -4,34 +4,23 @@ * Author: Xiao Yang */ -/* - * Test Name: epoll_ctl02.c - * - * Description: - * 1) epoll_ctl(2) fails if epfd is a invalid file descriptor. - * 2) epoll_ctl(2) fails if fd is a invalid file descriptor. - * 3) epoll_ctl(2) fails if op is not supported by this interface. - * 4) epoll_ctl(2) fails if fd is the same as epfd. - * 5) epoll_ctl(2) fails with EPOLL_CTL_DEL if fd is not registered - * with this epoll instance. - * 6) epoll_ctl(2) fails with EPOLL_CTL_MOD if fd is not registered - * with this epoll instance. - * 7) epoll_ctl(2) fails with EPOLL_CTL_ADD if fd is already registered - * with this epoll instance. - * - * Expected Result: - * 1) epoll_ctl(2) should return -1 and set errno to EBADF. - * 2) epoll_ctl(2) should return -1 and set errno to EBADF. - * 3) epoll_ctl(2) should return -1 and set errno to EINVAL. - * 4) epoll_ctl(2) should return -1 and set errno to EINVAL. - * 5) epoll_ctl(2) should return -1 and set errno to ENOENT. - * 6) epoll_ctl(2) should return -1 and set errno to ENOENT. - * 7) epoll_ctl(2) should return -1 and set errno to EEXIST. +/*\ + * [Description] * + * Verify that, + * - epoll_ctl fails with EBADF if epfd is an invalid fd. + * - epoll_ctl fails with EBADF if fd is an invalid fd. + * - epoll_ctl fails with EINVAL if op is not supported. + * - epoll_ctl fails with EINVAL if fd is the same as epfd. + * - epoll_ctl fails with EINVAL if events is NULL. + * - epoll_ctl fails with ENOENT if fd is not registered with EPOLL_CTL_DEL. + * - epoll_ctl fails with ENOENT if fd is not registered with EPOLL_CTL_MOD. + * - epoll_ctl fails with EEXIST if fd is already registered with EPOLL_CTL_ADD. */ -#include + #include -#include +#include + #include "tst_test.h" static int epfd; @@ -44,19 +33,21 @@ static struct epoll_event events[2] = { }; static struct testcase { - int *epfds; + int *epfd; int opt; - int *fds; - struct epoll_event *ts_event; + int *fd; + struct epoll_event *event; int exp_err; -} tcases[] = { - {&inv, EPOLL_CTL_ADD, &fd[1], &events[1], EBADF}, - {&epfd, EPOLL_CTL_ADD, &inv, &events[1], EBADF}, - {&epfd, -1, &fd[1], &events[1], EINVAL}, - {&epfd, EPOLL_CTL_ADD, &epfd, &events[1], EINVAL}, - {&epfd, EPOLL_CTL_DEL, &fd[1], &events[1], ENOENT}, - {&epfd, EPOLL_CTL_MOD, &fd[1], &events[1], ENOENT}, - {&epfd, EPOLL_CTL_ADD, &fd[0], &events[0], EEXIST} + const char *desc; +} tc[] = { + {&inv, EPOLL_CTL_ADD, &fd[1], &events[1], EBADF, "epfd is an invalid fd"}, + {&epfd, EPOLL_CTL_ADD, &inv, &events[1], EBADF, "fd is an invalid fd"}, + {&epfd, -1, &fd[1], &events[1], EINVAL, "op is not supported"}, + {&epfd, EPOLL_CTL_ADD, &epfd, &events[1], EINVAL, "fd is the same as epfd"}, + {&epfd, EPOLL_CTL_ADD, &fd[1], NULL, EFAULT, "events is NULL"}, + {&epfd, EPOLL_CTL_DEL, &fd[1], &events[1], ENOENT, "fd is not registered with EPOLL_CTL_DEL"}, + {&epfd, EPOLL_CTL_MOD, &fd[1], &events[1], ENOENT, "fd is not registered with EPOLL_CTL_MOD"}, + {&epfd, EPOLL_CTL_ADD, &fd[0], &events[0], EEXIST, "fd is already registered with EPOLL_CTL_ADD"} }; static void setup(void) @@ -70,9 +61,8 @@ static void setup(void) events[0].data.fd = fd[0]; events[1].data.fd = fd[1]; - TEST(epoll_ctl(epfd, EPOLL_CTL_ADD, fd[0], &events[0])); - if (TST_RET == -1) - tst_brk(TFAIL | TTERRNO, "epoll_ctl() fails to init"); + if (epoll_ctl(epfd, EPOLL_CTL_ADD, fd[0], &events[0])) + tst_brk(TBROK | TERRNO, "epoll_clt(..., EPOLL_CTL_ADD, ...)"); } static void cleanup(void) @@ -89,25 +79,12 @@ static void cleanup(void) static void verify_epoll_ctl(unsigned int n) { - struct testcase *tc = &tcases[n]; - - TEST(epoll_ctl(*tc->epfds, tc->opt, *tc->fds, tc->ts_event)); - if (TST_RET != -1) { - tst_res(TFAIL, "epoll_ctl() succeeds unexpectedly"); - return; - } - - if (tc->exp_err == TST_ERR) { - tst_res(TPASS | TTERRNO, "epoll_ctl() fails as expected"); - } else { - tst_res(TFAIL | TTERRNO, - "epoll_ctl() fails unexpectedly, expected %i: %s", - tc->exp_err, tst_strerrno(tc->exp_err)); - } + TST_EXP_FAIL(epoll_ctl(*tc[n].epfd, tc[n].opt, *tc[n].fd, tc[n].event), + tc[n].exp_err, "epoll_clt(...) if %s", tc[n].desc); } static struct tst_test test = { - .tcnt = ARRAY_SIZE(tcases), + .tcnt = ARRAY_SIZE(tc), .setup = setup, .cleanup = cleanup, .test = verify_epoll_ctl, From patchwork Tue Aug 17 06:49:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xie Ziyao X-Patchwork-Id: 1517581 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=2001:1418:10:5::2; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (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 ozlabs.org (Postfix) with ESMTPS id 4GphTH3Npbz9sRN for ; Tue, 17 Aug 2021 16:49:07 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id AB4CA3C577F for ; Tue, 17 Aug 2021 08:49:04 +0200 (CEST) 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]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id 085B43C207C for ; Tue, 17 Aug 2021 08:48:40 +0200 (CEST) Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by in-4.smtp.seeweb.it (Postfix) with ESMTPS id D09131000965 for ; Tue, 17 Aug 2021 08:48:38 +0200 (CEST) Received: from dggemv704-chm.china.huawei.com (unknown [172.30.72.53]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4GphNL2TB3zdbFL for ; Tue, 17 Aug 2021 14:44:50 +0800 (CST) Received: from dggpemm500022.china.huawei.com (7.185.36.162) by dggemv704-chm.china.huawei.com (10.3.19.47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Tue, 17 Aug 2021 14:48:34 +0800 Received: from ubuntu1804.huawei.com (10.67.174.209) by dggpemm500022.china.huawei.com (7.185.36.162) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Tue, 17 Aug 2021 14:48:33 +0800 From: Xie Ziyao To: Date: Tue, 17 Aug 2021 14:49:20 +0800 Message-ID: <20210817064924.127970-4-xieziyao@huawei.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210817064924.127970-1-xieziyao@huawei.com> References: <20210817064924.127970-1-xieziyao@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.67.174.209] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpemm500022.china.huawei.com (7.185.36.162) X-CFilter-Loop: Reflected X-Virus-Scanned: clamav-milter 0.102.4 at in-4.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.0 required=7.0 tests=SPF_HELO_NONE,SPF_PASS autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-4.smtp.seeweb.it Subject: [LTP] [PATCH 3/7] epoll_ctl: Add test for epoll_ctl03 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: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Check that epoll_ctl returns zero with different combinations of events on success. Signed-off-by: Xie Ziyao --- runtest/syscalls | 1 + .../kernel/syscalls/epoll_ctl/.gitignore | 5 +- .../kernel/syscalls/epoll_ctl/epoll_ctl03.c | 75 +++++++++++++++++++ 3 files changed, 79 insertions(+), 2 deletions(-) create mode 100644 testcases/kernel/syscalls/epoll_ctl/epoll_ctl03.c -- 2.17.1 diff --git a/runtest/syscalls b/runtest/syscalls index 7d308dcec..b28d19ac7 100644 --- a/runtest/syscalls +++ b/runtest/syscalls @@ -160,6 +160,7 @@ epoll_create1_01 epoll_create1_01 epoll01 epoll-ltp epoll_ctl01 epoll_ctl01 epoll_ctl02 epoll_ctl02 +epoll_ctl03 epoll_ctl03 epoll_wait01 epoll_wait01 epoll_wait02 epoll_wait02 epoll_wait03 epoll_wait03 diff --git a/testcases/kernel/syscalls/epoll_ctl/.gitignore b/testcases/kernel/syscalls/epoll_ctl/.gitignore index 634470a06..2b50d924c 100644 --- a/testcases/kernel/syscalls/epoll_ctl/.gitignore +++ b/testcases/kernel/syscalls/epoll_ctl/.gitignore @@ -1,2 +1,3 @@ -/epoll_ctl01 -/epoll_ctl02 +epoll_ctl01 +epoll_ctl02 +epoll_ctl03 diff --git a/testcases/kernel/syscalls/epoll_ctl/epoll_ctl03.c b/testcases/kernel/syscalls/epoll_ctl/epoll_ctl03.c new file mode 100644 index 000000000..f80bef93e --- /dev/null +++ b/testcases/kernel/syscalls/epoll_ctl/epoll_ctl03.c @@ -0,0 +1,75 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved. + * Author: Xie Ziyao + */ + +/*\ + * [Description] + * + * Check that epoll_ctl returns zero with different combinations of events on + * success. + */ + +#include +#include + +#include "tst_test.h" + +#define WIDTH_EPOLL_EVENTS 256 + +static int epfd, fds[2]; +static struct epoll_event events = {.events = EPOLLIN}; + +static void run_all(void) +{ + unsigned int index, events_bitmap; + + for (index = 0; index < WIDTH_EPOLL_EVENTS; index++) { + events_bitmap = ((EPOLLIN * ((index & 0x01) >> 0)) | + (EPOLLOUT * ((index & 0x02) >> 1)) | + (EPOLLPRI * ((index & 0x04) >> 2)) | + (EPOLLERR * ((index & 0x08) >> 3)) | + (EPOLLHUP * ((index & 0x10) >> 4)) | + (EPOLLET * ((index & 0x20) >> 5)) | + (EPOLLONESHOT * ((index & 0x40) >> 6)) | + (EPOLLRDHUP * ((index & 0x80) >> 7))); + + events.events = events_bitmap; + TST_EXP_PASS(epoll_ctl(epfd, EPOLL_CTL_MOD, fds[0], &events), + "epoll_ctl(..., EPOLL_CTL_MOD, ...) with events.events=%x", + events.events); + } +} + +static void setup(void) +{ + epfd = epoll_create(1); + if (epfd == -1) + tst_brk(TBROK | TERRNO, "fail to create epoll instance"); + + SAFE_PIPE(fds); + events.data.fd = fds[0]; + + if (epoll_ctl(epfd, EPOLL_CTL_ADD, fds[0], &events)) + tst_brk(TBROK | TERRNO, "epoll_clt(..., EPOLL_CTL_ADD, ...)"); +} + +static void cleanup(void) +{ + if (epfd) + SAFE_CLOSE(epfd); + + if (fds[0]) + SAFE_CLOSE(fds[0]); + + if (fds[1]) + SAFE_CLOSE(fds[1]); +} + +static struct tst_test test = { + .setup = setup, + .cleanup = cleanup, + .test_all = run_all, + .min_kver = "2.6.17", +}; From patchwork Tue Aug 17 06:49:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xie Ziyao X-Patchwork-Id: 1517579 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=2001:1418:10:5::2; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GphT21V0vz9sRN for ; Tue, 17 Aug 2021 16:48:51 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 0FD343C5711 for ; Tue, 17 Aug 2021 08:48:43 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-6.smtp.seeweb.it (in-6.smtp.seeweb.it [IPv6:2001:4b78:1:20::6]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id A6A593C207C for ; Tue, 17 Aug 2021 08:48:40 +0200 (CEST) Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by in-6.smtp.seeweb.it (Postfix) with ESMTPS id C1CCD1400E17 for ; Tue, 17 Aug 2021 08:48:38 +0200 (CEST) Received: from dggemv704-chm.china.huawei.com (unknown [172.30.72.53]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4GphNL3FL4zdbk9 for ; Tue, 17 Aug 2021 14:44:50 +0800 (CST) Received: from dggpemm500022.china.huawei.com (7.185.36.162) by dggemv704-chm.china.huawei.com (10.3.19.47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Tue, 17 Aug 2021 14:48:34 +0800 Received: from ubuntu1804.huawei.com (10.67.174.209) by dggpemm500022.china.huawei.com (7.185.36.162) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Tue, 17 Aug 2021 14:48:34 +0800 From: Xie Ziyao To: Date: Tue, 17 Aug 2021 14:49:21 +0800 Message-ID: <20210817064924.127970-5-xieziyao@huawei.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210817064924.127970-1-xieziyao@huawei.com> References: <20210817064924.127970-1-xieziyao@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.67.174.209] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpemm500022.china.huawei.com (7.185.36.162) X-CFilter-Loop: Reflected X-Virus-Scanned: clamav-milter 0.102.4 at in-6.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.0 required=7.0 tests=SPF_HELO_NONE,SPF_PASS autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-6.smtp.seeweb.it Subject: [LTP] [PATCH 4/7] epoll_create1: Add docparse formatting and cleanup for epoll_create1_01 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: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" 1. Add docparse formatting. 2. Make use of ARRAY_SIZE(). Signed-off-by: Xie Ziyao --- .../syscalls/epoll_create1/epoll_create1_01.c | 53 +++++++++---------- .../syscalls/epoll_create1/epoll_create1_02.c | 0 2 files changed, 25 insertions(+), 28 deletions(-) create mode 100644 testcases/kernel/syscalls/epoll_create1/epoll_create1_02.c -- 2.17.1 diff --git a/testcases/kernel/syscalls/epoll_create1/epoll_create1_01.c b/testcases/kernel/syscalls/epoll_create1/epoll_create1_01.c index 41aa634e1..39e01eb8b 100644 --- a/testcases/kernel/syscalls/epoll_create1/epoll_create1_01.c +++ b/testcases/kernel/syscalls/epoll_create1/epoll_create1_01.c @@ -2,51 +2,48 @@ /* * Copyright (c) Ulrich Drepper * Copyright (c) International Business Machines Corp., 2009 + */ + +/*\ + * [Description] * - * Test system call introduced in 2.6.27. - * http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=a0998b50c3f0b8fdd265c63e0032f86ebe377dbf - * - * This patch adds the new epoll_create1 syscall. It extends the old - * epoll_create syscall by one parameter which is meant to hold a flag value. - * In this patch the only flag support is EPOLL_CLOEXEC which causes the - * close-on-exec flag for the returned file descriptor to be set. A new name - * EPOLL_CLOEXEC is introduced which in this implementation must have the same - * value as O_CLOEXEC. + * Verify that epoll_create1 sets the close-on-exec flag for the returned + * file descriptor with the only flag support, EPOLL_CLOEXEC. */ -#include + #include + #include "tst_test.h" #include "lapi/epoll.h" #include "lapi/syscalls.h" -static void verify_epoll_create1(void) +static struct test_case_t { + int flags; + int exp_flag; + const char *desc; +} tc[] = { + {0, 0, "flags=0 didn't set close-on-exec flag"}, + {EPOLL_CLOEXEC, 1, "flags=EPOLL_CLOEXEC set close-on-exec"} +}; + +static void run(unsigned int n) { int fd, coe; - fd = tst_syscall(__NR_epoll_create1, 0); + fd = tst_syscall(__NR_epoll_create1, tc[n].flags); if (fd == -1) - tst_brk(TFAIL | TERRNO, "epoll_create1(0) failed"); + tst_brk(TFAIL | TERRNO, "epoll_create1(...) failed"); coe = SAFE_FCNTL(fd, F_GETFD); - if (coe & FD_CLOEXEC) - tst_brk(TFAIL, "flags=0 set close-on-exec flag"); + if ((coe & FD_CLOEXEC) != tc[n].exp_flag) + tst_brk(TFAIL, "epoll_create1(...) with %s", tc[n].desc); + tst_res(TPASS, "epoll_create1(...) with %s", tc[n].desc); SAFE_CLOSE(fd); - - fd = tst_syscall(__NR_epoll_create1, EPOLL_CLOEXEC); - if (fd == -1) - tst_brk(TFAIL | TERRNO, "epoll_create1(EPOLL_CLOEXEC) failed"); - - coe = SAFE_FCNTL(fd, F_GETFD); - if ((coe & FD_CLOEXEC) == 0) - tst_brk(TFAIL, "flags=EPOLL_CLOEXEC didn't set close-on-exec"); - - SAFE_CLOSE(fd); - - tst_res(TPASS, "epoll_create1(EPOLL_CLOEXEC) PASSED"); } static struct tst_test test = { .min_kver = "2.6.27", - .test_all = verify_epoll_create1, + .tcnt = ARRAY_SIZE(tc), + .test = run, }; diff --git a/testcases/kernel/syscalls/epoll_create1/epoll_create1_02.c b/testcases/kernel/syscalls/epoll_create1/epoll_create1_02.c new file mode 100644 index 000000000..e69de29bb From patchwork Tue Aug 17 06:49:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xie Ziyao X-Patchwork-Id: 1517584 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) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GphTv0MqLz9sRN for ; Tue, 17 Aug 2021 16:49:38 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 5C9043C5725 for ; Tue, 17 Aug 2021 08:49:35 +0200 (CEST) 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 [217.194.8.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id 67BDA3C5774 for ; Tue, 17 Aug 2021 08:48:53 +0200 (CEST) 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-4.smtp.seeweb.it (Postfix) with ESMTPS id 0EA2D10006D5 for ; Tue, 17 Aug 2021 08:48:51 +0200 (CEST) Received: from dggemv703-chm.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4GphST3xrGzYqVb for ; Tue, 17 Aug 2021 14:48:25 +0800 (CST) Received: from dggpemm500022.china.huawei.com (7.185.36.162) by dggemv703-chm.china.huawei.com (10.3.19.46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Tue, 17 Aug 2021 14:48:34 +0800 Received: from ubuntu1804.huawei.com (10.67.174.209) by dggpemm500022.china.huawei.com (7.185.36.162) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Tue, 17 Aug 2021 14:48:34 +0800 From: Xie Ziyao To: Date: Tue, 17 Aug 2021 14:49:22 +0800 Message-ID: <20210817064924.127970-6-xieziyao@huawei.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210817064924.127970-1-xieziyao@huawei.com> References: <20210817064924.127970-1-xieziyao@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.67.174.209] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpemm500022.china.huawei.com (7.185.36.162) X-CFilter-Loop: Reflected X-Virus-Scanned: clamav-milter 0.102.4 at in-4.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.0 required=7.0 tests=SPF_HELO_NONE,SPF_PASS autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-4.smtp.seeweb.it Subject: [LTP] [PATCH 5/7] epoll_create1: Add test for epoll_create1_02 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: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Verify that epoll_create1 returns -1 and set errno to EINVAL with an invalid value specified in flags. Signed-off-by: Xie Ziyao --- runtest/syscalls | 1 + .../kernel/syscalls/epoll_create1/.gitignore | 3 +- .../syscalls/epoll_create1/epoll_create1_02.c | 38 +++++++++++++++++++ 3 files changed, 41 insertions(+), 1 deletion(-) -- 2.17.1 diff --git a/runtest/syscalls b/runtest/syscalls index b28d19ac7..f6fe140b2 100644 --- a/runtest/syscalls +++ b/runtest/syscalls @@ -157,6 +157,7 @@ dup3_01 dup3_01 dup3_02 dup3_02 epoll_create1_01 epoll_create1_01 +epoll_create1_02 epoll_create1_02 epoll01 epoll-ltp epoll_ctl01 epoll_ctl01 epoll_ctl02 epoll_ctl02 diff --git a/testcases/kernel/syscalls/epoll_create1/.gitignore b/testcases/kernel/syscalls/epoll_create1/.gitignore index 7de2e4231..3e0482de9 100644 --- a/testcases/kernel/syscalls/epoll_create1/.gitignore +++ b/testcases/kernel/syscalls/epoll_create1/.gitignore @@ -1 +1,2 @@ -/epoll_create1_01 +epoll_create1_01 +epoll_create1_02 diff --git a/testcases/kernel/syscalls/epoll_create1/epoll_create1_02.c b/testcases/kernel/syscalls/epoll_create1/epoll_create1_02.c index e69de29bb..2308a65d6 100644 --- a/testcases/kernel/syscalls/epoll_create1/epoll_create1_02.c +++ b/testcases/kernel/syscalls/epoll_create1/epoll_create1_02.c @@ -0,0 +1,38 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved. + * Author: Xie Ziyao + */ + +/*\ + * [Description] + * + * Verify that epoll_create1 returns -1 and set errno to EINVAL with an invalid + * value specified in flags. + */ + +#include + +#include "tst_test.h" +#include "lapi/epoll.h" +#include "lapi/syscalls.h" + +static struct test_case_t { + int flags; + int exp_err; + const char *desc; +} tc[] = { + {-1, EINVAL, "-1"}, + {EPOLL_CLOEXEC + 1, EINVAL, "EPOLL_CLOEXEC+1"} +}; + +static void run(unsigned int n) +{ + TST_EXP_FAIL(tst_syscall(__NR_epoll_create1, tc[n].flags), + tc[n].exp_err, "create(%s)", tc[n].desc); +} + +static struct tst_test test = { + .tcnt = ARRAY_SIZE(tc), + .test = run, +}; From patchwork Tue Aug 17 06:49:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xie Ziyao X-Patchwork-Id: 1517585 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 ozlabs.org (Postfix) with ESMTPS id 4GphV3188Vz9sRN for ; Tue, 17 Aug 2021 16:49:47 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 17C9A3C5799 for ; Tue, 17 Aug 2021 08:49:45 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-6.smtp.seeweb.it (in-6.smtp.seeweb.it [IPv6:2001:4b78:1:20::6]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id 8069D3C56D6 for ; Tue, 17 Aug 2021 08:48:53 +0200 (CEST) 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-6.smtp.seeweb.it (Postfix) with ESMTPS id 05DF5140052D for ; Tue, 17 Aug 2021 08:48:51 +0200 (CEST) Received: from dggemv703-chm.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4GphST4HhmzYqVf for ; Tue, 17 Aug 2021 14:48:25 +0800 (CST) Received: from dggpemm500022.china.huawei.com (7.185.36.162) by dggemv703-chm.china.huawei.com (10.3.19.46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Tue, 17 Aug 2021 14:48:34 +0800 Received: from ubuntu1804.huawei.com (10.67.174.209) by dggpemm500022.china.huawei.com (7.185.36.162) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Tue, 17 Aug 2021 14:48:34 +0800 From: Xie Ziyao To: Date: Tue, 17 Aug 2021 14:49:23 +0800 Message-ID: <20210817064924.127970-7-xieziyao@huawei.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210817064924.127970-1-xieziyao@huawei.com> References: <20210817064924.127970-1-xieziyao@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.67.174.209] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpemm500022.china.huawei.com (7.185.36.162) X-CFilter-Loop: Reflected X-Virus-Scanned: clamav-milter 0.102.4 at in-6.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.0 required=7.0 tests=SPF_HELO_NONE,SPF_PASS autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-6.smtp.seeweb.it Subject: [LTP] [PATCH 6/7] epoll_create: Add test for epoll_create01 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: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Verify that epoll_create return a nonnegative file descriptor on success. Signed-off-by: Xie Ziyao --- runtest/syscalls | 1 + .../kernel/syscalls/epoll_create/.gitignore | 1 + .../kernel/syscalls/epoll_create/Makefile | 9 +++++ .../syscalls/epoll_create/epoll_create01.c | 40 +++++++++++++++++++ 4 files changed, 51 insertions(+) create mode 100644 testcases/kernel/syscalls/epoll_create/.gitignore create mode 100644 testcases/kernel/syscalls/epoll_create/Makefile create mode 100644 testcases/kernel/syscalls/epoll_create/epoll_create01.c -- 2.17.1 diff --git a/runtest/syscalls b/runtest/syscalls index f6fe140b2..2540905a0 100644 --- a/runtest/syscalls +++ b/runtest/syscalls @@ -156,6 +156,7 @@ dup205 dup205 dup3_01 dup3_01 dup3_02 dup3_02 +epoll_create01 epoll_create01 epoll_create1_01 epoll_create1_01 epoll_create1_02 epoll_create1_02 epoll01 epoll-ltp diff --git a/testcases/kernel/syscalls/epoll_create/.gitignore b/testcases/kernel/syscalls/epoll_create/.gitignore new file mode 100644 index 000000000..0ed4d940a --- /dev/null +++ b/testcases/kernel/syscalls/epoll_create/.gitignore @@ -0,0 +1 @@ +epoll_create01 diff --git a/testcases/kernel/syscalls/epoll_create/Makefile b/testcases/kernel/syscalls/epoll_create/Makefile new file mode 100644 index 000000000..0e0d8c56f --- /dev/null +++ b/testcases/kernel/syscalls/epoll_create/Makefile @@ -0,0 +1,9 @@ +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved. +# Author: Xie Ziyao + +top_srcdir ?= ../../../.. + +include $(top_srcdir)/include/mk/testcases.mk + +include $(top_srcdir)/include/mk/generic_leaf_target.mk diff --git a/testcases/kernel/syscalls/epoll_create/epoll_create01.c b/testcases/kernel/syscalls/epoll_create/epoll_create01.c new file mode 100644 index 000000000..53cb1dfe1 --- /dev/null +++ b/testcases/kernel/syscalls/epoll_create/epoll_create01.c @@ -0,0 +1,40 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved. + * Author: Xie Ziyao + */ + +/*\ + * [Description] + * + * Verify that epoll_create return a nonnegative file descriptor on success. + * + * The size argument informed the kernel of the number of file descriptors + * that the caller expected to add to the epoll instance, but it is no longer + * required. + */ + +#include + +#include "tst_test.h" +#include "lapi/epoll.h" +#include "lapi/syscalls.h" + +static int tc[] = {1, INT_MAX}; + +static void run(unsigned int n) +{ + int fd; + + fd = tst_syscall(__NR_epoll_create, tc[n]); + if (fd < 0) + tst_brk(TFAIL | TERRNO, "epoll_create(%d) failed", tc[n]); + tst_res(TPASS, "epoll_create(%d)", tc[n]); + + SAFE_CLOSE(fd); +} + +static struct tst_test test = { + .tcnt = ARRAY_SIZE(tc), + .test = run, +}; From patchwork Tue Aug 17 06:49:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xie Ziyao X-Patchwork-Id: 1517582 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=2001:1418:10:5::2; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (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 ozlabs.org (Postfix) with ESMTPS id 4GphTT0ZSGz9sRN for ; Tue, 17 Aug 2021 16:49:17 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 79D543C56E5 for ; Tue, 17 Aug 2021 08:49:14 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-6.smtp.seeweb.it (in-6.smtp.seeweb.it [IPv6:2001:4b78:1:20::6]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id 2F3703C207C for ; Tue, 17 Aug 2021 08:48:40 +0200 (CEST) Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by in-6.smtp.seeweb.it (Postfix) with ESMTPS id 858F71400E19 for ; Tue, 17 Aug 2021 08:48:39 +0200 (CEST) Received: from dggemv711-chm.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4GphN24PLtz88Mr for ; Tue, 17 Aug 2021 14:44:34 +0800 (CST) Received: from dggpemm500022.china.huawei.com (7.185.36.162) by dggemv711-chm.china.huawei.com (10.1.198.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Tue, 17 Aug 2021 14:48:34 +0800 Received: from ubuntu1804.huawei.com (10.67.174.209) by dggpemm500022.china.huawei.com (7.185.36.162) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Tue, 17 Aug 2021 14:48:34 +0800 From: Xie Ziyao To: Date: Tue, 17 Aug 2021 14:49:24 +0800 Message-ID: <20210817064924.127970-8-xieziyao@huawei.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210817064924.127970-1-xieziyao@huawei.com> References: <20210817064924.127970-1-xieziyao@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.67.174.209] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpemm500022.china.huawei.com (7.185.36.162) X-CFilter-Loop: Reflected X-Virus-Scanned: clamav-milter 0.102.4 at in-6.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.0 required=7.0 tests=SPF_HELO_NONE,SPF_PASS autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-6.smtp.seeweb.it Subject: [LTP] [PATCH 7/7] epoll_create: Add test for epoll_create02 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: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Verify that epoll_create returns -1 and set errno to EINVAL if size is not positive. Signed-off-by: Xie Ziyao --- runtest/syscalls | 1 + .../kernel/syscalls/epoll_create/.gitignore | 1 + .../syscalls/epoll_create/epoll_create02.c | 37 +++++++++++++++++++ 3 files changed, 39 insertions(+) create mode 100644 testcases/kernel/syscalls/epoll_create/epoll_create02.c -- 2.17.1 diff --git a/runtest/syscalls b/runtest/syscalls index 2540905a0..d5a1e86e8 100644 --- a/runtest/syscalls +++ b/runtest/syscalls @@ -157,6 +157,7 @@ dup3_01 dup3_01 dup3_02 dup3_02 epoll_create01 epoll_create01 +epoll_create02 epoll_create02 epoll_create1_01 epoll_create1_01 epoll_create1_02 epoll_create1_02 epoll01 epoll-ltp diff --git a/testcases/kernel/syscalls/epoll_create/.gitignore b/testcases/kernel/syscalls/epoll_create/.gitignore index 0ed4d940a..5c16cfa8c 100644 --- a/testcases/kernel/syscalls/epoll_create/.gitignore +++ b/testcases/kernel/syscalls/epoll_create/.gitignore @@ -1 +1,2 @@ epoll_create01 +epoll_create02 diff --git a/testcases/kernel/syscalls/epoll_create/epoll_create02.c b/testcases/kernel/syscalls/epoll_create/epoll_create02.c new file mode 100644 index 000000000..bbc493906 --- /dev/null +++ b/testcases/kernel/syscalls/epoll_create/epoll_create02.c @@ -0,0 +1,37 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved. + * Author: Xie Ziyao + */ + +/*\ + * [Description] + * + * Verify that epoll_create returns -1 and set errno to EINVAL if size is not + * positive. + */ + +#include + +#include "tst_test.h" +#include "lapi/epoll.h" +#include "lapi/syscalls.h" + +static struct test_case_t { + int size; + int exp_err; +} tc[] = { + {0, EINVAL}, + {-1, EINVAL} +}; + +static void run(unsigned int n) +{ + TST_EXP_FAIL(tst_syscall(__NR_epoll_create, tc[n].size), + tc[n].exp_err, "create(%d)", tc[n].size); +} + +static struct tst_test test = { + .tcnt = ARRAY_SIZE(tc), + .test = run, +};