From patchwork Fri Jul 16 10:22:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xie Ziyao X-Patchwork-Id: 1506113 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 4GR6kk5QJKz9shx for ; Fri, 16 Jul 2021 20:22:54 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 2540B3C65A8 for ; Fri, 16 Jul 2021 12:22:52 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-5.smtp.seeweb.it (in-5.smtp.seeweb.it [IPv6:2001:4b78:1:20::5]) (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 C75B63C7269 for ; Fri, 16 Jul 2021 12:22:19 +0200 (CEST) Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by in-5.smtp.seeweb.it (Postfix) with ESMTPS id 23FA66011E4 for ; Fri, 16 Jul 2021 12:22:14 +0200 (CEST) Received: from dggemv704-chm.china.huawei.com (unknown [172.30.72.57]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4GR6bK6Xnvz1CKT8 for ; Fri, 16 Jul 2021 18:16:29 +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; Fri, 16 Jul 2021 18:22:10 +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; Fri, 16 Jul 2021 18:22:09 +0800 From: Xie Ziyao To: Date: Fri, 16 Jul 2021 18:22:53 +0800 Message-ID: <20210716102257.20882-2-xieziyao@huawei.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210716102257.20882-1-xieziyao@huawei.com> References: <20210628080424.245911-3-xieziyao@huawei.com> <20210716102257.20882-1-xieziyao@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.67.174.209] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpemm500022.china.huawei.com (7.185.36.162) X-CFilter-Loop: Reflected X-Virus-Scanned: clamav-milter 0.102.4 at in-5.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-5.smtp.seeweb.it Subject: [LTP] [PATCH 1/5 v2] lapi/syscalls: Add syscall number for epoll_pwait2 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 syscall number for epoll_pwait2. Suggested-by: Cyril Hrubis Signed-off-by: Xie Ziyao --- include/lapi/syscalls/aarch64.in | 1 + include/lapi/syscalls/arc.in | 1 + include/lapi/syscalls/arm.in | 1 + include/lapi/syscalls/hppa.in | 3 ++- include/lapi/syscalls/i386.in | 1 + include/lapi/syscalls/ia64.in | 1 + include/lapi/syscalls/powerpc.in | 1 + include/lapi/syscalls/powerpc64.in | 1 + include/lapi/syscalls/s390.in | 1 + include/lapi/syscalls/s390x.in | 1 + include/lapi/syscalls/sh.in | 1 + include/lapi/syscalls/sparc.in | 1 + include/lapi/syscalls/sparc64.in | 1 + include/lapi/syscalls/x86_64.in | 1 + 14 files changed, 15 insertions(+), 1 deletion(-) -- 2.17.1 diff --git a/include/lapi/syscalls/aarch64.in b/include/lapi/syscalls/aarch64.in index 2def6ba3d..5a2816099 100644 --- a/include/lapi/syscalls/aarch64.in +++ b/include/lapi/syscalls/aarch64.in @@ -313,4 +313,5 @@ clone3 435 close_range 436 openat2 437 pidfd_getfd 438 +epoll_pwait2 441 _sysctl 1078 diff --git a/include/lapi/syscalls/arc.in b/include/lapi/syscalls/arc.in index 9bcd84706..9c1654b0b 100644 --- a/include/lapi/syscalls/arc.in +++ b/include/lapi/syscalls/arc.in @@ -313,3 +313,4 @@ clone3 435 close_range 436 openat2 437 pidfd_getfd 438 +epoll_pwait2 441 diff --git a/include/lapi/syscalls/arm.in b/include/lapi/syscalls/arm.in index 98c840cb8..ded2f5e03 100644 --- a/include/lapi/syscalls/arm.in +++ b/include/lapi/syscalls/arm.in @@ -391,3 +391,4 @@ clone3 (__NR_SYSCALL_BASE+435) close_range (__NR_SYSCALL_BASE+436) openat2 (__NR_SYSCALL_BASE+437) pidfd_getfd (__NR_SYSCALL_BASE+438) +epoll_pwait2 (__NR_SYSCALL_BASE+441) diff --git a/include/lapi/syscalls/hppa.in b/include/lapi/syscalls/hppa.in index e1628c4b1..d8f142b6a 100644 --- a/include/lapi/syscalls/hppa.in +++ b/include/lapi/syscalls/hppa.in @@ -39,4 +39,5 @@ fsconfig 431 fsmount 432 fspick 433 pidfd_open 434 -close_range 436 \ No newline at end of file +close_range 436 +epoll_pwait2 441 diff --git a/include/lapi/syscalls/i386.in b/include/lapi/syscalls/i386.in index aaa02c7bf..f69268e10 100644 --- a/include/lapi/syscalls/i386.in +++ b/include/lapi/syscalls/i386.in @@ -427,3 +427,4 @@ clone3 435 close_range 436 openat2 437 pidfd_getfd 438 +epoll_pwait2 441 diff --git a/include/lapi/syscalls/ia64.in b/include/lapi/syscalls/ia64.in index 5467f80f2..3ba2406c4 100644 --- a/include/lapi/syscalls/ia64.in +++ b/include/lapi/syscalls/ia64.in @@ -340,3 +340,4 @@ pidfd_open 1458 close_range 1460 openat2 1461 pidfd_getfd 1462 +epoll_pwait2 1465 diff --git a/include/lapi/syscalls/powerpc.in b/include/lapi/syscalls/powerpc.in index 2d287a606..a4ed2169c 100644 --- a/include/lapi/syscalls/powerpc.in +++ b/include/lapi/syscalls/powerpc.in @@ -420,3 +420,4 @@ clone3 435 close_range 436 openat2 437 pidfd_getfd 438 +epoll_pwait2 441 diff --git a/include/lapi/syscalls/powerpc64.in b/include/lapi/syscalls/powerpc64.in index 2d287a606..a4ed2169c 100644 --- a/include/lapi/syscalls/powerpc64.in +++ b/include/lapi/syscalls/powerpc64.in @@ -420,3 +420,4 @@ clone3 435 close_range 436 openat2 437 pidfd_getfd 438 +epoll_pwait2 441 diff --git a/include/lapi/syscalls/s390.in b/include/lapi/syscalls/s390.in index c978b6660..d99e5fd9e 100644 --- a/include/lapi/syscalls/s390.in +++ b/include/lapi/syscalls/s390.in @@ -407,3 +407,4 @@ clone3 435 close_range 436 openat2 437 pidfd_getfd 438 +epoll_pwait2 441 diff --git a/include/lapi/syscalls/s390x.in b/include/lapi/syscalls/s390x.in index d123db6cb..f26cdaaae 100644 --- a/include/lapi/syscalls/s390x.in +++ b/include/lapi/syscalls/s390x.in @@ -355,3 +355,4 @@ clone3 435 close_range 436 openat2 437 pidfd_getfd 438 +epoll_pwait2 441 diff --git a/include/lapi/syscalls/sh.in b/include/lapi/syscalls/sh.in index 22da7d6ff..20ee61ccc 100644 --- a/include/lapi/syscalls/sh.in +++ b/include/lapi/syscalls/sh.in @@ -401,3 +401,4 @@ pidfd_open 434 close_range 436 openat2 437 pidfd_getfd 438 +epoll_pwait2 441 diff --git a/include/lapi/syscalls/sparc.in b/include/lapi/syscalls/sparc.in index 7324b4ac6..86decdd82 100644 --- a/include/lapi/syscalls/sparc.in +++ b/include/lapi/syscalls/sparc.in @@ -406,3 +406,4 @@ pidfd_open 434 close_range 436 openat2 437 pidfd_getfd 438 +epoll_pwait2 441 diff --git a/include/lapi/syscalls/sparc64.in b/include/lapi/syscalls/sparc64.in index 862d806fa..02dfe473a 100644 --- a/include/lapi/syscalls/sparc64.in +++ b/include/lapi/syscalls/sparc64.in @@ -371,3 +371,4 @@ pidfd_open 434 close_range 436 openat2 437 pidfd_getfd 438 +epoll_pwait2 441 diff --git a/include/lapi/syscalls/x86_64.in b/include/lapi/syscalls/x86_64.in index 1345002f5..cf6d78bf6 100644 --- a/include/lapi/syscalls/x86_64.in +++ b/include/lapi/syscalls/x86_64.in @@ -348,6 +348,7 @@ clone3 435 close_range 436 openat2 437 pidfd_getfd 438 +epoll_pwait2 441 rt_sigaction 512 rt_sigreturn 513 ioctl 514 From patchwork Fri Jul 16 10:22:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xie Ziyao X-Patchwork-Id: 1506114 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 4GR6kw6NZmz9shx for ; Fri, 16 Jul 2021 20:23:04 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 4D9E93C73A3 for ; Fri, 16 Jul 2021 12:23:02 +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 A68DC3C861D for ; Fri, 16 Jul 2021 12:22:24 +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 6F581201148 for ; Fri, 16 Jul 2021 12:22:16 +0200 (CEST) Received: from dggemv704-chm.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4GR6f33MtZzZmbX for ; Fri, 16 Jul 2021 18:18:51 +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; Fri, 16 Jul 2021 18:22:10 +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; Fri, 16 Jul 2021 18:22:10 +0800 From: Xie Ziyao To: Date: Fri, 16 Jul 2021 18:22:54 +0800 Message-ID: <20210716102257.20882-3-xieziyao@huawei.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210716102257.20882-1-xieziyao@huawei.com> References: <20210628080424.245911-3-xieziyao@huawei.com> <20210716102257.20882-1-xieziyao@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.67.174.209] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) 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/5 v2] lapi: Add the prototype for epoll_pwait and epoll_pwait2 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 the prototype for epoll_pwait and epoll_pwait2 into include/lapi/epoll.h. Suggested-by: Cyril Hrubis Signed-off-by: Xie Ziyao --- v1->v2: 1. Add the prototype for epoll_pwait and epoll_pwait2 into include/lapi/epoll.h. configure.ac | 1 + include/lapi/epoll.h | 37 ++++++++++++++++++++++++++++++++++--- 2 files changed, 35 insertions(+), 3 deletions(-) -- 2.17.1 diff --git a/configure.ac b/configure.ac index 25c421de0..5bf3c52ec 100644 --- a/configure.ac +++ b/configure.ac @@ -86,6 +86,7 @@ AC_CHECK_FUNCS_ONCE([ \ close_range \ copy_file_range \ epoll_pwait \ + epoll_pwait2 \ execveat \ fallocate \ fchownat \ diff --git a/include/lapi/epoll.h b/include/lapi/epoll.h index 899eeb9d4..57f4b9d0f 100644 --- a/include/lapi/epoll.h +++ b/include/lapi/epoll.h @@ -1,13 +1,44 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -/* +/* SPDX-License-Identifier: GPL-2.0-or-later + * * Copyright (c) 2016 Cyril Hrubis + * Copyright (c) 2021 Xie Ziyao */ #ifndef LAPI_EPOLL_H__ #define LAPI_EPOLL_H__ +#include "lapi/syscalls.h" +#include "tst_timer_test.h" + #ifndef EPOLL_CLOEXEC -# define EPOLL_CLOEXEC 02000000 +#define EPOLL_CLOEXEC 02000000 +#endif + +#ifndef HAVE_EPOLL_PWAIT +int epoll_pwait(int epfd, struct epoll_event *events, int maxevents, + int timeout, const sigset_t *sigmask) +{ + return tst_syscall(__NR_epoll_pwait, epfd, events, maxevents, + timeout, sigmask, _NSIG / 8); +} +#endif + +#ifndef HAVE_EPOLL_PWAIT2 +int epoll_pwait2(int epfd, struct epoll_event *events, int maxevents, + const struct timespec *timeout, const sigset_t *sigmask) +{ + if (timeout == NULL) + return tst_syscall(__NR_epoll_pwait2, epfd, events, maxevents, + NULL, sigmask, _NSIG / 8); + + struct __kernel_timespec ts; + + ts.tv_sec = timeout->tv_sec; + ts.tv_nsec = timeout->tv_nsec; + + return tst_syscall(__NR_epoll_pwait2, epfd, events, maxevents, + &ts, sigmask, _NSIG / 8); +} #endif #endif /* LAPI_EPOLL_H__ */ From patchwork Fri Jul 16 10:22:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xie Ziyao X-Patchwork-Id: 1506111 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 4GR6kJ3zbtz9shx for ; Fri, 16 Jul 2021 20:22:32 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 9B35C3C861D for ; Fri, 16 Jul 2021 12:22:29 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-3.smtp.seeweb.it (in-3.smtp.seeweb.it [217.194.8.3]) (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 B47C93C65B8 for ; Fri, 16 Jul 2021 12:22:16 +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-3.smtp.seeweb.it (Postfix) with ESMTPS id A4A931A016F8 for ; Fri, 16 Jul 2021 12:22:14 +0200 (CEST) Received: from dggemv703-chm.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4GR6bK6t7RzYd16 for ; Fri, 16 Jul 2021 18:16:29 +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; Fri, 16 Jul 2021 18:22:10 +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; Fri, 16 Jul 2021 18:22:10 +0800 From: Xie Ziyao To: Date: Fri, 16 Jul 2021 18:22:55 +0800 Message-ID: <20210716102257.20882-4-xieziyao@huawei.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210716102257.20882-1-xieziyao@huawei.com> References: <20210628080424.245911-3-xieziyao@huawei.com> <20210716102257.20882-1-xieziyao@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.67.174.209] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpemm500022.china.huawei.com (7.185.36.162) X-CFilter-Loop: Reflected X-Virus-Scanned: clamav-milter 0.102.4 at in-3.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-3.smtp.seeweb.it Subject: [LTP] [PATCH 3/5 v2] epoll_pwait: Add test variants for epoll_pwait 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 test variants to switch between different syscall variants/wrappers at runtime. Suggested-by: Cyril Hrubis Signed-off-by: Xie Ziyao --- v1->v2: 1. Add test variants to switch between epoll_pwait and epoll_pwait2. .../syscalls/epoll_pwait/epoll_pwait_var.h | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 testcases/kernel/syscalls/epoll_pwait/epoll_pwait_var.h -- 2.17.1 diff --git a/testcases/kernel/syscalls/epoll_pwait/epoll_pwait_var.h b/testcases/kernel/syscalls/epoll_pwait/epoll_pwait_var.h new file mode 100644 index 000000000..2bdea17e9 --- /dev/null +++ b/testcases/kernel/syscalls/epoll_pwait/epoll_pwait_var.h @@ -0,0 +1,43 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later + * + * Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved. + * Author: Xie Ziyao + */ + +#ifndef LTP_EPOLL_PWAIT_VAR_H +#define LTP_EPOLL_PWAIT_VAR_H + +#include "lapi/epoll.h" + +#define TEST_VARIANTS 2 +#define MSEC_PER_SEC (1000L) +#define NSEC_PER_MSEC (1000000L) + +static int do_epoll_pwait(int epfd, struct epoll_event *events, int + maxevents, int timeout, const sigset_t *sigmask) +{ + if (tst_variant == 0) + return epoll_pwait(epfd, events, maxevents, timeout, sigmask); + + struct timespec ts; + + if (timeout < 0) { + return epoll_pwait2(epfd, events, maxevents, NULL, sigmask); + } else { + ts.tv_sec = timeout / MSEC_PER_SEC; + ts.tv_nsec = NSEC_PER_MSEC * (timeout % MSEC_PER_SEC); + } + + return epoll_pwait2(epfd, events, maxevents, &ts, sigmask); + +} + +static void epoll_pwait_info(void) +{ + if (tst_variant == 0) + tst_res(TINFO, "Test epoll_pwait()"); + else + tst_res(TINFO, "Test epoll_pwait2()"); +} + +#endif //LTP_EPOLL_PWAIT_VAR_H From patchwork Fri Jul 16 10:22:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xie Ziyao X-Patchwork-Id: 1506110 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 4GR6k62kMjz9shx for ; Fri, 16 Jul 2021 20:22:22 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 27D783C71EC for ; Fri, 16 Jul 2021 12:22:20 +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 [217.194.8.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 9F3EF3C4CF2 for ; Fri, 16 Jul 2021 12:22:16 +0200 (CEST) Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) (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 3D1A21401443 for ; Fri, 16 Jul 2021 12:22:15 +0200 (CEST) Received: from dggemv703-chm.china.huawei.com (unknown [172.30.72.53]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4GR6cg5Q9Dz7tcR for ; Fri, 16 Jul 2021 18:17:39 +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; Fri, 16 Jul 2021 18:22:10 +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; Fri, 16 Jul 2021 18:22:10 +0800 From: Xie Ziyao To: Date: Fri, 16 Jul 2021 18:22:56 +0800 Message-ID: <20210716102257.20882-5-xieziyao@huawei.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210716102257.20882-1-xieziyao@huawei.com> References: <20210628080424.245911-3-xieziyao@huawei.com> <20210716102257.20882-1-xieziyao@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.67.174.209] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) 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/5 v2] epoll_pwait: Add test for epoll_pwait02 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" Basic test for epoll_pwait/epoll_pwait2. Suggested-by: Cyril Hrubis Signed-off-by: Xie Ziyao --- 1. Add test variants to switch between epoll_pwait and epoll_pwait2. runtest/syscalls | 1 + .../kernel/syscalls/epoll_pwait/.gitignore | 3 +- .../syscalls/epoll_pwait/epoll_pwait02.c | 65 +++++++++++++++++++ 3 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 testcases/kernel/syscalls/epoll_pwait/epoll_pwait02.c -- 2.17.1 diff --git a/runtest/syscalls b/runtest/syscalls index 26786c96a..bed224809 100644 --- a/runtest/syscalls +++ b/runtest/syscalls @@ -166,6 +166,7 @@ epoll_wait01 epoll_wait01 epoll_wait02 epoll_wait02 epoll_wait03 epoll_wait03 epoll_pwait01 epoll_pwait01 +epoll_pwait02 epoll_pwait02 eventfd01 eventfd01 diff --git a/testcases/kernel/syscalls/epoll_pwait/.gitignore b/testcases/kernel/syscalls/epoll_pwait/.gitignore index d53943a75..ab049f173 100644 --- a/testcases/kernel/syscalls/epoll_pwait/.gitignore +++ b/testcases/kernel/syscalls/epoll_pwait/.gitignore @@ -1 +1,2 @@ -/epoll_pwait01 +epoll_pwait01 +epoll_pwait02 diff --git a/testcases/kernel/syscalls/epoll_pwait/epoll_pwait02.c b/testcases/kernel/syscalls/epoll_pwait/epoll_pwait02.c new file mode 100644 index 000000000..b2733fa41 --- /dev/null +++ b/testcases/kernel/syscalls/epoll_pwait/epoll_pwait02.c @@ -0,0 +1,65 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights reserved. + * Author: Xie Ziyao + */ + +/*\ + * [Description] + * + * Basic test for epoll_pwait and epoll_pwait2. + */ + +#include + +#include "tst_test.h" +#include "epoll_pwait_var.h" + +static int efd, sfd[2]; +static struct epoll_event e; + +static void run(void) +{ + TEST(do_epoll_pwait(efd, &e, 1, -1, NULL)); + + if (TST_RET == 1) { + tst_res(TPASS, "do_epoll_pwait() succeeded"); + return; + } + tst_res(TFAIL, "do_epoll_pwait() returned %li, expected 1", TST_RET); +} + +static void setup(void) +{ + epoll_pwait_info(); + + SAFE_SOCKETPAIR(AF_UNIX, SOCK_STREAM, 0, sfd); + + efd = epoll_create(1); + if (efd == -1) + tst_brk(TBROK | TERRNO, "epoll_create()"); + + e.events = EPOLLIN; + if (epoll_ctl(efd, EPOLL_CTL_ADD, sfd[0], &e)) + tst_brk(TBROK | TERRNO, "epoll_clt(..., EPOLL_CTL_ADD, ...)"); + SAFE_WRITE(1, sfd[1], "w", 1); +} + +static void cleanup(void) +{ + if (efd > 0) + SAFE_CLOSE(efd); + + if (sfd[0] > 0) + SAFE_CLOSE(sfd[0]); + + if (sfd[1] > 0) + SAFE_CLOSE(sfd[1]); +} + +static struct tst_test test = { + .test_all = run, + .setup = setup, + .cleanup = cleanup, + .test_variants = TEST_VARIANTS, +}; From patchwork Fri Jul 16 10:22:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xie Ziyao X-Patchwork-Id: 1506112 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 4GR6kT2hWRz9sj1 for ; Fri, 16 Jul 2021 20:22:41 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 1CD073C735A for ; Fri, 16 Jul 2021 12:22:39 +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 A9B3F3C65A8 for ; Fri, 16 Jul 2021 12:22:16 +0200 (CEST) Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) (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 389F41001381 for ; Fri, 16 Jul 2021 12:22:15 +0200 (CEST) Received: from dggemv711-chm.china.huawei.com (unknown [172.30.72.57]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4GR6cg6PkRz7tf0 for ; Fri, 16 Jul 2021 18:17:39 +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; Fri, 16 Jul 2021 18:22:10 +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; Fri, 16 Jul 2021 18:22:10 +0800 From: Xie Ziyao To: Date: Fri, 16 Jul 2021 18:22:57 +0800 Message-ID: <20210716102257.20882-6-xieziyao@huawei.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210716102257.20882-1-xieziyao@huawei.com> References: <20210628080424.245911-3-xieziyao@huawei.com> <20210716102257.20882-1-xieziyao@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.67.174.209] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) 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/5 v2] epoll_pwait: Add test for epoll_pwait03 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_pwait/epoll_pwait2 timeout correctly. Suggested-by: Cyril Hrubis Signed-off-by: Xie Ziyao --- v1->v2: 1. Add test variants to switch between epoll_pwait and epoll_pwait2. runtest/syscalls | 1 + .../kernel/syscalls/epoll_pwait/.gitignore | 1 + .../syscalls/epoll_pwait/epoll_pwait03.c | 74 +++++++++++++++++++ 3 files changed, 76 insertions(+) create mode 100644 testcases/kernel/syscalls/epoll_pwait/epoll_pwait03.c -- 2.17.1 diff --git a/runtest/syscalls b/runtest/syscalls index bed224809..1deb6118f 100644 --- a/runtest/syscalls +++ b/runtest/syscalls @@ -167,6 +167,7 @@ epoll_wait02 epoll_wait02 epoll_wait03 epoll_wait03 epoll_pwait01 epoll_pwait01 epoll_pwait02 epoll_pwait02 +epoll_pwait03 epoll_pwait03 eventfd01 eventfd01 diff --git a/testcases/kernel/syscalls/epoll_pwait/.gitignore b/testcases/kernel/syscalls/epoll_pwait/.gitignore index ab049f173..1d16367e6 100644 --- a/testcases/kernel/syscalls/epoll_pwait/.gitignore +++ b/testcases/kernel/syscalls/epoll_pwait/.gitignore @@ -1,2 +1,3 @@ epoll_pwait01 epoll_pwait02 +epoll_pwait03 diff --git a/testcases/kernel/syscalls/epoll_pwait/epoll_pwait03.c b/testcases/kernel/syscalls/epoll_pwait/epoll_pwait03.c new file mode 100644 index 000000000..ec3b9579d --- /dev/null +++ b/testcases/kernel/syscalls/epoll_pwait/epoll_pwait03.c @@ -0,0 +1,74 @@ +// 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_pwait and epoll_pwait2 timeout correctly. + */ + +#include + +#include "tst_timer_test.h" +#include "epoll_pwait_var.h" + +#define USEC_PER_MSEC (1000L) + +static int efd, sfd[2]; +static struct epoll_event e; + +int sample_fn(int clk_id, long long usec) +{ + unsigned int ms = usec / USEC_PER_MSEC; + + tst_timer_start(clk_id); + TEST(do_epoll_pwait(efd, &e, 1, ms, NULL)); + tst_timer_stop(); + tst_timer_sample(); + + if (TST_RET != 0) { + tst_res(TFAIL | TTERRNO, + "do_epoll_pwait() returned %li, expected 0", TST_RET); + return 1; + } + + return 0; +} + +static void setup(void) +{ + epoll_pwait_info(); + + SAFE_SOCKETPAIR(AF_UNIX, SOCK_STREAM, 0, sfd); + + efd = epoll_create(1); + if (efd == -1) + tst_brk(TBROK | TERRNO, "epoll_create()"); + + e.events = EPOLLIN; + if (epoll_ctl(efd, EPOLL_CTL_ADD, sfd[0], &e)) + tst_brk(TBROK | TERRNO, "epoll_clt(..., EPOLL_CTL_ADD, ...)"); +} + +static void cleanup(void) +{ + if (efd > 0) + SAFE_CLOSE(efd); + + if (sfd[0] > 0) + SAFE_CLOSE(sfd[0]); + + if (sfd[1] > 0) + SAFE_CLOSE(sfd[1]); +} + +static struct tst_test test = { + .scall = "do_epoll_pwait()", + .sample = sample_fn, + .setup = setup, + .cleanup = cleanup, + .test_variants = TEST_VARIANTS, +};