From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 016D8A0548; Fri, 3 Dec 2021 01:07:34 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 16B374271D; Fri, 3 Dec 2021 01:07:02 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 15EF74067B for ; Fri, 3 Dec 2021 01:06:55 +0100 (CET) Received: from linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net (linux.microsoft.com [13.77.154.182]) by linux.microsoft.com (Postfix) with ESMTPSA id 2806020E6932; Thu, 2 Dec 2021 16:06:54 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 2806020E6932 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1638490014; bh=G21A1xUkgd7EjMr79cHDN6COBYFivV6ZRxaSnZ6wmxU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WSa0SJqqiYJMTSdJD31rIkcXnRL5GJnBd9/aCfq5GHLn9BgjfJgiRuikJX/bqvVLh g5gbBpRzElVR2fqa2DnEJuORFde9a+04ZQsVrkOH+sNdZBv15CopvMC6bFrlwHyeEL a9wqApRp8HZFutQxt/2hRLDJyIXgAt9admTd4s/4= From: Jie Zhou To: dev@dpdk.org Cc: dmitry.kozliuk@gmail.com, roretzla@microsoft.com, navasile@linux.microsoft.com, dmitrym@microsoft.com, pallavi.kadam@intel.com, talshn@nvidia.com, thomas@monjalon.net, aconole@redhat.com Subject: [PATCH v11 8/9] app/test: replace .sh script with .py script Date: Thu, 2 Dec 2021 16:06:46 -0800 Message-Id: <1638490007-9939-9-git-send-email-jizh@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1638490007-9939-1-git-send-email-jizh@linux.microsoft.com> References: <1638384245-12587-1-git-send-email-jizh@linux.microsoft.com> <1638490007-9939-1-git-send-email-jizh@linux.microsoft.com> X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org - Add python script to check if system supports hugepages - Remove corresponding .sh script - Replace calling of .sh with corresponding .py in meson.build Signed-off-by: Jie Zhou --- app/test/has-hugepage.sh | 11 ----------- app/test/has_hugepage.py | 26 ++++++++++++++++++++++++++ app/test/meson.build | 2 +- 3 files changed, 27 insertions(+), 12 deletions(-) delete mode 100755 app/test/has-hugepage.sh create mode 100644 app/test/has_hugepage.py diff --git a/app/test/has-hugepage.sh b/app/test/has-hugepage.sh deleted file mode 100755 index d600fad319..0000000000 --- a/app/test/has-hugepage.sh +++ /dev/null @@ -1,11 +0,0 @@ -#! /bin/sh -# SPDX-License-Identifier: BSD-3-Clause -# Copyright 2020 Mellanox Technologies, Ltd - -if [ "$(uname)" = "Linux" ] ; then - cat /proc/sys/vm/nr_hugepages || echo 0 -elif [ "$(uname)" = "FreeBSD" ] ; then - echo 1 # assume FreeBSD always has hugepages -else - echo 0 -fi diff --git a/app/test/has_hugepage.py b/app/test/has_hugepage.py new file mode 100644 index 0000000000..f8e7087d1c --- /dev/null +++ b/app/test/has_hugepage.py @@ -0,0 +1,26 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright (c) 2021 Microsoft Corporation +"""This script checks if the system supports huge pages""" + +import platform +import ctypes + +os_name = platform.system() +if os_name == "Linux": + try: + with open("/proc/sys/vm/nr_hugepages") as file_o: + content = file_o.read() + print(content) + except: + print("0") + +elif os_name == "FreeBSD": + # Assume FreeBSD always has hugepages enabled + print("1") +elif os_name == "Windows": + if ctypes.windll.kernel32.GetLargePageMinimum() > 0: + print("1") + else: + print("0") +else: + print("0") diff --git a/app/test/meson.build b/app/test/meson.build index 2b480adfba..97ee83029e 100644 --- a/app/test/meson.build +++ b/app/test/meson.build @@ -492,7 +492,7 @@ dpdk_test = executable('dpdk-test', driver_install_path), install: true) -has_hugepage = run_command('has-hugepage.sh').stdout().strip() != '0' +has_hugepage = run_command(py3, 'has_hugepage.py').stdout().strip() != '0' message('hugepage availability: @0@'.format(has_hugepage)) # some perf tests (eg: memcpy perf autotest)take very long -- 2.31.0.vfs.0.1