From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 50AABC433EF for ; Mon, 4 Jul 2022 19:32:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232192AbiGDTcs (ORCPT ); Mon, 4 Jul 2022 15:32:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231582AbiGDTcs (ORCPT ); Mon, 4 Jul 2022 15:32:48 -0400 Received: from gnuweeb.org (gnuweeb.org [51.81.211.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 158CFDFD0 for ; Mon, 4 Jul 2022 12:32:48 -0700 (PDT) Received: from integral2.. (unknown [36.81.65.188]) by gnuweeb.org (Postfix) with ESMTPSA id 1B4AF804A1; Mon, 4 Jul 2022 19:32:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1656963167; bh=qeJm1bXOu6klaDCaHOGajmdgN7Yjd2MtzUuZCCYVGsc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mTv+9aheGSutarJf16aR29NoHVhVTgL7zTSSPEv7JOAbilX6q79FMYy5Pk7yq2mEU Xk3SBcjzJMckLAmpGb3T6a95vo7rLJ0jzOuMMyZsOCmlQknG8wd94ereqZHgLh4cfR wromve1xNSBqwGN7GiSx8TQZcwkSVYwCO8lX2BkUVumHgsJ0OHyqLNo7QLqkFqQz69 vizZnmFuEvxdNS6+8vxPcmihll8G3/j1gQ/VQ+Cg8OuGwzkT95VzwB2FfCOXtu1fVb PlMxvwVSgWVoYhGLKLijdI7kMvgrsxfYEC9w1HNIlkVKaTR79+xuYSxV+lyxhRTxcD 6+xcaC1GcLIWA== From: Ammar Faizi To: Jens Axboe Cc: Ammar Faizi , Alviro Iskandar Setiawan , Fernanda Ma'rouf , Hao Xu , Pavel Begunkov , io-uring Mailing List , GNU/Weeb Mailing List Subject: [PATCH liburing v4 08/10] test: Add nolibc test Date: Tue, 5 Jul 2022 02:31:53 +0700 Message-Id: <20220704192827.338771-9-ammar.faizi@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220704192827.338771-1-ammar.faizi@intel.com> References: <20220704192827.338771-1-ammar.faizi@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org From: Ammar Faizi This test is used to test liburing nolibc functionality. The first use case is test get_page_size() function, especially for aarch64 which relies on reading /proc/self/auxv. We don't seem to have a test that tests that function, so let's do it here. We may add more nolibc tests in this file in the future. Signed-off-by: Ammar Faizi --- test/Makefile | 1 + test/nolibc.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 test/nolibc.c diff --git a/test/Makefile b/test/Makefile index 9590e1e..45674c3 100644 --- a/test/Makefile +++ b/test/Makefile @@ -101,6 +101,7 @@ test_srcs := \ mkdir.c \ msg-ring.c \ multicqes_drain.c \ + nolibc.c \ nop-all-sizes.c \ nop.c \ openat2.c \ diff --git a/test/nolibc.c b/test/nolibc.c new file mode 100644 index 0000000..e996f40 --- /dev/null +++ b/test/nolibc.c @@ -0,0 +1,60 @@ +/* SPDX-License-Identifier: MIT */ +/* + * Test liburing nolibc functionality. + * + * Currently, supported architectures are: + * 1) x86 + * 2) x86-64 + * 3) aarch64 + * + */ +#include "helpers.h" + +#if !defined(__x86_64__) && !defined(__i386__) && !defined(__aarch64__) + +/* + * This arch doesn't support nolibc. + */ +int main(void) +{ + return T_EXIT_SKIP; +} + +#else /* #if !defined(__x86_64__) && !defined(__i386__) && !defined(__aarch64__) */ + +#ifndef CONFIG_NOLIBC +#define CONFIG_NOLIBC +#endif + +#include +#include +#include "../src/lib.h" + +static int test_get_page_size(void) +{ + long a, b; + + a = sysconf(_SC_PAGESIZE); + b = get_page_size(); + if (a != b) { + fprintf(stderr, "get_page_size() fails, %ld != %ld", a, b); + return -1; + } + return 0; +} + +int main(int argc, char *argv[]) +{ + int ret; + + if (argc > 1) + return T_EXIT_SKIP; + + ret = test_get_page_size(); + if (ret) + return T_EXIT_FAIL; + + return T_EXIT_PASS; +} + +#endif /* #if !defined(__x86_64__) && !defined(__i386__) && !defined(__aarch64__) */ -- Ammar Faizi