Received: by 2002:ab2:3c46:0:b0:1f5:f2ab:c469 with SMTP id x6csp193598lqf; Fri, 26 Apr 2024 04:09:43 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUYY/XMUBChzdXaRmawgXMplTjHqAHtBj17koljwZDVM7RLaxZPeBc0iTmJovbsoEKzUvJ3jOirF5idEJNrR4NUmzzZvfyBHlzCHhtrMA== X-Google-Smtp-Source: AGHT+IGIWK0aCUj5opq6QOy/SzRnfO/EUoK7qlvbXrpuCEnE5mvcPm0scL29ZhIgi0ojTLqTaxiG X-Received: by 2002:a17:90a:840c:b0:2a2:71c7:7e26 with SMTP id j12-20020a17090a840c00b002a271c77e26mr2024658pjn.28.1714129783640; Fri, 26 Apr 2024 04:09:43 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714129783; cv=pass; d=google.com; s=arc-20160816; b=ivaBqqhxVxn/okzWXazhh5GWVd6qz89QVQpY9Yt1y5bK8DrIKTuOTlCoyhcD424w/2 5mjwzycW/sEmyZ209HWmCyROow8VRgG2h1eLEyrjRA+4GmcUhTfIq/O0m3Kbrfk/S+fz J0P+QKbaO3j7GG1tDCJ7fAqVrDWNI2OiqBBReSmqVpzGUGAKa3JCrppyYD5/hB3Z4GzO WQSP1BtR7i+7N+jVTLue8w8rCgQvZpIlpcYHglGSCaOG7Sy6kdWZxaRqrMYiRWUzCzSx 4ltJaPEVp9f3F4KIHpSzHOkPfZLVpFox91oGziNcVyXWjWubbz8/hM2mU6+Cm/qNoEi3 v7vg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=ly4E9MDD89nxskV7XJm+cVvMID7rVQwujTxZOgSK7C4=; fh=lrawtlvYUyTnD3YboMckJjmalpw48Rm60lz21Jj4CJE=; b=z5GTw7vwbLDXCf7y79jrmz6i/Wbv/1483S9XSmf1z4MmG/aInFyGtMEemOzSJsXkHp 26OB9ej1Ugu9G9dJtDZw2ZnPTIT71bm9HnfskneTrqp+2ZnACLfD2w6NFUxllwHMK/ll 5oaxkPHCFkeSnMppZ85lkd8cSY0hfTUd83jZA0tGchk+agxkCLylm258ELA/HYjtYQpZ b6p/pVn0pJ59orZTZC2ucHGD5cbe/TuSrA0ojF99vXX0UOWG2ZOH/c+82mHvHPJddcrY 1lFrDQQe0QrQ5zMjf5Q5iUAGsfCFKQ5rAtUO9oUlc+SLu5GvlSkNqGKBxS8H0CyoWjEq avKA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@weissschuh.net header.s=mail header.b=WUOSdkjH; arc=pass (i=1 spf=pass spfdomain=weissschuh.net dkim=pass dkdomain=weissschuh.net); spf=pass (google.com: domain of linux-kernel+bounces-159924-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-159924-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id br11-20020a17090b0f0b00b002ad02baafb6si10999535pjb.103.2024.04.26.04.09.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Apr 2024 04:09:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-159924-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@weissschuh.net header.s=mail header.b=WUOSdkjH; arc=pass (i=1 spf=pass spfdomain=weissschuh.net dkim=pass dkdomain=weissschuh.net); spf=pass (google.com: domain of linux-kernel+bounces-159924-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-159924-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id ABC29283EC7 for ; Fri, 26 Apr 2024 11:09:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 635AE145358; Fri, 26 Apr 2024 11:09:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="WUOSdkjH" Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (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 EC91414037C; Fri, 26 Apr 2024 11:09:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714129765; cv=none; b=hS8BcLFVC5oPc8D78FCBHMXaAWJymcv37pmNSZGFI8DDOfuXihVF/LnrjWChC4bjNsAP4i8w+l4dSwl4Um0BmfXykM7Q1Cc2xE/pYEOpztr7dNxPo8frk46UBuWbQG5b2foI4vrf4iIhGDmkow0ROpiNmE2ldW9hlkkQahOIA3s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714129765; c=relaxed/simple; bh=POPoBWA0zb+CZxTZKQlvH0jHEDfJwJeLYQ/q42Q4tds=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=WEbDIRwkr5rP0HWZ0piRGFG7TEABSSxa55ssuWj+45EVlfn32slVfWq7NvL2rj1LFf2RG82/kij2EjeDwL0lQJGFSKLC3hSac1Fp2W/DTi7r3+G2XrVHccBI9Bt66/NEZDurBx8w7nzmkxXkDwvA8r6t5Gp0hLOGhDxKsKKenIo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=WUOSdkjH; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1714129754; bh=POPoBWA0zb+CZxTZKQlvH0jHEDfJwJeLYQ/q42Q4tds=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=WUOSdkjHWxDPd0U/iFslTgTmwnqkN7oHeNmu3TUfmmD2kXPvfdpXSBJxbnG0gUhO5 4Iy959TvW/Ut+XzIsvyj9xn4C0jNCTNcXVkDLA/9xHmYAnbbAST+VLxuIKfyYEGzlU zyQkCmbE3vy1cTKMa+IRIzPYbPDasA2Q18AN+Y8w= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Fri, 26 Apr 2024 13:08:56 +0200 Subject: [PATCH 1/3] selftests/nolibc: introduce condition to run tests only on nolibc 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: 8bit Message-Id: <20240426-nolibc-strerror-v1-1-76a4c9c5271d@weissschuh.net> References: <20240426-nolibc-strerror-v1-0-76a4c9c5271d@weissschuh.net> In-Reply-To: <20240426-nolibc-strerror-v1-0-76a4c9c5271d@weissschuh.net> To: Willy Tarreau , Shuah Khan Cc: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1714129753; l=3870; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=POPoBWA0zb+CZxTZKQlvH0jHEDfJwJeLYQ/q42Q4tds=; b=HuIlN6rPjhA6VH5rmE3ZlIQZCJFQgnuMWRUt+OWRMPAohYcsyfBBDb6hKa5IVXqkaXqRkW+Wz vsK3AM1Q48vCWVLkDrINm3uQTA7rjI5jkheKN/tqvgEKhiWxoHlDZ6C X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= Some tests only make sense on nolibc. To avoid gaps in the test numbers do to inline "#ifdef NOLIBC", add a condition to formally skip these tests. Signed-off-by: Thomas Weißschuh --- tools/testing/selftests/nolibc/nolibc-test.c | 32 +++++++++++++++++----------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index 6161bd57a0c9..dadc9b8f2727 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -64,6 +64,14 @@ static const char *argv0; /* will be used by constructor tests */ static int constructor_test_value; +static const int is_nolibc = +#ifdef NOLIBC + 1 +#else + 0 +#endif +; + /* definition of a series of tests */ struct test { const char *name; /* test name */ @@ -1125,19 +1133,17 @@ int run_stdlib(int min, int max) CASE_TEST(strchr_foobar_z); EXPECT_STRZR(1, strchr("foobar", 'z')); break; CASE_TEST(strrchr_foobar_o); EXPECT_STREQ(1, strrchr("foobar", 'o'), "obar"); break; CASE_TEST(strrchr_foobar_z); EXPECT_STRZR(1, strrchr("foobar", 'z')); break; -#ifdef NOLIBC - CASE_TEST(strlcat_0); EXPECT_STRBUFEQ(1, strlcat(buf, "bar", 0), buf, 3, "test"); break; - CASE_TEST(strlcat_1); EXPECT_STRBUFEQ(1, strlcat(buf, "bar", 1), buf, 4, "test"); break; - CASE_TEST(strlcat_5); EXPECT_STRBUFEQ(1, strlcat(buf, "bar", 5), buf, 7, "test"); break; - CASE_TEST(strlcat_6); EXPECT_STRBUFEQ(1, strlcat(buf, "bar", 6), buf, 7, "testb"); break; - CASE_TEST(strlcat_7); EXPECT_STRBUFEQ(1, strlcat(buf, "bar", 7), buf, 7, "testba"); break; - CASE_TEST(strlcat_8); EXPECT_STRBUFEQ(1, strlcat(buf, "bar", 8), buf, 7, "testbar"); break; - CASE_TEST(strlcpy_0); EXPECT_STRBUFEQ(1, strlcpy(buf, "bar", 0), buf, 3, "test"); break; - CASE_TEST(strlcpy_1); EXPECT_STRBUFEQ(1, strlcpy(buf, "bar", 1), buf, 3, ""); break; - CASE_TEST(strlcpy_2); EXPECT_STRBUFEQ(1, strlcpy(buf, "bar", 2), buf, 3, "b"); break; - CASE_TEST(strlcpy_3); EXPECT_STRBUFEQ(1, strlcpy(buf, "bar", 3), buf, 3, "ba"); break; - CASE_TEST(strlcpy_4); EXPECT_STRBUFEQ(1, strlcpy(buf, "bar", 4), buf, 3, "bar"); break; -#endif + CASE_TEST(strlcat_0); EXPECT_STRBUFEQ(is_nolibc, strlcat(buf, "bar", 0), buf, 3, "test"); break; + CASE_TEST(strlcat_1); EXPECT_STRBUFEQ(is_nolibc, strlcat(buf, "bar", 1), buf, 4, "test"); break; + CASE_TEST(strlcat_5); EXPECT_STRBUFEQ(is_nolibc, strlcat(buf, "bar", 5), buf, 7, "test"); break; + CASE_TEST(strlcat_6); EXPECT_STRBUFEQ(is_nolibc, strlcat(buf, "bar", 6), buf, 7, "testb"); break; + CASE_TEST(strlcat_7); EXPECT_STRBUFEQ(is_nolibc, strlcat(buf, "bar", 7), buf, 7, "testba"); break; + CASE_TEST(strlcat_8); EXPECT_STRBUFEQ(is_nolibc, strlcat(buf, "bar", 8), buf, 7, "testbar"); break; + CASE_TEST(strlcpy_0); EXPECT_STRBUFEQ(is_nolibc, strlcpy(buf, "bar", 0), buf, 3, "test"); break; + CASE_TEST(strlcpy_1); EXPECT_STRBUFEQ(is_nolibc, strlcpy(buf, "bar", 1), buf, 3, ""); break; + CASE_TEST(strlcpy_2); EXPECT_STRBUFEQ(is_nolibc, strlcpy(buf, "bar", 2), buf, 3, "b"); break; + CASE_TEST(strlcpy_3); EXPECT_STRBUFEQ(is_nolibc, strlcpy(buf, "bar", 3), buf, 3, "ba"); break; + CASE_TEST(strlcpy_4); EXPECT_STRBUFEQ(is_nolibc, strlcpy(buf, "bar", 4), buf, 3, "bar"); break; CASE_TEST(memcmp_20_20); EXPECT_EQ(1, memcmp("aaa\x20", "aaa\x20", 4), 0); break; CASE_TEST(memcmp_20_60); EXPECT_LT(1, memcmp("aaa\x20", "aaa\x60", 4), 0); break; CASE_TEST(memcmp_60_20); EXPECT_GT(1, memcmp("aaa\x60", "aaa\x20", 4), 0); break; -- 2.44.0