Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp774274pxb; Thu, 23 Sep 2021 10:15:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyx8N0mof4/HG/hz0emVlak1sGBhCFjjG9r7kPI71vHD/91zajs31d76cV4nuwIUyOcRsMh X-Received: by 2002:a6b:5f1b:: with SMTP id t27mr4832789iob.213.1632417354638; Thu, 23 Sep 2021 10:15:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632417354; cv=none; d=google.com; s=arc-20160816; b=jgH0j0URVjm9llFVVIOFdIvdhzDO/Hnuw2YqHJRGgoNFIgJwuEonFQH4mHwRj+M6fN RvKEX2W/c4MPjB8AkpjxeeMhcL7hnEhmtjEAF0ac0mejnD454yT8fv2VQH7BeVIDIL23 rh5kZhZP7l6p9ZglE+vVQbxiu1hZjECs9UJ6Fdb4z3Hhzt4NtaFGJifdGsVXLH4+GZ02 KKo3kicDTHdWDYSwQ37sm04i4ysRRn3JMHxz7Il3TpKj6jaShAisQ8xgE14h+VCEr2yJ 0ScHBKNLuU4W6wXVr2isEncwAg0ZwEv8pWAkBDYsiCEdA0z0Wpb6t5jRrwZDfBSYzXdu fZEQ== 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=QlcA4ic5lMDECYhSdWsS3abSp0JPkUuu+E1kqFl+wUI=; b=Y3E3mGkdTArAQxDRG6REJdreQG/+yj+Y1mNfV1fVy1eOeyVVLQsVQgAxTDL+1vWUfk PBa+vipxQJ050nnR5c+JRTy+zsOkOOp91np5v3n7x85XDVfHNne5sKGap2rbVUoKeQNR xO+z18Hk5xG2eJxJ0Dx7Ditc2oWRqGPFkozLEsuFxFHhErpNacNL+5cDKs/0aihwtulV mlK9ZtM0fQrhDB7iLoSPMADmabHGIacZyr2FNJrErdtil7MqElgY4QBwXwCuNPw76R8a RnHCDnhq54jtH3BTtJmEqEGazy6gPwPc8JnqREUlEZCMUddJu4AgJi5H4gRzIohWg/b/ VZcQ== 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 n2si8777414jaj.35.2021.09.23.10.15.42; Thu, 23 Sep 2021 10:15:54 -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 S242752AbhIWROy (ORCPT + 99 others); Thu, 23 Sep 2021 13:14:54 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:47256 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242687AbhIWROb (ORCPT ); Thu, 23 Sep 2021 13:14:31 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: tonyk) with ESMTPSA id 4E8311F44619 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 21/22] selftests: futex: Test sys_futex_waitv() wouldblock Date: Thu, 23 Sep 2021 14:11:10 -0300 Message-Id: <20210923171111.300673-22-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 futex_waitv() returns -EWOULDBLOCK correctly when the expected value is different from the actual value for a waiter. Signed-off-by: André Almeida --- .../futex/functional/futex_wait_wouldblock.c | 41 +++++++++++++++++-- 1 file changed, 37 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/futex/functional/futex_wait_wouldblock.c b/tools/testing/selftests/futex/functional/futex_wait_wouldblock.c index 0ae390ff8164..7d7a6a06cdb7 100644 --- a/tools/testing/selftests/futex/functional/futex_wait_wouldblock.c +++ b/tools/testing/selftests/futex/functional/futex_wait_wouldblock.c @@ -22,6 +22,7 @@ #include #include #include "futextest.h" +#include "futex2test.h" #include "logging.h" #define TEST_NAME "futex-wait-wouldblock" @@ -42,6 +43,12 @@ int main(int argc, char *argv[]) futex_t f1 = FUTEX_INITIALIZER; int res, ret = RET_PASS; int c; + struct futex_waitv waitv = { + .uaddr = (uintptr_t)&f1, + .val = f1+1, + .flags = FUTEX_32, + .__reserved = 0 + }; while ((c = getopt(argc, argv, "cht:v:")) != -1) { switch (c) { @@ -61,18 +68,44 @@ int main(int argc, char *argv[]) } ksft_print_header(); - ksft_set_plan(1); + ksft_set_plan(2); ksft_print_msg("%s: Test the unexpected futex value in FUTEX_WAIT\n", basename(argv[0])); info("Calling futex_wait on f1: %u @ %p with val=%u\n", f1, &f1, f1+1); res = futex_wait(&f1, f1+1, &to, FUTEX_PRIVATE_FLAG); if (!res || errno != EWOULDBLOCK) { - fail("futex_wait returned: %d %s\n", - res ? errno : res, res ? strerror(errno) : ""); + ksft_test_result_fail("futex_wait returned: %d %s\n", + res ? errno : res, + res ? strerror(errno) : ""); ret = RET_FAIL; + } else { + ksft_test_result_pass("futex_wait\n"); } - print_result(TEST_NAME, ret); + if (clock_gettime(CLOCK_MONOTONIC, &to)) { + error("clock_gettime failed\n", errno); + return errno; + } + + to.tv_nsec += timeout_ns; + + if (to.tv_nsec >= 1000000000) { + to.tv_sec++; + to.tv_nsec -= 1000000000; + } + + info("Calling futex_waitv on f1: %u @ %p with val=%u\n", f1, &f1, f1+1); + res = futex_waitv(&waitv, 1, 0, &to, CLOCK_MONOTONIC); + if (!res || errno != EWOULDBLOCK) { + ksft_test_result_pass("futex_waitv returned: %d %s\n", + res ? errno : res, + res ? strerror(errno) : ""); + ret = RET_FAIL; + } else { + ksft_test_result_pass("futex_waitv\n"); + } + + ksft_print_cnts(); return ret; } -- 2.33.0