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 3797A3101A9; Wed, 17 Sep 2025 21:23:28 +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=1758144209; cv=none; b=NLWtGSHP6iabX5s/xP077Wvo0i67M7jJd6z2cI8LZKbPsCeMtg71rNhr5xjc1zyYUi8maBaBpaBIvHZjMsocnFZJHl8AFwFQKFiu1wr7UZuLg8xQmvk73wZfpGJGB05cZQJdwVXOVybNvsL/ANazttIWkKCUQziINc/+hnjhD2Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758144209; c=relaxed/simple; bh=pqw8nNA03uWYatAtp667EchelVCKgMD8tugcKbIy4YM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=BGA16ySJBn8yk2a2v7u6KjoZV5KVKWj0ecQYLsgG+bcWkLu0BZi4HsXyStHCegeV3hJ/XfTc6fQUDrnV0wjKrsOxOCOGZoHe2jAIqiBTTCwvNNI71rYJzZqcjwkaWcApQre9ERxuVd0l2QLVqHhYLApE8LvQCuAUkrGlhh+yMjM= 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=cf8EyPGa; 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="cf8EyPGa" 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=YhlOvvSM5hh3gzgwP5617LIrDcARnvfh4VFWk9tr+EA=; b=cf8EyPGaoJZX+l+wUGu4NMvVOR YO8Z8oXhi8QyeF5+Nyrf5K3lBr/m2x7sQIlzRLCmoOO8UbJ1h+S8RW4eb8CXdkHqdY9ZI3e3ZrSYg 9CelP+MwzUsOGbPblYKgyJvcCf4yNA18wE4MvjAtQiW2GKz9rI94Y6NhORLqN+C4CciZ6ptvt2fpq Ci08IZoaFNEhjPmQjFFHgXS88wa8vElWn52+alkM6YpSV7B2hltab+eDcIrhgKkqovnh+3KBNW+w8 TTtyx25jqfEqQXnfuhauE4DqtX8ut6s2BYi2UZHwT275neNyGVjpMDqVHbfCnI+jP0qeOUY/+4vuH Fk2AphRA==; 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 1uyzcc-00CsMq-6H; Wed, 17 Sep 2025 23:23:26 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= Date: Wed, 17 Sep 2025 18:21:51 -0300 Subject: [PATCH v3 12/15] selftests/futex: Refactor futex_priv_hash 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-12-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_priv_hash test to use kselftest_harness header instead of futex's logging header. Signed-off-by: Andr=C3=A9 Almeida --- .../selftests/futex/functional/futex_priv_hash.c | 48 ++++--------------= ---- tools/testing/selftests/futex/functional/run.sh | 2 +- 2 files changed, 8 insertions(+), 42 deletions(-) diff --git a/tools/testing/selftests/futex/functional/futex_priv_hash.c b/t= ools/testing/selftests/futex/functional/futex_priv_hash.c index 95f01603a6813cdfd6ec9ee1f22c4c4f5061004c..3b7b5851f290fcabd693276fc67= 46cfe30ca9520 100644 --- a/tools/testing/selftests/futex/functional/futex_priv_hash.c +++ b/tools/testing/selftests/futex/functional/futex_priv_hash.c @@ -14,7 +14,7 @@ #include #include =20 -#include "logging.h" +#include "../../kselftest_harness.h" =20 #define MAX_THREADS 64 =20 @@ -128,45 +128,14 @@ static void futex_dummy_op(void) ksft_exit_fail_msg("pthread_mutex_timedlock() did not timeout: %d.\n", r= et); } =20 -static 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); -} - static const char *test_msg_auto_create =3D "Automatic hash bucket init on= thread creation.\n"; static const char *test_msg_auto_inc =3D "Automatic increase with more tha= n 16 CPUs\n"; =20 -int main(int argc, char *argv[]) +TEST(priv_hash) { int futex_slots1, futex_slotsn, online_cpus; pthread_mutexattr_t mutex_attr_pi; int ret, retry =3D 20; - int c; - - while ((c =3D getopt(argc, argv, "chv:")) !=3D -1) { - switch (c) { - case 'c': - log_color(1); - break; - case 'h': - usage(basename(argv[0])); - exit(0); - break; - case 'v': - log_verbosity(atoi(optarg)); - break; - default: - usage(basename(argv[0])); - exit(1); - } - } - - ksft_print_header(); - ksft_set_plan(21); =20 ret =3D pthread_mutexattr_init(&mutex_attr_pi); ret |=3D pthread_mutexattr_setprotocol(&mutex_attr_pi, PTHREAD_PRIO_INHER= IT); @@ -279,7 +248,7 @@ int main(int argc, char *argv[]) ret =3D futex_hash_slots_set(0); ksft_test_result(ret =3D=3D 0, "Global hash request\n"); if (ret !=3D 0) - goto out; + return; =20 futex_hash_slots_set_must_fail(4); futex_hash_slots_set_must_fail(8); @@ -288,17 +257,14 @@ int main(int argc, char *argv[]) futex_hash_slots_set_must_fail(6); =20 ret =3D pthread_barrier_init(&barrier_main, NULL, MAX_THREADS); - if (ret !=3D 0) { + if (ret !=3D 0) ksft_exit_fail_msg("pthread_barrier_init failed: %m\n"); - return 1; - } + create_max_threads(thread_lock_fn); join_max_threads(); =20 ret =3D futex_hash_slots_get(); ksft_test_result(ret =3D=3D 0, "Continue to use global hash\n"); - -out: - ksft_finished(); - return 0; } + +TEST_HARNESS_MAIN diff --git a/tools/testing/selftests/futex/functional/run.sh b/tools/testin= g/selftests/futex/functional/run.sh index 4a7b0efbcce2962a2cc40e3911711079a4e70243..f725531f06c4a88e6d3ebbabb62= 8a5d5009eaa3b 100755 --- a/tools/testing/selftests/futex/functional/run.sh +++ b/tools/testing/selftests/futex/functional/run.sh @@ -60,7 +60,7 @@ echo ./futex_waitv =20 echo -./futex_priv_hash $COLOR +./futex_priv_hash =20 echo ./futex_numa_mpol $COLOR --=20 2.51.0