From patchwork Fri Aug 14 18:36:12 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andr=C3=A9_Almeida?= X-Patchwork-Id: 141438 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9FEAF4BA902D for ; Fri, 14 Aug 2026 18:37:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9FEAF4BA902D Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=igalia.com header.i=@igalia.com header.a=rsa-sha256 header.s=20170329 header.b=AxFWSBc2 X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) by sourceware.org (Postfix) with ESMTPS id 77DD14BA2E0C for ; Fri, 14 Aug 2026 18:36:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 77DD14BA2E0C Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=igalia.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=igalia.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 77DD14BA2E0C Authentication-Results: sourceware.org; arc=none smtp.remote-ip=213.97.179.56 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1786732613; cv=none; b=AGwqjSsf8nk0D8uYgLSI4sCLpTtp2cqpQyKW5//Wq2F2Kq4ZMS1G0A666chlUzRGOeetBPJQtz9BKdqf+bwjteYBfYJA0o6hPUe1UrDtxj8inCCbZl/L07NWBTDgQ0kbAkKoDgxDZPetCA6tts+ji+B0XJLqvnEKiN5H4gy+2t8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1786732613; c=relaxed/simple; bh=Px+XfblFQfPn5+Q9wvQ9+d7FjledlaP8FRYET//5bVM=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=TzXQBaa+4qwSSrZkIaXDA769BxweVJHves+PDZxSXZkmWVGzq+ieB47vkMIQwr3ve1fjycJcDWFGCojgZHWF8n6ZMkSTfcYGPOO+RgkCkblScOEPEfsPya3SvsTejGADa8SL0yuCA4nIFQ4LoKVLF3+UjrUxl/rU73sGAUPd0O0= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=igalia.com header.i=@igalia.com header.a=rsa-sha256 header.s=20170329 header.b=AxFWSBc2 DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 77DD14BA2E0C DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID: Date:Subject:Cc:To:From:From:Reply-To; bh=uHydzl1Cs+OTOIMnYUbLomWLygPq8sWiHpPATDOJJH4=; b=AxFWSBc2UK41FmHATV83KS08Zd cSzc34vLt+t7un3LtNZ+A7WUxZvc2D+oC1SdUwjXNxjDfudCMXh5MHlvFpQ+iOA6mHaoaXBE3ZdrL uR1OJ6KMButSfESKtVGKOtP/WZvV6xw4f47livym1EveZyd3cecRXqJPZt9VNwEgKRXj/9DEejHJO N1GhWHyIZeIrtdEVkf3n+XOx9HddPBFSoSvBsPzX/rwGJmF3k28Cy0fCUDORCmoHcjPNDBXnQVmwH jcT1iWtwH2KtqVoQR2tvnJ+2LxaG3xBLESmJ2EQu0AcItHZqbPvH5ab7+n20twsairXPFgH9RZBIa UOqY8Gew==; Received: from [177.139.22.20] (helo=computador) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1wuwlv-001xOF-Qb; Fri, 14 Aug 2026 20:36:52 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= To: libc-alpha@sourceware.org, carlos@redhat.com, adhemerval.zanella@linaro.org Cc: =?utf-8?q?Andr=C3=A9_Almeida?= Subject: [PATCH 2/2] misc: tst-futex: Create futex test Date: Fri, 14 Aug 2026 15:36:12 -0300 Message-ID: <20260814183612.1780736-3-andrealmeid@igalia.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260814183612.1780736-1-andrealmeid@igalia.com> References: <20260814183612.1780736-1-andrealmeid@igalia.com> MIME-Version: 1.0 X-Spam-Status: No, score=-10.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_PBL, SPF_HELO_NONE, SPF_PASS, TXREP shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~patchwork=sourceware.org@sourceware.org Create test for the futex syscall wrappers. Signed-off-by: André Almeida --- sysdeps/unix/sysv/linux/Makefile | 1 + sysdeps/unix/sysv/linux/tst-futex.c | 93 +++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+) create mode 100644 sysdeps/unix/sysv/linux/tst-futex.c diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile index d3ccb57b59..73ea9425f4 100644 --- a/sysdeps/unix/sysv/linux/Makefile +++ b/sysdeps/unix/sysv/linux/Makefile @@ -201,6 +201,7 @@ tests += \ tst-epoll-ioctls \ tst-fanotify \ tst-fdopendir-o_path \ + tst-futex \ tst-getauxval \ tst-gettid \ tst-gettid-kill \ diff --git a/sysdeps/unix/sysv/linux/tst-futex.c b/sysdeps/unix/sysv/linux/tst-futex.c new file mode 100644 index 0000000000..fae6418a1c --- /dev/null +++ b/sysdeps/unix/sysv/linux/tst-futex.c @@ -0,0 +1,93 @@ +/* Basic tests for Linux futex_* wrappers. + Copyright (C) 2022-2026 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define FUTEX_WAKE 1 + +#define NR_WAITERS 5 + +static uint32_t futex[NR_WAITERS]; + +static int +futex_wake (uint32_t *futex, int val) +{ + return syscall (__NR_futex, futex, FUTEX_WAKE, val); +} + +static void * +thread_waiter (void *arg) +{ + struct futex_waitv waiters[NR_WAITERS]; + struct timespec timeout; + int i, ret; + + clock_gettime(CLOCK_MONOTONIC, &timeout); + timeout.tv_sec += 5; + + for (i = 0; i < NR_WAITERS; i++) { + waiters[i].uaddr = (uintptr_t) &futex[i]; + waiters[i].val = 0; + waiters[i].flags = FUTEX2_SIZE_U32; + waiters[i].__reserved = 0; + } + + ret = futex_waitv(waiters, NR_WAITERS, 0, &timeout, CLOCK_MONOTONIC); + + if (ret == -1) + FAIL_EXIT1 ("futex_waitv failed"); + + return NULL; +} + +static void +test_futex_waitv_basic (void) +{ + int i; + + for (i = 0; i < NR_WAITERS; i++) + futex[i] = 0; + + xpthread_create (NULL, thread_waiter, NULL); + + usleep(1000); + + futex_wake (&futex[3], 0); + +} + +static int +do_test (void) +{ + test_futex_waitv_basic (); + + + return 0; +} + +#include