Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp821163rwe; Wed, 31 Aug 2022 11:35:25 -0700 (PDT) X-Google-Smtp-Source: AA6agR55n71bd/djDeamp8DsFbUp+VE7VjiyPzXZZz/Amt7OKXJQD0884hDuZqqaHktRhzZXZjzL X-Received: by 2002:a17:907:2ceb:b0:741:6115:a57 with SMTP id hz11-20020a1709072ceb00b0074161150a57mr13554775ejc.423.1661970925580; Wed, 31 Aug 2022 11:35:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661970925; cv=none; d=google.com; s=arc-20160816; b=gqTvZqg+jLPtHckDli3sYSsx/qs18/JfOJ+zMzNY13k8xnr+qTrUENpmDzTDMXczmi V4xiLXGZDRKDoAm1+6X/z7ecQ+CtXReQoIEVhOmuasURIpMKuhhKBdLgie7kceTLwTbA B0+5wILF/54PDB5t5w4EUhRa0VIOXhVWGO5vvHjAdI1EfIp3HUI4Fu2ObwXziGXwKJGO 3MIz+W5M8QJqnASkAwkV8gnl2LV+MsnLQsjdDlerdIRcei5aAXhlPgOBYMsSybiZbFAJ /+4KU28oPMJqZ8ds3W+aTdsT6gqJACWdarq4PQ3RIbyE2HgAECY+ktv/LXwCvrxgAvme KycQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=z9WcmIgq7hFvWV0Eik4/fDXd8NVQ5735TK3xmbFRYn8=; b=i7w0jm70CL0F/THUl9e8ViyI1Xm1G69qJH99OivDlrwBg42HyeK2KTLraRHKDELuIn PPkXJgnffHmOrEfmKWBNhGvv5M2CltoLXubhFsl5Q6fyytBjDIhJUI2sMu10iqz8CBNI inozuDL800go+AhzQESAz/jZI60CJPSVYgRvRNT8vyGlPP/26Lbtl2sCrc864QqALuXx fISP+Y6jHDAER6s6rjJH7nHLoIdaqhvl1wQ2xMqGLEPOKe5lNSbKlXbjry0cj7C12Ioe n88wM2loh7j8JUxAsdGLjX0OjupkFiykjMPwiYMj/BnfYHs1GUIk1GHj/lYb854SAPfc ke0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="DonB0/CV"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i1-20020a05640242c100b004485508bcfbsi20290edc.30.2022.08.31.11.34.57; Wed, 31 Aug 2022 11:35:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="DonB0/CV"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232842AbiHaS00 (ORCPT + 99 others); Wed, 31 Aug 2022 14:26:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57166 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232756AbiHaSZh (ORCPT ); Wed, 31 Aug 2022 14:25:37 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 409C1FCA2C for ; Wed, 31 Aug 2022 11:21:54 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 0F780B82278 for ; Wed, 31 Aug 2022 18:21:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7D613C43147; Wed, 31 Aug 2022 18:21:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1661970110; bh=Cc1PozE4Kvo2KpHAs/2aNkgoLKg3JAhc3RNFnVGkdlc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DonB0/CVLG3l2uQY+D8qFgEMnR1rFNq4Af5Svwo2EM5tXyCJm4wjRcUw1YLb3b9/L Kti+1NzP41QbSzjO7oqaB54J6asvqX7e0/d3Yp7DAIiFmxs/cGaVBvT3Y3zKQkZFt4 BL1Ak7etLvMHCb8uk84YwcZ2wES2rt/xLqkAvMGu85khdbbprH+JiZgDP2DKD8zGfe YUBXqdCgZ5x0jbxNtd3eIug9+HR6O4I14ajmDQNdS3XAviHQZYiEyRdRGt2I35Z4Qv 4duFMw1hdLZg6oSflkMXGAlh0FoVLTO+UNi5Rd58Nm9fRQX7f668CL5xSwKOtUYjyF 8cSSaj9V/uMAQ== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id DEE785C09C2; Wed, 31 Aug 2022 11:21:49 -0700 (PDT) From: "Paul E. McKenney" To: linux-kernel@vger.kernel.org Cc: gwml@vger.gnuweeb.org, kernel-team@fb.com, w@lwt.eu, Willy Tarreau , "Paul E . McKenney" Subject: [PATCH nolibc 07/18] selftests/nolibc: add a few tests for some libc functions Date: Wed, 31 Aug 2022 11:21:37 -0700 Message-Id: <20220831182148.2698489-9-paulmck@kernel.org> X-Mailer: git-send-email 2.31.1.189.g2e36527f23 In-Reply-To: <20220831182113.GA2697286@paulmck-ThinkPad-P17-Gen-1> References: <20220831182113.GA2697286@paulmck-ThinkPad-P17-Gen-1> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Willy Tarreau The test series called "stdlib" covers some libc functions (string, stdlib etc). By default they are automatically run after "syscall" but may be requested in argument or in variable NOLIBC_TEST. Signed-off-by: Willy Tarreau Signed-off-by: Paul E. McKenney --- tools/testing/selftests/nolibc/nolibc-test.c | 35 ++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index dc87832912ce4..b928f099431f7 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -496,11 +496,46 @@ int run_syscall(int min, int max) return ret; } +int run_stdlib(int min, int max) +{ + int test; + int tmp; + int ret = 0; + void *p1, *p2; + + for (test = min; test >= 0 && test <= max; test++) { + int llen = 0; // line length + + /* avoid leaving empty lines below, this will insert holes into + * test numbers. + */ + switch (test + __LINE__ + 1) { + CASE_TEST(getenv_TERM); EXPECT_STRNZ(1, getenv("TERM")); break; + CASE_TEST(getenv_blah); EXPECT_STRZR(1, getenv("blah")); break; + CASE_TEST(setcmp_blah_blah); EXPECT_EQ(1, strcmp("blah", "blah"), 0); break; + CASE_TEST(setcmp_blah_blah2); EXPECT_NE(1, strcmp("blah", "blah2"), 0); break; + CASE_TEST(setncmp_blah_blah); EXPECT_EQ(1, strncmp("blah", "blah", 10), 0); break; + CASE_TEST(setncmp_blah_blah4); EXPECT_EQ(1, strncmp("blah", "blah4", 4), 0); break; + CASE_TEST(setncmp_blah_blah5); EXPECT_NE(1, strncmp("blah", "blah5", 5), 0); break; + CASE_TEST(setncmp_blah_blah6); EXPECT_NE(1, strncmp("blah", "blah6", 6), 0); break; + CASE_TEST(strchr_foobar_o); EXPECT_STREQ(1, strchr("foobar", 'o'), "oobar"); break; + 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; + case __LINE__: + return ret; /* must be last */ + /* note: do not set any defaults so as to permit holes above */ + } + } + return ret; +} + /* This is the definition of known test names, with their functions */ static struct test test_names[] = { /* add new tests here */ { .name = "syscall", .func = run_syscall }, + { .name = "stdlib", .func = run_stdlib }, { 0 } }; -- 2.31.1.189.g2e36527f23