test: replace shell script with Python

- 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 <jizh@linux.microsoft.com>
Acked-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
This commit is contained in:
Jie Zhou 2022-01-25 21:10:43 -08:00 committed by Thomas Monjalon
parent 3c60274c09
commit 9713eae1d8
4 changed files with 28 additions and 13 deletions

View File

@ -1638,7 +1638,7 @@ Test Applications
Unit tests framework
F: app/test/commands.c
F: app/test/has-hugepage.sh
F: app/test/has_hugepage.py
F: app/test/packet_burst_generator.c
F: app/test/packet_burst_generator.h
F: app/test/process.h

View File

@ -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

26
app/test/has_hugepage.py Normal file
View File

@ -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")

View File

@ -457,7 +457,7 @@ dpdk_test = executable('dpdk-test',
driver_install_path),
install: true)
has_hugepage = run_command('has-hugepage.sh', check: true).stdout().strip() != '0'
has_hugepage = run_command(py3, 'has_hugepage.py', check: true).stdout().strip() != '0'
message('hugepage availability: @0@'.format(has_hugepage))
# some perf tests (eg: memcpy perf autotest)take very long