From nobody Sat Feb 7 20:47:52 2026 Received: from mail-pf1-f180.google.com (mail-pf1-f180.google.com [209.85.210.180]) (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 8A96A35CBA5 for ; Fri, 30 Jan 2026 10:22:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769768553; cv=none; b=DRomrspyIeo1sesLj77M1icQ8P3CDo42MQbvQ1L83CRimCNRMCX9Nef9k8yYN5K3O/0gaRVPhnUr1xOIgp6kUgK6k1HCChX/tCHapA1hos0Hkmmkk9nqqfViZm7Zxft3izSKhw39CrA/uAGDo7Lbdvhtxc2MkGd4Shh9mFLhrRY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769768553; c=relaxed/simple; bh=AcF6Fg3Ymnat8HxxAPStYCzOrYY1ptvmxT8L9V98YkA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=l6PG/tmel8cU/ZEfNU+iQXvhi+4XCUSFaVsa5UkBE25TTe+jv46PaBqS27EUbnin0fp9CuazpsTh18TLIB4VgzU4BdB/2SJwy9X6WuQ/481dMOswFn6LAODfWQ4Lma1DahzbhssiHvas0qeu84MGn7hc04sjmH4bKEe2XR4tMvs= 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=gf27TVbW; arc=none smtp.client-ip=209.85.210.180 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="gf27TVbW" Received: by mail-pf1-f180.google.com with SMTP id d2e1a72fcca58-81f4c0e2b42so1093994b3a.1 for ; Fri, 30 Jan 2026 02:22:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1769768550; x=1770373350; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=+53aZ4Nj1yaeOA5unftPISR2gWN0w2O7aStXoE4adO8=; b=gf27TVbWWMObgFoU3WQURC1bxsuLlfaNmh1HQ7lC4OINP2Lmce+/CpRln31io3akqq FLBMiTS4n03nz7fbkrsCcytpj+0BEmfqoPMgUFuoZooiAIz7K72HgmP15kpO9xYjWYsX 1fO3137q+8gcZgaX/x/K2MadNbrJ4TpKAS0FCdA4sMvaKb9d2Hu0TsP4U5GjwtGFY4Cj pmrxNFOeOTW4MlHIhPiaS+f8LhJrIsg4Nl31VRfuuLYkgyuTFWzwCxpq7Oe0Z9oezKvA PhAry4qehjfoPyNNPATOrlgGayuba5h1IMRZ2J6B++/NlRLx54OEghjRcOyMwriImxdH heAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769768550; x=1770373350; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=+53aZ4Nj1yaeOA5unftPISR2gWN0w2O7aStXoE4adO8=; b=X/gFr2pmSv5d5jo5eEu7xOH82CbhLn4KzhRUQWVYhPsqVGz6CaMXUj6fW8vF/OFCFe I8X5LPIddXCCbTtxi1CryX/S6ev3+Kq8bv6XqzXUGP4jBM1qdu9/uoErN1A+XZukn4tt 8Us1uzC7gKVPw+vbUK5t8APZFh7iKtzpq77IGy+BefqMKFEReR12gjK8Mnqg2az2zde+ B8hDNPf3i/4rPVNovraVAOlyu8EEE4z+APQYPxlQ0LcBT57x1E8p0VD1mF2uS09DF2Gf ofwULfnEF8A0YC/WF9+/DrM5vPUqWTFCrvoRnwWeLGbb69Sm+oXJeppovd1vXQNTgyuK ZYgg== X-Forwarded-Encrypted: i=1; AJvYcCWlfjeopgeUOF0QFxbg1mAvxIPve7iQCIrS9CUdHAaatfHsKz6vQ2YnnVM/dXQtuDvZn4Ps9YByqLYDSVY=@vger.kernel.org X-Gm-Message-State: AOJu0YzplJDwBDOYxysQ90+O/BAkVzLg6Ghb8eT8Ed8zaPE7vS85v4Ox xnHEnC59A6vR8NDdZvjbTf8aOsk0gWRP5pBzneV4yeRXPHasxhDJ5CUC X-Gm-Gg: AZuq6aLCD5BbfbVYeBT1Kt0YZKxt2EInYi9zpHTq2OZVd0j4qRtOjTnE/YsfJhGAMni qNWVUL0RjbM38RsvDExpRTHt7alttKQKhr3j5tztGvOHnqjuZHJHi24SJ+2DH2GnOXzLaZHUYhQ AX0UXqGTjnguvO3BUhX9JGBFrdbf5VBm46ufD2LKexGy9kigW130tnFAERASXJDjdLOn+knNbxm mFFcAGzPtAacW2aDAF9eFl6iacm0j/P0PyfEb4k8dAm7zuLrIzJv7kzzyscNJOBDtX1EDlnRDkg 0Ge6yOGWuh7jlmtf6BmZrDmXRVSbpAwKbpR2Uw1GRLs5TLjX/ZrRsKX74hRKHgyLLT3G76Ui18T RaWPAEvOaljkaYtKyEm4LZqpRzpNMIHNfoKLHRtvJ0LNfRP4ZVMPkClLEsHWFMA24FP3hYnr0xF tiSrERJhV7qpa/8XRb4pTq1LFPL/hh83KxPSJ33EBw9eiCC9QbH32Gyy6rVLstT0C0vc98dbG6P vn8DwRsI3WQCLn0Ldl99Q== X-Received: by 2002:a05:6a20:d524:b0:38b:de3d:d530 with SMTP id adf61e73a8af0-392e016dd8dmr2305227637.72.1769768549787; Fri, 30 Jan 2026 02:22:29 -0800 (PST) Received: from LAPTOP-UKI113GK ([119.123.175.125]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-c6427da8441sm6647206a12.9.2026.01.30.02.22.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Jan 2026 02:22:29 -0800 (PST) From: "licheng.li" To: Willy Tarreau , David Laight Cc: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= , linux-kernel@vger.kernel.org, im.lechain@gmail.com Subject: [PATCH v4 2/2] selftests/nolibc: add tests for printf left alignment and zero padding Date: Fri, 30 Jan 2026 18:22:18 +0800 Message-ID: <20260130102218.1324-3-im.lechain@gmail.com> X-Mailer: git-send-email 2.51.0.windows.1 In-Reply-To: <20260130102218.1324-1-im.lechain@gmail.com> References: <20260130102218.1324-1-im.lechain@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Cheng Li This patch adds validation for the recently added left-alignment ('-') flag in printf(). It ensures that Fields are correctly padded with spaces on the right when the '-' flag is used. Signed-off-by: Cheng Li --- v3 changes: - Removed test case for zero padding that cannot work properly v2 changes: - Added test cases for zero padding (%08d) --- tools/testing/selftests/nolibc/nolibc-test.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/s= elftests/nolibc/nolibc-test.c index 3c5a226dad3a..c11fcf6c5075 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -1723,6 +1723,8 @@ static int run_printf(int min, int max) CASE_TEST(truncation); EXPECT_VFPRINTF(25, "01234567890123456789", "%s= ", "0123456789012345678901234"); break; CASE_TEST(string_width); EXPECT_VFPRINTF(10, " 1", "%10s", "1");= break; CASE_TEST(number_width); EXPECT_VFPRINTF(10, " 1", "%10d", 1); b= reak; + CASE_TEST(number_left); EXPECT_VFPRINTF(10, "|-5 |", "|%-8d|", -5)= ; break; + CASE_TEST(string_align); EXPECT_VFPRINTF(10, "|foo |", "|%-8s|", "fo= o"); break; CASE_TEST(width_trunc); EXPECT_VFPRINTF(25, " ", "%2= 5d", 1); break; CASE_TEST(scanf); EXPECT_ZR(1, test_scanf()); break; CASE_TEST(strerror); EXPECT_ZR(1, test_strerror()); break; --=20 2.52.0