Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp773541pxb; Thu, 23 Sep 2021 10:15:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxc7vn1yNe9Uxwq80y0Xm11JcqolLK9Hc7BP8RRHuBgCWTMIbNzY6fbKAdEr3saa7UqgRLN X-Received: by 2002:a6b:cd01:: with SMTP id d1mr5065024iog.88.1632417306094; Thu, 23 Sep 2021 10:15:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632417306; cv=none; d=google.com; s=arc-20160816; b=GfG+rMq92rYSURRveasVFi4zIWBBVhEGr6xscAtelk63bEIb/fo3pQri21IycFonkL Uts1gIdna0pOtk35J6Juh6py/M014gOF5pE80ywbmENPzR2jYk6RUldbBmhrNsXPzUso mPNykZQj7PqHhltruULOb7vGaTZT6EfFvfef7Fv1bD1sYOgsilZu4gm/bwdWJM8ceGM/ 4tHSQDDIeu9NGB9oVfM9hRu76R7ySnvxMIt/F9/cMzV5PVFRZtqw9Mc0tUgmp6rt0lHl lHJ5rHu2Qp8PRQfVwJ+/vA/3ltxLpegD4Wj0MXFtqPKIszl5e9gwrAH8LMa3J+UQg5d+ dJeg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=2w7v0mNX8zD/8dTr98CQ1AsS4kDq8CV69PRioawRlrE=; b=oQhDihrfnZVfh/WpkWGrlHH7/j5O8ei6+1jyujs7/fDZ+6ntzQJEL67kTo+OMzZHYC eb1peOd46ta/IjYVqJX6zvlye5W1AyRa1t77t+SB7L/2iowIL+KswhWnZRljeEyeswYq k84LEpwbsvr666VZ2YFNfMJLfZZ3dAwokG2cou1u7rQDqSsrWajndCSuLr5RoDgMdhul Ym0dK440OlIVBV/hEjtVYzGGf5f7YNezrxiQ/tjEyTFnUxP5s+4c4y5iLmQB0Hhgj6Wf 6cv3i4ICuENr3hUvlTVPdkdcC/UzlmW69BPTDiqdL7F6ZrgQZ36PXSomkksz14Nju8v7 9iRQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c3si4497395ilq.163.2021.09.23.10.14.54; Thu, 23 Sep 2021 10:15:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242663AbhIWROw (ORCPT + 99 others); Thu, 23 Sep 2021 13:14:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58372 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242570AbhIWRO1 (ORCPT ); Thu, 23 Sep 2021 13:14:27 -0400 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DBFC2C0613D3; Thu, 23 Sep 2021 10:12:55 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: tonyk) with ESMTPSA id DBB121F44618 From: =?UTF-8?q?Andr=C3=A9=20Almeida?= To: Thomas Gleixner , Ingo Molnar , Peter Zijlstra , Darren Hart , linux-kernel@vger.kernel.org, Steven Rostedt , Sebastian Andrzej Siewior Cc: kernel@collabora.com, krisman@collabora.com, linux-api@vger.kernel.org, libc-alpha@sourceware.org, mtk.manpages@gmail.com, Davidlohr Bueso , Arnd Bergmann , =?UTF-8?q?Andr=C3=A9=20Almeida?= Subject: [PATCH v2 20/22] selftests: futex: Test sys_futex_waitv() timeout Date: Thu, 23 Sep 2021 14:11:09 -0300 Message-Id: <20210923171111.300673-21-andrealmeid@collabora.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210923171111.300673-1-andrealmeid@collabora.com> References: <20210923171111.300673-1-andrealmeid@collabora.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Test if the futex_waitv timeout is working as expected, using the supported clockid options. Signed-off-by: André Almeida --- .../futex/functional/futex_wait_timeout.c | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/futex/functional/futex_wait_timeout.c b/tools/testing/selftests/futex/functional/futex_wait_timeout.c index 1f8f6daaf1e7..3651ce17beeb 100644 --- a/tools/testing/selftests/futex/functional/futex_wait_timeout.c +++ b/tools/testing/selftests/futex/functional/futex_wait_timeout.c @@ -17,6 +17,7 @@ #include #include "futextest.h" +#include "futex2test.h" #include "logging.h" #define TEST_NAME "futex-wait-timeout" @@ -96,6 +97,12 @@ int main(int argc, char *argv[]) struct timespec to; pthread_t thread; int c; + struct futex_waitv waitv = { + .uaddr = (uintptr_t)&f1, + .val = f1, + .flags = FUTEX_32, + .__reserved = 0 + }; while ((c = getopt(argc, argv, "cht:v:")) != -1) { switch (c) { @@ -118,7 +125,7 @@ int main(int argc, char *argv[]) } ksft_print_header(); - ksft_set_plan(7); + ksft_set_plan(9); ksft_print_msg("%s: Block on a futex and wait for timeout\n", basename(argv[0])); ksft_print_msg("\tArguments: timeout=%ldns\n", timeout_ns); @@ -175,6 +182,18 @@ int main(int argc, char *argv[]) res = futex_lock_pi(&futex_pi, NULL, 0, FUTEX_CLOCK_REALTIME); test_timeout(res, &ret, "futex_lock_pi invalid timeout flag", ENOSYS); + /* futex_waitv with CLOCK_MONOTONIC */ + if (futex_get_abs_timeout(CLOCK_MONOTONIC, &to, timeout_ns)) + return RET_FAIL; + res = futex_waitv(&waitv, 1, 0, &to, CLOCK_MONOTONIC); + test_timeout(res, &ret, "futex_waitv monotonic", ETIMEDOUT); + + /* futex_waitv with CLOCK_REALTIME */ + if (futex_get_abs_timeout(CLOCK_REALTIME, &to, timeout_ns)) + return RET_FAIL; + res = futex_waitv(&waitv, 1, 0, &to, CLOCK_REALTIME); + test_timeout(res, &ret, "futex_waitv realtime", ETIMEDOUT); + ksft_print_cnts(); return ret; } -- 2.33.0