From patchwork Wed Feb 14 23:53:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elizabeth Figura X-Patchwork-Id: 201204 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:b825:b0:106:860b:bbdd with SMTP id da37csp64456dyb; Wed, 14 Feb 2024 16:02:41 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVm28O0YK/AxWEE4oqSUnCF+xmjGWAc+CS6a4RoxlHs+ZRAI2zWVXYYIrvWwMiWu6EKGAHo2Jr4Q8T2sVAJbqWxwys1Sg== X-Google-Smtp-Source: AGHT+IFxb5m2jytFbaAd3/6pUXEp7Y+U6Jz2SjAZjU83+uGo2GNzT1cStK60940NdCwwPPUPQl2O X-Received: by 2002:a17:902:f68e:b0:1da:1dbc:bf9e with SMTP id l14-20020a170902f68e00b001da1dbcbf9emr246088plg.47.1707955361251; Wed, 14 Feb 2024 16:02:41 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707955361; cv=pass; d=google.com; s=arc-20160816; b=tmcJO5M/mDKb5DUJz1luHdRARq+LcjOdUcxSDuMP9/patC+Lpbu//VWOzzyGwwzoiW oJYlR/LfRllIPmqcwE6fcWjzi8P/Rgye8frSv1sUWKSxhTLfBbiE4bokUeuHGdidce/B OCLBqsrbCm/nqrdjS4GX6JTER4a6aZjamrZD6rlRx2kQmdSZCJEKctmI9IcGv/dAlv+N jlvWjcfb9bwZqmQjUJ72fHQlck2sr97gmwKRXzazOeN1U5EIzMi03sA4cn/O6kN4tfmY rWi8gSDo9ogVkaKsjX8tFORQqkJRkE7fZvL8NDGiFi2DduVQtS/vwTdvC7gr3MCYdtBT 7bTQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=dfzB4q87+P8orUXmAGMZBiDPDRQbWh8zWpHSIv/oNb8=; fh=sOAzP1IXJnllEbSCBRlwdfT0MN3UiaRLwzx1Tpw7GJA=; b=pBFjpyTkQH6YmRDQ+/fgBrri/6AYLQ4Vazy504PNDUzt+Gq6a/vXQTA2CZPqndLayD HX8t1xz/7LmtMfa3XGqRxnskGyoNICfndtF6/VuwJtlncAgKyWB9uq2c8N7UV7uHJb6B v+Vh2z5s9kvfuDcIkHVPbuPLJsU5UjFAi5zOS1iVHk76KFCHYoFUpZGV5XK8kLVEsWWA YenfG+/ut9/YkHhOD7UARvfiE7R724j8PwGi/WOqh5maA/rfRmNVS6DuPZkij+EeQ71r +yzC9fy887BaDClgc1V5vFX8HDLnMkDYZ0Y6PLHYbsTUB1W2rYXfdVcCSaTYGaPNne7b WTaA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@codeweavers.com header.s=s1 header.b="LC/OsRuU"; arc=pass (i=1 spf=pass spfdomain=codeweavers.com dkim=pass dkdomain=codeweavers.com dmarc=pass fromdomain=codeweavers.com); spf=pass (google.com: domain of linux-kernel+bounces-66160-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-66160-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=codeweavers.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id y11-20020a17090322cb00b001da0beabfdasi36160plg.207.2024.02.14.16.02.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 16:02:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-66160-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@codeweavers.com header.s=s1 header.b="LC/OsRuU"; arc=pass (i=1 spf=pass spfdomain=codeweavers.com dkim=pass dkdomain=codeweavers.com dmarc=pass fromdomain=codeweavers.com); spf=pass (google.com: domain of linux-kernel+bounces-66160-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-66160-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=codeweavers.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 2B46928393D for ; Thu, 15 Feb 2024 00:00:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1CC8914E2FE; Wed, 14 Feb 2024 23:53:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=codeweavers.com header.i=@codeweavers.com header.b="LC/OsRuU" 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 C17B314C59C; Wed, 14 Feb 2024 23:53:47 +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=1707954829; cv=none; b=hS3lv0mv1NH4R/SghTwTe4QAmlYevi8miuEJXzd2CAyQ1gAtiFcpuG09/sGKspGeNZ1e9ll2NKoJUs05QdQGUt9ZKabtZRKoeRpEg1f5hlPjji5tYjs3QBdXikDBHP+eiuoYtmnMG96qbayD4HrK+l3UtMoWFwAK6TlIzf+Ffm4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707954829; c=relaxed/simple; bh=UgpG6jjwC+kDfZfnjxxOjeWemeUkGXkpkWpYzrvW9hk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OoE+iM8bm8LkJBfBtbUQbJSRQMN73Rgl4eStyfMzGPuDJebkAED8wcl+A4WGleeT+mhom8ogz9PoWzY//F+65MoOCK0+N5apI6vo6XjQ7JKnlRcdBNt8BO7SpdpBRyJT+6U8h4VvuIjfSRG1ZYUcIbjwgMjVh2WbBOBHhRbToy0= 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=LC/OsRuU; 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 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=codeweavers.com; s=s1; h=Message-ID:Date:Subject:Cc:To:From:Sender; bh=dfzB4q87+P8orUXmAGMZBiDPDRQbWh8zWpHSIv/oNb8=; b=LC/OsRuUYD4zN0e6gcly3uCJGZ jx7cccSnBN3hemhTKjjVvF79XI5kj4HtR1IqzU22z8tt5tEr5r0NYjfLBG2ytFT89nfwWbqYQAOff hsfk/bbn31hd7UIkXmtpreZ15FJw3yCYUTwFgFkd4Bu7JpZ4KeR+3OHXJ4Pmh8qznnEn+fYPXpWuX k0X8RCHCtdCAWNjzEcvrOemKYcpmD8Ecwq7bIsnDKI6fnQmSdUIv8mGzmdAgCUfTy+KiZmJQsZQAE PM+QSeNND3fiGrcalpTHNFHJ79mHgns9ERx0QJQE4I/gzzGVghy/v2L2L7EpVrvW/RB5Gs6589nIz y/AgHVkQ==; 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 1raP4S-00GcSK-1z; Wed, 14 Feb 2024 17:53:44 -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_Almeida?= , Wolfram Sang , Arkadiusz Hiler , Peter Zijlstra , Andy Lutomirski , linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, Elizabeth Figura Subject: [PATCH 25/31] selftests: ntsync: Add some tests for auto-reset event state. Date: Wed, 14 Feb 2024 17:53:00 -0600 Message-ID: <20240214235307.10494-16-zfigura@codeweavers.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240214235307.10494-1-zfigura@codeweavers.com> References: <20240214233645.9273-1-zfigura@codeweavers.com> <20240214235307.10494-1-zfigura@codeweavers.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790921000867803360 X-GMAIL-MSGID: 1790921000867803360 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/testing/selftests/drivers/ntsync/ntsync.c index 7cc6fdf10abd..49ee4be280f6 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); } +TEST(auto_event_state) +{ + struct ntsync_event_args event_args; + __u32 index, signaled; + int fd, event, ret; + + fd = open("/dev/ntsync", O_CLOEXEC | O_RDONLY); + ASSERT_LE(0, fd); + + event_args.manual = 0; + event_args.signaled = 1; + event_args.event = 0xdeadbeef; + ret = ioctl(fd, NTSYNC_IOC_CREATE_EVENT, &event_args); + EXPECT_EQ(0, ret); + EXPECT_NE(0xdeadbeef, event_args.event); + event = event_args.event; + + check_event_state(event, 1, 0); + + signaled = 0xdeadbeef; + ret = ioctl(event, NTSYNC_IOC_EVENT_SET, &signaled); + EXPECT_EQ(0, ret); + EXPECT_EQ(1, signaled); + check_event_state(event, 1, 0); + + ret = wait_any(fd, 1, &event, 123, &index); + EXPECT_EQ(0, ret); + EXPECT_EQ(0, index); + check_event_state(event, 0, 0); + + signaled = 0xdeadbeef; + ret = ioctl(event, NTSYNC_IOC_EVENT_RESET, &signaled); + EXPECT_EQ(0, ret); + EXPECT_EQ(0, signaled); + check_event_state(event, 0, 0); + + ret = wait_any(fd, 1, &event, 123, &index); + EXPECT_EQ(-1, ret); + EXPECT_EQ(ETIMEDOUT, errno); + + ret = ioctl(event, NTSYNC_IOC_EVENT_SET, &signaled); + EXPECT_EQ(0, ret); + EXPECT_EQ(0, signaled); + + ret = ioctl(event, NTSYNC_IOC_EVENT_PULSE, &signaled); + EXPECT_EQ(0, ret); + EXPECT_EQ(1, signaled); + check_event_state(event, 0, 0); + + ret = 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;