From patchwork Mon Feb 19 22:38:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elizabeth Figura X-Patchwork-Id: 203316 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp77192dyc; Mon, 19 Feb 2024 14:47:43 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWArPRbIUzK3tXvvzPq4BTiSfz0zUgLM3n4i+hkZMVsk24VmD52y/WmMFQzbGq3+XyhG0/du0L+1aweYZyEqLMbPu3rNw== X-Google-Smtp-Source: AGHT+IHHWwpO0lEPWgLxiEZ6K3fH0HqRw79wZYTXL5u7WyY2190RMY7vmdrddr/rAeOns3IpLPQ8 X-Received: by 2002:a05:620a:84ca:b0:787:6fdb:7bde with SMTP id pq10-20020a05620a84ca00b007876fdb7bdemr3767553qkn.33.1708382863388; Mon, 19 Feb 2024 14:47:43 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708382863; cv=pass; d=google.com; s=arc-20160816; b=G25LdFVf9DjeI4nReesutcoTQVYet0ZsNeXcVZYiLSrBVctw6bKO6N8EBB6KK34djZ DOc3uBUEZ9ysiAVAfaqeGR13g1VmMh9CXQJrLW10aw5o4zNvWeE4y4Qygl23fEoS+GPa nrmz5Io5MfahcuPTs1xkgcgwuIkMPi2U8nTv26HWyYN5uHN7Njq4h+I6wg8i+CO8DZrT 505Dld6FKSUX6vkWgdzqBb9LIDVO610bqTTV/zpmRttZbNIrVp4lLg2tMlFne3SgiNd4 6oSYPwVAb2nH4znLsZQ/ZOfPGDHW6Prxyu8NkWbzdOPyfeuLc2e9apvZ+7uwTZGzi5S0 Zg6A== 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=LKcmPKdAjQdF3bbQtJTzkXMVlTzxEokxNER4gf+xieY=; fh=hR3Xqo6s6FufP5gEw1XgbtLHrluZu7hd5XGp+hLIfiM=; b=A8KAWNfjpO7hbFD8DErTOib27TVxyhw7qKh+PwF0J9WK9eRtQksEu3wUkqhT1A4yTp O/RzwPYpmUN3IAS7l8RuauHlc+71YHBbb9PIfYYfbsrWdVtk1gL6FnjRV7UAlMcBV7oY o3cerfbq2L0mCUQDUkpddL5IQOrnAqcotmxAAs51pg0aRGOuCQlqE1CVpM1npz/vFKSv TqEq3qSes5ylwMIkMZSHdO0Y9H529bLI3931WYNzuD840a1ACFace+nkbENODAtYLefk f5aJJyTje9egdLe0IJhsv7/P1sJ46h1EPbtyJ9JbAJn5ueeESo0Zngi0fhR3AzVS30td pCBQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@codeweavers.com header.s=s1 header.b=GMEk38aR; 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-72105-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-72105-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=codeweavers.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id ou39-20020a05620a622700b007876fdb7bddsi1744141qkn.230.2024.02.19.14.47.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 14:47:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-72105-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@codeweavers.com header.s=s1 header.b=GMEk38aR; 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-72105-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-72105-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 27DC81C21CAD for ; Mon, 19 Feb 2024 22:47:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3CA7E67A16; Mon, 19 Feb 2024 22:39:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=codeweavers.com header.i=@codeweavers.com header.b="GMEk38aR" 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 1FF1B5676F; Mon, 19 Feb 2024 22:39:38 +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=1708382382; cv=none; b=AX7xr21cugCMysCNUWoyd2haUA6/F4Dk5UOAjhonWG+uRPKkI8be7b4WdvNQUlYz4a4OjyMIePhOOcBlUYXucB6TX6Pul2n2NA1hHl+QRc68tKB+8EwTMfwUB2fKs5W6lTwz+2i13ptbr8NgLt+/5J8R1O03fHpyyRiw5qt0v9A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708382382; c=relaxed/simple; bh=UtZlrYh+PmJdbzwEPZ8FZ2UGM/54x6+dlq/Hl5BOk+Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=m4Ra80NOAboonw1gCG0f7TrnHxiZq39MvM2uoXJN0PbSaXh38G3/+vrSFA4z46+MCXs7rj07iEFjQIv6Bxy8aoz7Cr4ngzNwnfKkfs7LZPFn7az6Jf3EEEuZrSSVBDS/gQo8z9Mv0zmAX9g0afk7erWoh1OpWSWe7Dde2WiqLkg= 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=GMEk38aR; 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=LKcmPKdAjQdF3bbQtJTzkXMVlTzxEokxNER4gf+xieY=; b=GMEk38aRzCsql4OCoE6k2dq9E1 Y8bFWT5JrWXlybQ3GCszyrdYRHLDdXHcaoqp8fXEOJ1YwlrmimdgZgPwoOO8uuWdXOqaXhYpL4PZi +RKeZjFu+zgmDKtDvKmJ8cGJla4mKC9fnu8ktMD8hmMXN7vURDgEXQhBIPAMoKYktQ5+1vi9pls2W KDKv8ehlQfnNgsvNbDQ9ZKj4w4ucvinyZwhnB9Qz0jXReaNP7oHd+NdrxrHuyTX4r0++U543Wmmqs Q83POryFlXV6yZOWxwt3QW71vNXbeO5pKsD78m+1nNc621l5ltMtO8m9LDmkq/N7gVyOI59fGC1Yu V5LLH88Q==; 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 1rcCIS-0037Oz-23; Mon, 19 Feb 2024 16:39:36 -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, Randy Dunlap , Elizabeth Figura Subject: [PATCH v2 25/31] selftests: ntsync: Add some tests for auto-reset event state. Date: Mon, 19 Feb 2024 16:38:27 -0600 Message-ID: <20240219223833.95710-26-zfigura@codeweavers.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240219223833.95710-1-zfigura@codeweavers.com> References: <20240219223833.95710-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: 1791369269616586268 X-GMAIL-MSGID: 1791369269616586268 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 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); } +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;