From nobody Thu Oct 2 12:06:27 2025 Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) (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 2E49730C620; Wed, 17 Sep 2025 21:23:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.97.179.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758144193; cv=none; b=mGDg6ek4AYS3eV9j9HLYLddv9WmISGToCP4HAVtwSOefY9P5aUvZQBErBpAVoHSy3umXLrbhRzICiVqzMUCd1IKzPaUPjgOwAIolDLA/6hyi+DsCA73CQgUzYyPpEURPXG67c2YWZtWr8HH6IvMKnqnfJtnQry7oir2keTb8nic= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758144193; c=relaxed/simple; bh=vJBF7xnyH6eY+Ij59jETYymm0hpvX6bnTNxb0Syzueo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=AGwuDZ8H5G/u9Wgg1s7+CMYt6XUS/rXMyatRBsipP2vV588cEGJKZ4qsnCZtj6FP9GKPxJg4PsOgdVU5Rn0bwR4PwEIC5lUZetFpPI8NYcqj4EXWygqNCll6zw1KfMk7CnvlRxMD/AY7q94kuSPAo2hYyxOpp+qKnm7WdK2hBtI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=igalia.com; spf=pass smtp.mailfrom=igalia.com; dkim=pass (2048-bit key) header.d=igalia.com header.i=@igalia.com header.b=EddLs+xZ; arc=none smtp.client-ip=213.97.179.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=igalia.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=igalia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=igalia.com header.i=@igalia.com header.b="EddLs+xZ" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Cc:To:In-Reply-To:References:Message-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From:Sender: Reply-To: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=BU9FnS6Oehk7szHXJ/JJaYmuuyjtZYFzwkh2Du3BYF8=; b=EddLs+xZCKLgL+hfXosYhhAP0a 0oYROtG3OEH9N8GaI/MOTmporUzN9Psf1Jg5rrmDIpUIHNoniejHCSuGc8B32/GjmlqC48vHRxekP Vm8Ogo77+exRIPDhMY6EZvpMUI3CfjaWciBvlJeHpD9+Avb0B/y1b0ZdlPCvIddLvgWEAUehQskIn gAOPcNhndlecIgbPTnFzd4tmCFfIKXfmLpP+WENlIxdlWsrQw6HVUPx+rFJhGG1/fcGpsuNfv1YUO LR0Z0Xf00OBH/NliBsDzDA9nBpjZVWlCI0D7dNSdkBDElTQW36B+l31/HpZRqT2OqtSHHJSKnDMN/ aZBHoA2A==; Received: from [191.204.197.103] (helo=[192.168.15.100]) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1uyzcM-00CsMq-6R; Wed, 17 Sep 2025 23:23:10 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= Date: Wed, 17 Sep 2025 18:21:45 -0300 Subject: [PATCH v3 06/15] selftests/futex: Refactor futex_wait_wouldblock with kselftest_harness.h Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250917-tonyk-robust_test_cleanup-v3-6-306b373c244d@igalia.com> References: <20250917-tonyk-robust_test_cleanup-v3-0-306b373c244d@igalia.com> In-Reply-To: <20250917-tonyk-robust_test_cleanup-v3-0-306b373c244d@igalia.com> To: Shuah Khan , Thomas Gleixner , Ingo Molnar , Peter Zijlstra , Darren Hart , Davidlohr Bueso , Sebastian Andrzej Siewior Cc: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-dev@igalia.com, =?utf-8?q?Andr=C3=A9_Almeida?= X-Mailer: b4 0.14.2 To reduce the boilerplate code, refactor futex_wait_wouldblock test to use kselftest_harness header instead of futex's logging header. Signed-off-by: Andr=C3=A9 Almeida --- .../futex/functional/futex_wait_wouldblock.c | 75 +++++++-----------= ---- tools/testing/selftests/futex/functional/run.sh | 2 +- 2 files changed, 23 insertions(+), 54 deletions(-) diff --git a/tools/testing/selftests/futex/functional/futex_wait_wouldblock= .c b/tools/testing/selftests/futex/functional/futex_wait_wouldblock.c index 2d8230da906429cd9f1f9021e8df23e12398429e..7bb4ff4dcd9d5fef289b1012975= 558f19e1490e0 100644 --- a/tools/testing/selftests/futex/functional/futex_wait_wouldblock.c +++ b/tools/testing/selftests/futex/functional/futex_wait_wouldblock.c @@ -21,72 +21,43 @@ #include #include #include + #include "futextest.h" #include "futex2test.h" -#include "logging.h" +#include "../../kselftest_harness.h" =20 -#define TEST_NAME "futex-wait-wouldblock" #define timeout_ns 100000 =20 -void usage(char *prog) -{ - printf("Usage: %s\n", prog); - printf(" -c Use color\n"); - printf(" -h Display this help message\n"); - printf(" -v L Verbosity level: %d=3DQUIET %d=3DCRITICAL %d=3DINFO\n", - VQUIET, VCRITICAL, VINFO); -} - -int main(int argc, char *argv[]) +TEST(futex_wait_wouldblock) { struct timespec to =3D {.tv_sec =3D 0, .tv_nsec =3D timeout_ns}; futex_t f1 =3D FUTEX_INITIALIZER; - int res, ret =3D RET_PASS; - int c; - struct futex_waitv waitv =3D { - .uaddr =3D (uintptr_t)&f1, - .val =3D f1+1, - .flags =3D FUTEX_32, - .__reserved =3D 0 - }; - - while ((c =3D getopt(argc, argv, "cht:v:")) !=3D -1) { - switch (c) { - case 'c': - log_color(1); - break; - case 'h': - usage(basename(argv[0])); - exit(0); - case 'v': - log_verbosity(atoi(optarg)); - break; - default: - usage(basename(argv[0])); - exit(1); - } - } - - ksft_print_header(); - ksft_set_plan(2); - ksft_print_msg("%s: Test the unexpected futex value in FUTEX_WAIT\n", - basename(argv[0])); + int res; =20 - info("Calling futex_wait on f1: %u @ %p with val=3D%u\n", f1, &f1, f1+1); + ksft_print_dbg_msg("Calling futex_wait on f1: %u @ %p with val=3D%u\n", f= 1, &f1, f1+1); res =3D futex_wait(&f1, f1+1, &to, FUTEX_PRIVATE_FLAG); if (!res || errno !=3D EWOULDBLOCK) { ksft_test_result_fail("futex_wait returned: %d %s\n", res ? errno : res, res ? strerror(errno) : ""); - ret =3D RET_FAIL; } else { ksft_test_result_pass("futex_wait\n"); } +} =20 - if (clock_gettime(CLOCK_MONOTONIC, &to)) { - error("clock_gettime failed\n", errno); - return errno; - } +TEST(futex_waitv_wouldblock) +{ + struct timespec to =3D {.tv_sec =3D 0, .tv_nsec =3D timeout_ns}; + futex_t f1 =3D FUTEX_INITIALIZER; + int res; + struct futex_waitv waitv =3D { + .uaddr =3D (uintptr_t)&f1, + .val =3D f1+1, + .flags =3D FUTEX_32, + .__reserved =3D 0 + }; + if (clock_gettime(CLOCK_MONOTONIC, &to)) + ksft_exit_fail_msg("clock_gettime failed %d\n", errno); =20 to.tv_nsec +=3D timeout_ns; =20 @@ -95,17 +66,15 @@ int main(int argc, char *argv[]) to.tv_nsec -=3D 1000000000; } =20 - info("Calling futex_waitv on f1: %u @ %p with val=3D%u\n", f1, &f1, f1+1); + ksft_print_dbg_msg("Calling futex_waitv on f1: %u @ %p with val=3D%u\n", = f1, &f1, f1+1); res =3D futex_waitv(&waitv, 1, 0, &to, CLOCK_MONOTONIC); if (!res || errno !=3D EWOULDBLOCK) { ksft_test_result_fail("futex_waitv returned: %d %s\n", res ? errno : res, res ? strerror(errno) : ""); - ret =3D RET_FAIL; } else { ksft_test_result_pass("futex_waitv\n"); } - - ksft_print_cnts(); - return ret; } + +TEST_HARNESS_MAIN diff --git a/tools/testing/selftests/futex/functional/run.sh b/tools/testin= g/selftests/futex/functional/run.sh index 0af695038003b1ded7b21959d5f85105282811df..a5246d59849853bb70ecf836f05= 20053cf1fee76 100755 --- a/tools/testing/selftests/futex/functional/run.sh +++ b/tools/testing/selftests/futex/functional/run.sh @@ -44,7 +44,7 @@ echo ./futex_wait_timeout =20 echo -./futex_wait_wouldblock $COLOR +./futex_wait_wouldblock =20 echo ./futex_wait_uninitialized_heap $COLOR --=20 2.51.0