From nobody Sat Dec 28 04:04:23 2024 Received: from mail.codeweavers.com (mail.codeweavers.com [4.36.192.163]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 06DEF199FDC; Mon, 9 Dec 2024 18:59:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=4.36.192.163 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733770779; cv=none; b=m8x2IzjfVbEZyVq68GncyfrojIv6RcFiDl/dI9pIKYIaHcpAD/seaa0azjmdR/lOh/ARm7B0pWgtmoKk+NBwMo++WNIos+4iJAwqSVEzMTKXjk0LLQjwcq/eGuZos5Ih/ySY0fS1MpkT8s2RzgPW2wpfKDuJov8F76ae7DPye7I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733770779; c=relaxed/simple; bh=4Ab/sQIbAd81VaBoQcLVwxOsdxge96BedL56C5osvQg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AgQ1VdTsgZVzCZM0e3UirS1ZcAs/F9mkoYi6Xomq88rFcLwlrFpWhNkIhO/p3bU6cXPMR3axHUZnX6396B+IebdpEWQEdpLtrPdGL4+PDy/HTSJRMIuGwm+1MSAA4mNlxi0x1vqrJR4yMrqClAxRGPCg+mp3Ie3laseBnbyKOQA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=codeweavers.com; spf=pass smtp.mailfrom=codeweavers.com; dkim=pass (2048-bit key) header.d=codeweavers.com header.i=@codeweavers.com header.b=QweM9zmT; arc=none smtp.client-ip=4.36.192.163 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=codeweavers.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=codeweavers.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=codeweavers.com header.i=@codeweavers.com header.b="QweM9zmT" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=codeweavers.com; s=s1; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=Eeq3Ehv4lJUwOdLSmPyFK5uFI6EH6FzbCtzv+EtsojA=; b=QweM9zmTwz6LxC5w2j11j62DY4 OtmStgufVHHiBncnxgkivzKNyLml8b0ImnaFp02Ol34827E7T79IzgeC0kUgi9GxymtjO9n2kEhGx BL8YYMobu5Ta+0P56Ytegz7W8Faf2dSIRW2+1lFvnNiFYwYOjoyJTsWsbZBlyISKjxUsTj8l+QUF5 eGehAGVBsRF/dAwaJd2WSPjVlXnDV4M/P+IZzDt1B+EFdEez8EcAFXOTkOVPmSnnczXn+ZXrVt0cc +NnFLPwkCLEjn4boGXG94lf4BUCVf4W2LV/DDek8XwKrao2eQFql3GTaqmm01RhNtg232yX+n/+A4 5NCDjjMw==; Received: from cw137ip160.mn.codeweavers.com ([10.69.137.160] helo=camazotz.mn.codeweavers.com) by mail.codeweavers.com with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tKiyk-001Gd5-16; Mon, 09 Dec 2024 12:59:34 -0600 From: Elizabeth Figura To: Arnd Bergmann , Greg Kroah-Hartman , Jonathan Corbet , Shuah Khan Cc: linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, wine-devel@winehq.org, =?UTF-8?q?Andr=C3=A9=20Almeida?= , Wolfram Sang , Arkadiusz Hiler , Peter Zijlstra , Andy Lutomirski , linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, Randy Dunlap , Ingo Molnar , Will Deacon , Waiman Long , Boqun Feng , Elizabeth Figura Subject: [PATCH v6 21/28] selftests: ntsync: Add some tests for auto-reset event state. Date: Mon, 9 Dec 2024 12:58:57 -0600 Message-ID: <20241209185904.507350-22-zfigura@codeweavers.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241209185904.507350-1-zfigura@codeweavers.com> References: <20241209185904.507350-1-zfigura@codeweavers.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Test event-specific ioctls NTSYNC_IOC_EVENT_SET, NTSYNC_IOC_EVENT_RESET, NTSYNC_IOC_EVENT_PULSE, NTSYNC_IOC_EVENT_READ for auto-reset events, and waiting on auto-reset events. Signed-off-by: Elizabeth Figura --- .../testing/selftests/drivers/ntsync/ntsync.c | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/tools/testing/selftests/drivers/ntsync/ntsync.c b/tools/testin= g/selftests/drivers/ntsync/ntsync.c index b6481c2b85cc..12ccb4ec28e4 100644 --- a/tools/testing/selftests/drivers/ntsync/ntsync.c +++ b/tools/testing/selftests/drivers/ntsync/ntsync.c @@ -442,6 +442,65 @@ TEST(manual_event_state) close(fd); } =20 +TEST(auto_event_state) +{ + struct ntsync_event_args event_args; + __u32 index, signaled; + int fd, event, ret; + + fd =3D open("/dev/ntsync", O_CLOEXEC | O_RDONLY); + ASSERT_LE(0, fd); + + event_args.manual =3D 0; + event_args.signaled =3D 1; + event_args.event =3D 0xdeadbeef; + ret =3D ioctl(fd, NTSYNC_IOC_CREATE_EVENT, &event_args); + EXPECT_EQ(0, ret); + EXPECT_NE(0xdeadbeef, event_args.event); + event =3D event_args.event; + + check_event_state(event, 1, 0); + + signaled =3D 0xdeadbeef; + ret =3D ioctl(event, NTSYNC_IOC_EVENT_SET, &signaled); + EXPECT_EQ(0, ret); + EXPECT_EQ(1, signaled); + check_event_state(event, 1, 0); + + ret =3D wait_any(fd, 1, &event, 123, &index); + EXPECT_EQ(0, ret); + EXPECT_EQ(0, index); + check_event_state(event, 0, 0); + + signaled =3D 0xdeadbeef; + ret =3D ioctl(event, NTSYNC_IOC_EVENT_RESET, &signaled); + EXPECT_EQ(0, ret); + EXPECT_EQ(0, signaled); + check_event_state(event, 0, 0); + + ret =3D wait_any(fd, 1, &event, 123, &index); + EXPECT_EQ(-1, ret); + EXPECT_EQ(ETIMEDOUT, errno); + + ret =3D ioctl(event, NTSYNC_IOC_EVENT_SET, &signaled); + EXPECT_EQ(0, ret); + EXPECT_EQ(0, signaled); + + ret =3D ioctl(event, NTSYNC_IOC_EVENT_PULSE, &signaled); + EXPECT_EQ(0, ret); + EXPECT_EQ(1, signaled); + check_event_state(event, 0, 0); + + ret =3D ioctl(event, NTSYNC_IOC_EVENT_PULSE, &signaled); + EXPECT_EQ(0, ret); + EXPECT_EQ(0, signaled); + check_event_state(event, 0, 0); + + close(event); + + close(fd); +} + TEST(test_wait_any) { int objs[NTSYNC_MAX_WAIT_COUNT + 1], fd, ret; --=20 2.45.2