Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp7417465rwl; Tue, 10 Jan 2023 00:03:25 -0800 (PST) X-Google-Smtp-Source: AMrXdXvF43icCDZ94vZ1/k99+eU6gK0tQwcyl+5IAN7MnMpfwkccdvBQ3Nb0rCwOZhARhZHTImgQ X-Received: by 2002:a05:6a00:d4e:b0:581:a2b6:df19 with SMTP id n14-20020a056a000d4e00b00581a2b6df19mr41401102pfv.14.1673337803944; Tue, 10 Jan 2023 00:03:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673337803; cv=none; d=google.com; s=arc-20160816; b=YpccD9UsvNN0FW+3cSp4vABz4B/DrJrMpcIoJYWorS/AmmiMk2SborZrdlT8VE/6z3 U2SAoTk+C4bkfgtIAkSB/h7iD+5P4OWDKnNl0Po4tR1WhvpeAr3NJVSU654TQkgL2v+d Hp7Chou1PJSJnthGH4r7adXTAAjMi0GiJtzvXzIva1UnlaDWtrLlMm35SdJy95IIW4fO h33ABgvZQNwA5ZH8FSfiydqeHcvyXR+l5Vrm051iiojv0cUp+Ji1cVG2hbxgUFUP5kvD LJmplUuhvCyNrExTDCer0VjqNSOTtaajRPFH9zi8enYbx1mhGa9EtTd78vx7Y9XiGyys uLMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=7U0jI/5IuSaYMK/7UmO/O/O6wflQzjjy3BDv9jXmwVI=; b=peekN224KBY3YyDWdEczDR6rf4R1OIAwCOyzyX0s3F5Rcll9fTlZNCGQ7GeVSdVaah K8w5teMF0Mivt+aiKjtYl5W40o1GGYZto2ezPMaHeuQ2CzUUZlyW6No9xtIV0XZxN1/U uxdShbzd0kGP2fbFVE5rIsBhgur+60mEwnZDVn1xVzjbvBChiNcpEtAnp7Tack/tUKyb fahRBUIREWRT8B1ilYiT5LiMLiOaoBDLWtQtX/dhNNkLKjI2tS4NF3+Hk+h7LS110/mu bPsO19pIf1XzDUrR93AhCi10uvL0bkH5INXcgFPAMMATbD0m5ci2hCPEkAiP8gPohcho jeJQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g22-20020a056a000b9600b00588f646fb44si3639894pfj.242.2023.01.10.00.03.17; Tue, 10 Jan 2023 00:03:23 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237219AbjAJH2n (ORCPT + 53 others); Tue, 10 Jan 2023 02:28:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44150 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235378AbjAJH17 (ORCPT ); Tue, 10 Jan 2023 02:27:59 -0500 Received: from 1wt.eu (wtarreau.pck.nerim.net [62.212.114.60]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C68B21AA2E for ; Mon, 9 Jan 2023 23:26:14 -0800 (PST) Received: (from willy@localhost) by pcw.home.local (8.15.2/8.15.2/Submit) id 30A7OeUi003949; Tue, 10 Jan 2023 08:24:40 +0100 From: Willy Tarreau To: "Paul E. McKenney" Cc: linux-kernel@vger.kernel.org, Ammar Faizi , Willy Tarreau Subject: [PATCH v2 22/22] selftests/nolibc: Add `getpagesize(2)` selftest Date: Tue, 10 Jan 2023 08:24:34 +0100 Message-Id: <20230110072434.3863-23-w@1wt.eu> X-Mailer: git-send-email 2.17.5 In-Reply-To: <20230110072434.3863-1-w@1wt.eu> References: <20230110072434.3863-1-w@1wt.eu> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, SPF_PASS 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: Ammar Faizi Test the getpagesize() function. Make sure it returns the correct value. Signed-off-by: Ammar Faizi Signed-off-by: Willy Tarreau --- tools/testing/selftests/nolibc/nolibc-test.c | 30 ++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index f14f5076fb6d..c4a0c915139c 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -442,6 +442,35 @@ int test_getdents64(const char *dir) return ret; } +static int test_getpagesize(void) +{ + long x = getpagesize(); + int c; + + if (x < 0) + return x; + +#if defined(__x86_64__) || defined(__i386__) || defined(__i486__) || defined(__i586__) || defined(__i686__) + /* + * x86 family is always 4K page. + */ + c = (x == 4096); +#elif defined(__aarch64__) + /* + * Linux aarch64 supports three values of page size: 4K, 16K, and 64K + * which are selected at kernel compilation time. + */ + c = (x == 4096 || x == (16 * 1024) || x == (64 * 1024)); +#else + /* + * Assuming other architectures must have at least 4K page. + */ + c = (x >= 4096); +#endif + + return !c; +} + /* Run syscall tests between IDs and . * Return 0 on success, non-zero on failure. */ @@ -502,6 +531,7 @@ int run_syscall(int min, int max) CASE_TEST(gettimeofday_bad2); EXPECT_SYSER(1, gettimeofday(NULL, (void *)1), -1, EFAULT); break; CASE_TEST(gettimeofday_bad2); EXPECT_SYSER(1, gettimeofday(NULL, (void *)1), -1, EFAULT); break; #endif + CASE_TEST(getpagesize); EXPECT_SYSZR(1, test_getpagesize()); break; CASE_TEST(ioctl_tiocinq); EXPECT_SYSZR(1, ioctl(0, TIOCINQ, &tmp)); break; CASE_TEST(ioctl_tiocinq); EXPECT_SYSZR(1, ioctl(0, TIOCINQ, &tmp)); break; CASE_TEST(link_root1); EXPECT_SYSER(1, link("/", "/"), -1, EEXIST); break; -- 2.17.5