From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F229C3BBA10 for ; Thu, 19 Mar 2026 22:44:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773960282; cv=none; b=N8NWTfcBBJcyKjuabG/Kf8aZCrZujZVVtxgCTbV94tZF6mWvdmkXk0VoZuPfMq3OsnCf5PANC+XwdaqcVpPgkfG7gyIDFOTyEwcArHCeR9rK8KoidqzZ/2cbs5YGeRKkq6Qf2XVaN6ZV0VoC/9N+fcHfruKToGeu7QU2O2Kp758= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773960282; c=relaxed/simple; bh=Aa2mame68qvgpp5vrU9+ROVeTrbmIlqHxAieTWCJNc8=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=J5b1RDo7yJFaGU8m+wZ89Aik4CARHzUc/bo+PaDvHCcwFOJ9Lz+uNS3MFhRp6F0lpkE82Uv1JN+3tYW+C1N84OQSM+L+UqLCDJ7fDh5xJuYvFN1THUTUrmm1lyn7xFvPy/L2zakCeZCXxFHK3ZjC9B8GAk7rQmy3l7zlD4VG3aI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=iEEAxz04; arc=none smtp.client-ip=209.85.221.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="iEEAxz04" Received: by mail-wr1-f45.google.com with SMTP id ffacd0b85a97d-43b4d73463dso19803f8f.3 for ; Thu, 19 Mar 2026 15:44:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1773960279; x=1774565079; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=h/xRVfZVCsnysUgIJA5WJ9mMMWVe3lASIMciyFEfzio=; b=iEEAxz04fS0Nff1wSo1+SfrUua0P8q/5bgtKR+cQ8FGago8U10d2TcIKF9mBRGcSax AIjrsJiwfSYcRcZDtwGFey9T8W6OW3J+0rGkOTWZ1F8IDmQBGN466nBFia0JfuzjCFcs PRqIX7GhjW79tXUINBlll271qf4I7kkxoHwUc5fcgGt+gFCME4OoIcB4vX1c3yk0tKEY IXKcJLMob77rK58RSRdiDxqSW6Zb4QS/7KrlZzXDC1+IUXNmzoT7g1buCQf3/Cs5GIlE KXn635wKH3slV8KZJsXmOSKscXwFRRvd8GsiHKig9GbJ1QRPDpv5qTg3OVjezikU3vqI lDyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773960279; x=1774565079; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=h/xRVfZVCsnysUgIJA5WJ9mMMWVe3lASIMciyFEfzio=; b=BjsEQHOfnVa4YhWL1KYjZI7jZnGzje5FlGeJdYN9Z5wxRoqrDf0m4uOCjWmHsEkaeD dLWjhjA4z0+rY0+WRl6U6gHKjbdaR2Tf3pshi6QuuAZ2A/vTisEPwUNtbk4P045kyiPO eGIdHNe2dD90iQucNJA7ZFFK2VAchV0OSqzVT7ls9DojwRrD7P0ts4/PXmPsLz0N/n1a SMZGWIJT1btuJX7cVVDqdmcStq3ZG3JXP6W1BUegR8IVzrZH0hNGtAZFvoPSoN4m7iNu odUh9VWh1U1yUVRkGefHMS00UV9sXD+GLEkNyCgn2qz6lPbItaYBsVt56dbufGIHeDOk L9PQ== X-Forwarded-Encrypted: i=1; AJvYcCU9g2w6+Z5M1R66fWgSThKduY7xpnkgcFMuxBrGR4lVrAOni6X28cu7yzm7oLfd6dXEFDTqXYFPECnfpTs=@vger.kernel.org X-Gm-Message-State: AOJu0YxlmpFv8ZGBCnatWayqUEP6T+zfAgSluY9Cpj5hC8zd/g9KjQ/A sMzZbzdSd3xwx6tfbpQJf7ue7BNMw0T09+7rpkxs4W/NxZm2PLvyyf+TH080WIHN X-Gm-Gg: ATEYQzxEB9heSHDcKlHViWhuekszP7mAhtX9ah9AMTm4KtIFMVkUhihkCs/71oHeSHu 2+SoUNisOMNLrlGMzgzmO3MMz2rj4yQmoxWh8Y0EHUwPipHMarRadQWj+1YEswk2e2DGXsxMOPZ ciyYs+Dbd7hE4iFddKsHpDvxjNuX/aHQgrbVt292Oy8qujrfslvnup8DFYhJ2jCKpWkRn9XXaLc iOFyQ+pYDukJ+Frhb3yYQzU1uYS9CGa0VNxr0xAuvQqgDZ5x925xjCuRmga/hVVgqBFFRFxuC4C IAUQwL9ZDl4RsEoZAsmU5/tZYsR1DnpePqKbdhR2cPuGzB+ZasWU+dxuHjIUSqZi3T51bj6zD32 LufrMm8s7tkUDSCR/Rx0A11e1EP1RAlxTSDFZdxhd42LLntAhJJXJ724eI2ot1FDNPKvY7S9cPq Ku+EKIP5KbTEp/CJEklazpc9+Vtti44d/GqimPgEwJZlOTqoF1XvV97jv5X3FJBSTL8uLrQSYlV Qw= X-Received: by 2002:a05:6000:24c7:b0:439:c799:dbfa with SMTP id ffacd0b85a97d-43b6423fb14mr1653085f8f.9.1773960278891; Thu, 19 Mar 2026 15:44:38 -0700 (PDT) Received: from pumpkin (82-69-66-36.dsl.in-addr.zen.co.uk. [82.69.66.36]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43b644bdaf8sm1743962f8f.13.2026.03.19.15.44.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Mar 2026 15:44:38 -0700 (PDT) Date: Thu, 19 Mar 2026 22:44:36 +0000 From: David Laight To: Thomas =?UTF-8?B?V2Vpw59zY2h1aA==?= Cc: Willy Tarreau , Daniel Palmer , linux-kernel@vger.kernel.org Subject: Re: [PATCH] selftests/nolibc: fix libc-test with musl libc Message-ID: <20260319224436.554d2ad4@pumpkin> In-Reply-To: <021586fd-ef90-4b8f-9d04-8055d457ff89@t-8ch.de> References: <20260318-nolibc-tests-musl-v1-1-884cd7f48646@weissschuh.net> <20260318225231.00b2f462@pumpkin> <20260319105207.07b66eea@pumpkin> <021586fd-ef90-4b8f-9d04-8055d457ff89@t-8ch.de> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; arm-unknown-linux-gnueabihf) 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 On Thu, 19 Mar 2026 17:18:33 +0100 Thomas Wei=C3=9Fschuh wrote: > On 2026-03-19 10:52:07+0000, David Laight wrote: > > On Wed, 18 Mar 2026 22:52:31 +0000 > > David Laight wrote: > > =20 > > > On Wed, 18 Mar 2026 18:20:46 +0100 > > > Thomas Wei=C3=9Fschuh wrote: > > > =20 > > > > Some of the nolibc testcases fail on musl. In these cases nolibc mi= rrors > > > > the non-standard behavior of glibc. > > > >=20 > > > > Avoid the failures by only running these testcases on nolibc itself. > > > >=20 > > > > Fixes: a5f00be9b3b0 ("tools/nolibc: Add a simple test for writing t= o a FILE and reading it back") > > > > Fixes: d94393e48c09 ("tools/nolibc/printf: Add support for length m= odifiers tzqL and formats iX") > > > > Fixes: c2d234d3dc56 ("tools/nolibc/printf: Special case 0 and add s= upport for %#x") > > > > Fixes: 63befd993da4 ("tools/nolibc/printf: Add support for zero pad= ding and field precision") > > > > Fixes: d94393e48c09 ("tools/nolibc/printf: Add support for length m= odifiers tzqL and formats iX") > > > > Signed-off-by: Thomas Wei=C3=9Fschuh > > > > --- > > > > I am thinking about folding the printf fixups directly into the ori= ginal > > > > patches. Any objections? > > > > --- > > > > tools/testing/selftests/nolibc/nolibc-test.c | 12 ++++++------ > > > > 1 file changed, 6 insertions(+), 6 deletions(-) > > > >=20 > > > > diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/t= esting/selftests/nolibc/nolibc-test.c > > > > index 180611aabbfb..b03fb9aeb54e 100644 > > > > --- a/tools/testing/selftests/nolibc/nolibc-test.c > > > > +++ b/tools/testing/selftests/nolibc/nolibc-test.c > > > > @@ -867,7 +867,7 @@ int test_file_stream(void) > > > > =20 > > > > errno =3D 0; > > > > r =3D fwrite("foo", 1, 3, f); > > > > - if (r !=3D 0 || errno !=3D EBADF) { > > > > + if (r !=3D 0 || (is_nolibc && errno !=3D EBADF)) { > > > > fclose(f); > > > > return -1; > > > > } > > > > @@ -1824,13 +1824,13 @@ static int run_printf(int min, int max) > > > > CASE_TEST(hex_alt_prec); EXPECT_VFPRINTF(1, "| 0x02|0x03| 0x123|= ", "|%#5.2x|%#04x|%#6.2x|", 2, 3, 0x123); break; > > > > CASE_TEST(hex_0_alt); EXPECT_VFPRINTF(1, "|0|0000| 00|", "|= %#x|%#04x|%#5.2x|", 0, 0, 0); break; > > > > CASE_TEST(pointer); EXPECT_VFPRINTF(1, "0x1", "%p", (void *= ) 0x1); break; > > > > - CASE_TEST(pointer_NULL); EXPECT_VFPRINTF(1, "|(nil)|(nil)|", "|%= p|%.4p|", (void *)0, (void *)0); break; > > > > - CASE_TEST(string_NULL); EXPECT_VFPRINTF(1, "|(null)||(null)|", = "|%s|%.5s|%.6s|", (void *)0, (void *)0, (void *)0); break; > > > > + CASE_TEST(pointer_NULL); EXPECT_VFPRINTF(is_nolibc, "|(nil)|(nil= )|", "|%p|%.4p|", (void *)0, (void *)0); break; > > > > + CASE_TEST(string_NULL); EXPECT_VFPRINTF(is_nolibc, "|(null)||(n= ull)|", "|%s|%.5s|%.6s|", (void *)0, (void *)0, (void *)0); break; > > > > CASE_TEST(percent); EXPECT_VFPRINTF(1, "a%d42%69%", "a%%d%d= %%%d%%", 42, 69); break; > > > > - CASE_TEST(perc_qual); EXPECT_VFPRINTF(1, "a%d2", "a%-14l%d%d"= , 2); break; > > > > - CASE_TEST(invalid); EXPECT_VFPRINTF(1, "a%12yx3%y42%P", "a%= 12yx%d%y%d%P", 3, 42); break; > > > > + CASE_TEST(perc_qual); EXPECT_VFPRINTF(is_nolibc, "a%d2", "a%-= 14l%d%d", 2); break; > > > > + CASE_TEST(invalid); EXPECT_VFPRINTF(is_nolibc, "a%12yx3%y42= %P", "a%12yx%d%y%d%P", 3, 42); break; > > > > CASE_TEST(intmax_max); EXPECT_VFPRINTF(1, "9223372036854775807= ", "%lld", ~0ULL >> 1); break; > > > > - CASE_TEST(intmax_min); EXPECT_VFPRINTF(1, "-922337203685477580= 8", "%Li", (~0ULL >> 1) + 1); break; > > > > + CASE_TEST(intmax_min); EXPECT_VFPRINTF(is_nolibc, "-9223372036= 854775808", "%Li", (~0ULL >> 1) + 1); break; > > > > CASE_TEST(uintmax_max); EXPECT_VFPRINTF(1, "1844674407370955161= 5", "%ju", ~0ULL); break; > > > > CASE_TEST(truncation); EXPECT_VFPRINTF(1, "0123456789012345678= 90123456789", "%s", "012345678901234567890123456789"); break; > > > > CASE_TEST(string_width); EXPECT_VFPRINTF(1, " 1", "%10s"= , "1"); break; =20 > > >=20 > > > Hmmm.... > > > Those are deliberately matching glibc behaviour, at least annotating = that > > > might be useful. > > > Can you think of a way of detecting whether glibc is being used? > > > Even !is_musl might be better than is_nolibc - even even they are the= same. =20 > >=20 > > Thinking more, the nil/null tests want is_nolibc || is_glibc. > > Setting is_glibc might be hard (unless done from the command line). =20 >=20 > We already have a test for __GLIBC__. We can also use that for > is_glibc. >=20 > > The musl people think you don't need to know because their library is c= onformant. > > I found something from someone trying to detect pthread_setname_np(), > > glibc's features.h will set __USE_GNU (and similar) that musl doesn't s= et. > > There might also be issues with bionic and uClibc. =20 >=20 > Why would __GLIBC__ not work? It wasn't mentioned in the stack overflow article I found :-( > > > I'm guessing musl doesn't support 'L' as a length modifier for intege= rs ? =20 >=20 > Yep.=20 >=20 > > > (I'm pretty sure that comes from M$.) Just checked, seems not. So it must be something glibc invented. For some reason L has always been used for 'long double' (M$ accepts l). David > > > The intmax_min test could use %qi instead since that is checking the = value as well. > > > Another test for %Li could be added, I just mixed the formats up a bi= t. =20 >=20 >=20 > Thomas