update testcase for testsuite ndctl-devel

This commit is contained in:
2026-04-21 08:32:43 +08:00
parent 0d89cd2955
commit c313ea44d9
8 changed files with 0 additions and 578 deletions

View File

@@ -2,37 +2,9 @@
"path": "$OET_PATH/testcases/function_test/pkg_test/ndctl/ndctl-devel",
"machine num": 1,
"cases": [
{
"name": "test_ndctl-devel_function_install",
"desc": "Test the installation of ndctl-devel package"
},
{
"name": "test_ndctl-devel_function_uninstall",
"desc": "Test the uninstallation of ndctl-devel package"
},
{
"name": "test_ndctl-devel_function_lib",
"desc": "Test the basic library functionality of ndctl-devel"
},
{
"name": "test_ndctl-devel_function_install_check",
"desc": "Check if ndctl-devel package is installed on the system"
},
{
"name": "test_ndctl-devel_function_header_files",
"desc": "Verify the presence of essential C header files (e.g., ndctl/libndctl.h)"
},
{
"name": "test_ndctl-devel_function_lib_pkgconfig",
"desc": "Test pkg-config can find the ndctl development library"
},
{
"name": "test_ndctl-devel_function_compile_link",
"desc": "Compile and link a simple test program using the ndctl library"
},
{
"name": "test_ndctl-devel_function_man_pages",
"desc": "Check the availability of man pages for library functions"
}
]
}

View File

@@ -1,112 +0,0 @@
#!/usr/bin/bash
# Copyright (c) 2024 ISCAS .ALL rights reserved.
# This program is licensed under Mulan PSL v2.
# You can use it according to the terms and conditions of the Mulan PSL v2.
# http://license.coscl.org.cn/MulanPSL2
# THIS PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
# See the Mulan PSL v2 for more details.
# #############################################
# @Author : honghua
# @Contact : honghua@iscas.ac.cn
# @Date : 2026-03-21
# @License : Mulan PSL v2
# @Desc : Compile and link a simple test program using the ndctl library
# ############################################
source "$OET_PATH/libs/locallibs/common_lib.sh"
function run_test() {
set -e
LOG_INFO "开始测试使用ndctl库编译和链接简单测试程序"
# 定义软件包名称
PKG_NAME="ndctl-devel"
# 步骤1检查yum源中是否存在ndctl-devel软件包
LOG_INFO "步骤1检查yum源中是否存在${PKG_NAME}软件包"
if ! dnf list available "${PKG_NAME}" &>/dev/null; then
LOG_ERROR "yum源中未找到${PKG_NAME}软件包"
exit 255
fi
# 步骤2检查系统是否已安装ndctl-devel
LOG_INFO "步骤2检查系统是否已安装${PKG_NAME}"
if rpm -q "${PKG_NAME}" &>/dev/null; then
LOG_INFO "系统已安装${PKG_NAME},测试结束后将保持安装状态"
ALREADY_INSTALLED=1
else
LOG_INFO "系统未安装${PKG_NAME},将在测试步骤中安装"
ALREADY_INSTALLED=0
fi
# 步骤3如果未安装则安装ndctl-devel
if [ ${ALREADY_INSTALLED} -eq 0 ]; then
LOG_INFO "步骤3安装${PKG_NAME}软件包"
dnf install -y "${PKG_NAME}"
CHECK_RESULT $? 0 0 "安装${PKG_NAME}失败"
fi
# 步骤4检查ndctl库的头文件和库文件是否存在
LOG_INFO "步骤4检查ndctl库的头文件和库文件"
if [ ! -f /usr/include/ndctl.h ]; then
LOG_ERROR "ndctl头文件未找到"
exit 255
fi
if [ ! -f /usr/lib64/libndctl.so ] && [ ! -f /usr/lib/libndctl.so ]; then
LOG_ERROR "ndctl库文件未找到"
exit 255
fi
# 步骤5编写简单的测试程序
LOG_INFO "步骤5编写简单的测试程序"
TEST_PROGRAM="test_ndctl.c"
cat > "${TEST_PROGRAM}" << "EOF"
#include <stdio.h>
#include <ndctl/libndctl.h>
int main() {
struct ndctl_ctx *ctx;
int rc = ndctl_new(&ctx);
if (rc < 0) {
printf("Failed to create ndctl context\n");
return 1;
}
printf("Successfully created ndctl context\n");
ndctl_unref(ctx);
return 0;
}
EOF
CHECK_RESULT $? 0 0 "创建测试程序失败"
# 步骤6编译测试程序
LOG_INFO "步骤6编译测试程序"
gcc -o test_ndctl_program "${TEST_PROGRAM}" -lndctl
CHECK_RESULT $? 0 0 "编译测试程序失败"
# 步骤7运行测试程序
LOG_INFO "步骤7运行测试程序"
./test_ndctl_program
CHECK_RESULT $? 0 0 "运行测试程序失败"
# 步骤8清理临时文件
LOG_INFO "步骤8清理临时文件"
rm -f "${TEST_PROGRAM}" test_ndctl_program
# 步骤9如果测试前未安装则卸载ndctl-devel
if [ ${ALREADY_INSTALLED} -eq 0 ]; then
LOG_INFO "步骤9卸载${PKG_NAME}软件包"
dnf remove -y "${PKG_NAME}"
CHECK_RESULT $? 0 0 "卸载${PKG_NAME}失败"
else
LOG_INFO "步骤9保持${PKG_NAME}安装状态"
fi
LOG_INFO "测试完成使用ndctl库编译和链接简单测试程序成功"
}
main "$@"

View File

@@ -1,74 +0,0 @@
#!/usr/bin/bash
# Copyright (c) 2024 ISCAS .ALL rights reserved.
# This program is licensed under Mulan PSL v2.
# You can use it according to the terms and conditions of the Mulan PSL v2.
# http://license.coscl.org.cn/MulanPSL2
# THIS PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
# See the Mulan PSL v2 for more details.
# #############################################
# @Author : honghua
# @Contact : honghua@iscas.ac.cn
# @Date : 2026-03-21
# @License : Mulan PSL v2
# @Desc : Verify the presence of essential C header files (e.g., ndctl/libndctl.h)
# ############################################
source "$OET_PATH/libs/locallibs/common_lib.sh"
function run_test() {
LOG_INFO "开始测试验证ndctl开发包是否包含必要的C头文件如ndctl/libndctl.h"
# 检查ndctl-devel软件包是否已安装
LOG_INFO "步骤1检查ndctl-devel软件包是否已安装"
if rpm -q ndctl-devel &>/dev/null; then
LOG_INFO "ndctl-devel软件包已安装标记为需要保持安装状态"
KEEP_INSTALLED=1
else
LOG_INFO "ndctl-devel软件包未安装标记为需要安装"
KEEP_INSTALLED=0
fi
# 检查yum源中是否有ndctl-devel软件包
LOG_INFO "步骤2检查yum源中是否有ndctl-devel软件包"
if ! dnf list available ndctl-devel &>/dev/null; then
LOG_ERROR "yum源中未找到ndctl-devel软件包"
exit 255
fi
# 如果未安装则安装ndctl-devel软件包
if [ $KEEP_INSTALLED -eq 0 ]; then
LOG_INFO "步骤3安装ndctl-devel软件包"
dnf install -y ndctl-devel
CHECK_RESULT $? 0 0 "安装ndctl-devel软件包失败"
fi
# 验证头文件是否存在
LOG_INFO "步骤4验证头文件ndctl/libndctl.h是否存在"
if [ -f /usr/include/ndctl/libndctl.h ]; then
LOG_INFO "头文件ndctl/libndctl.h存在"
else
LOG_ERROR "头文件ndctl/libndctl.h不存在"
if [ $KEEP_INSTALLED -eq 0 ]; then
LOG_INFO "清理环境卸载ndctl-devel软件包"
dnf remove -y ndctl-devel
fi
exit 1
fi
# 清理环境如果测试前未安装则卸载ndctl-devel软件包
if [ $KEEP_INSTALLED -eq 0 ]; then
LOG_INFO "步骤5清理环境卸载ndctl-devel软件包"
dnf remove -y ndctl-devel
CHECK_RESULT $? 0 0 "卸载ndctl-devel软件包失败"
else
LOG_INFO "步骤5保持ndctl-devel软件包安装状态无需卸载"
fi
LOG_INFO "测试完成ndctl开发包包含必要的C头文件"
}
main "$@"

View File

@@ -1,65 +0,0 @@
#!/usr/bin/bash
# Copyright (c) 2024 ISCAS .ALL rights reserved.
# This program is licensed under Mulan PSL v2.
# You can use it according to the terms and conditions of the Mulan PSL v2.
# http://license.coscl.org.cn/MulanPSL2
# THIS PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
# See the Mulan PSL v2 for more details.
# #############################################
# @Author : honghua
# @Contact : honghua@iscas.ac.cn
# @Date : 2025-09-12
# @License : Mulan PSL v2
# @Desc : Test the installation of ndctl-devel package
# ############################################
source "$OET_PATH/libs/locallibs/common_lib.sh"
function run_test() {
# 检查ndctl-devel软件包是否已安装
LOG_INFO "检查ndctl-devel软件包是否已安装"
rpm -q ndctl-devel > /dev/null 2>&1
if [ $? -eq 0 ]; then
LOG_INFO "ndctl-devel软件包已安装脚本结束后保持安装状态"
INSTALLED=1
else
LOG_INFO "ndctl-devel软件包未安装将在测试后卸载"
INSTALLED=0
fi
# 检查yum源中是否存在ndctl-devel软件包
LOG_INFO "检查yum源中是否存在ndctl-devel软件包"
dnf list available ndctl-devel > /dev/null 2>&1
CHECK_RESULT $? 0 255 "yum源中不存在ndctl-devel软件包"
# 安装ndctl-devel软件包
LOG_INFO "安装ndctl-devel软件包"
dnf install -y ndctl-devel > /dev/null 2>&1
CHECK_RESULT $? 0 0 "安装ndctl-devel软件包失败"
# 验证ndctl-devel软件包是否成功安装
LOG_INFO "验证ndctl-devel软件包是否成功安装"
rpm -q ndctl-devel > /dev/null 2>&1
CHECK_RESULT $? 0 0 "ndctl-devel软件包未成功安装"
# 测试完成后根据初始状态决定是否卸载ndctl-devel软件包
if [ $INSTALLED -eq 0 ]; then
LOG_INFO "卸载ndctl-devel软件包"
dnf remove -y ndctl-devel > /dev/null 2>&1
CHECK_RESULT $? 0 0 "卸载ndctl-devel软件包失败"
# 验证ndctl-devel软件包是否成功卸载
LOG_INFO "验证ndctl-devel软件包是否成功卸载"
rpm -q ndctl-devel > /dev/null 2>&1
CHECK_RESULT $? 1 0 "ndctl-devel软件包未成功卸载"
fi
LOG_INFO "测试完成,环境已恢复"
}
main "$@"

View File

@@ -1,76 +0,0 @@
#!/usr/bin/bash
# Copyright (c) 2024 ISCAS .ALL rights reserved.
# This program is licensed under Mulan PSL v2.
# You can use it according to the terms and conditions of the Mulan PSL v2.
# http://license.coscl.org.cn/MulanPSL2
# THIS PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
# See the Mulan PSL v2 for more details.
# #############################################
# @Author : honghua
# @Contact : honghua@iscas.ac.cn
# @Date : 2026-03-21
# @License : Mulan PSL v2
# @Desc : Check if ndctl-devel package is installed on the system
# ############################################
source "$OET_PATH/libs/locallibs/common_lib.sh"
function run_test() {
set -e
LOG_INFO "检查系统是否已安装ndctl-devel软件包"
# 检查ndctl-devel是否已安装
if rpm -q ndctl-devel > /dev/null 2>&1; then
LOG_INFO "ndctl-devel软件包已安装跳过安装步骤"
INSTALLED_BEFORE=true
else
LOG_INFO "ndctl-devel软件包未安装将进行安装测试"
INSTALLED_BEFORE=false
fi
# 检查yum源中是否有ndctl-devel软件包
LOG_INFO "检查yum源中是否存在ndctl-devel软件包"
if ! dnf list available ndctl-devel > /dev/null 2>&1; then
LOG_ERROR "yum源中未找到ndctl-devel软件包"
exit 255
fi
# 如果之前未安装则安装ndctl-devel
if [ "$INSTALLED_BEFORE" = "false" ]; then
LOG_INFO "开始安装ndctl-devel软件包"
dnf install -y ndctl-devel
CHECK_RESULT $? 0 0 "安装ndctl-devel软件包失败"
LOG_INFO "ndctl-devel软件包安装成功"
fi
# 检查ndctl命令是否可用
LOG_INFO "检查ndctl命令是否可用"
if ! command -v ndctl > /dev/null 2>&1; then
LOG_ERROR "ndctl命令未找到"
exit 255
fi
# 测试ndctl命令的基本功能
LOG_INFO "测试ndctl命令的基本功能"
ndctl --version
CHECK_RESULT $? 0 0 "ndctl命令执行失败"
LOG_INFO "ndctl-devel软件包安装检查完成"
# 环境恢复如果之前未安装则卸载ndctl-devel
if [ "$INSTALLED_BEFORE" = "false" ]; then
LOG_INFO "清理环境卸载ndctl-devel软件包"
dnf remove -y ndctl-devel
CHECK_RESULT $? 0 0 "卸载ndctl-devel软件包失败"
LOG_INFO "ndctl-devel软件包已卸载环境已恢复"
else
LOG_INFO "ndctl-devel软件包已安装保持安装状态"
fi
}
main "$@"

View File

@@ -1,81 +0,0 @@
#!/usr/bin/bash
# Copyright (c) 2024 ISCAS .ALL rights reserved.
# This program is licensed under Mulan PSL v2.
# You can use it according to the terms and conditions of the Mulan PSL v2.
# http://license.coscl.org.cn/MulanPSL2
# THIS PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
# See the Mulan PSL v2 for more details.
# #############################################
# @Author : honghua
# @Contact : honghua@iscas.ac.cn
# @Date : 2026-03-21
# @License : Mulan PSL v2
# @Desc : Test pkg-config can find the ndctl development library
# ############################################
source "$OET_PATH/libs/locallibs/common_lib.sh"
function run_test() {
LOG_INFO "开始测试Test pkg-config can find the ndctl development library"
LOG_INFO "步骤1检查yum源中是否存在ndctl-devel软件包"
dnf list ndctl-devel &>/dev/null
CHECK_RESULT $? 0 0 "yum源中不存在ndctl-devel软件包退出测试"
if [ $? -eq 255 ]; then
LOG_ERROR "yum源中不存在ndctl-devel软件包退出测试"
exit 255
fi
LOG_INFO "步骤2检查系统是否已安装ndctl-devel软件包"
if rpm -q ndctl-devel &>/dev/null; then
LOG_INFO "ndctl-devel软件包已安装测试结束后将保持安装状态"
INSTALLED=1
else
LOG_INFO "ndctl-devel软件包未安装将进行安装测试"
INSTALLED=0
fi
if [ $INSTALLED -eq 0 ]; then
LOG_INFO "步骤3安装ndctl-devel软件包"
dnf install -y ndctl-devel
CHECK_RESULT $? 0 0 "安装ndctl-devel软件包失败"
fi
LOG_INFO "步骤4检查pkg-config命令是否存在"
command -v pkg-config &>/dev/null
CHECK_RESULT $? 0 0 "pkg-config命令不存在退出测试"
if [ $? -eq 255 ]; then
LOG_ERROR "pkg-config命令不存在退出测试"
exit 255
fi
LOG_INFO "步骤5使用pkg-config查找ndctl开发库"
pkg-config --exists ndctl
CHECK_RESULT $? 0 0 "pkg-config无法找到ndctl开发库"
LOG_INFO "步骤6获取ndctl开发库的版本信息"
pkg-config --modversion ndctl
CHECK_RESULT $? 0 0 "获取ndctl开发库版本信息失败"
LOG_INFO "步骤7获取ndctl开发库的编译选项"
pkg-config --cflags ndctl
CHECK_RESULT $? 0 0 "获取ndctl开发库编译选项失败"
LOG_INFO "步骤8获取ndctl开发库的链接选项"
pkg-config --libs ndctl
CHECK_RESULT $? 0 0 "获取ndctl开发库链接选项失败"
if [ $INSTALLED -eq 0 ]; then
LOG_INFO "步骤9卸载ndctl-devel软件包"
dnf remove -y ndctl-devel
CHECK_RESULT $? 0 0 "卸载ndctl-devel软件包失败"
fi
LOG_INFO "测试完成pkg-config成功找到ndctl开发库"
}
main "$@"

View File

@@ -1,73 +0,0 @@
#!/usr/bin/bash
# Copyright (c) 2024 ISCAS .ALL rights reserved.
# This program is licensed under Mulan PSL v2.
# You can use it according to the terms and conditions of the Mulan PSL v2.
# http://license.coscl.org.cn/MulanPSL2
# THIS PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
# See the Mulan PSL v2 for more details.
# #############################################
# @Author : honghua
# @Contact : honghua@iscas.ac.cn
# @Date : 2026-03-21
# @License : Mulan PSL v2
# @Desc : Check the availability of man pages for library functions
# ############################################
source "$OET_PATH/libs/locallibs/common_lib.sh"
function run_test() {
# 判断是否已安装ndctl-devel包
LOG_INFO "检查ndctl-devel包是否已安装"
if dnf list installed ndctl-devel &>/dev/null; then
LOG_INFO "ndctl-devel包已安装标记为需要保持安装状态"
INSTALLED_ALREADY=1
else
LOG_INFO "ndctl-devel包未安装标记为需要清理安装"
INSTALLED_ALREADY=0
fi
# 检查yum源中是否有ndctl-devel包
LOG_INFO "检查yum源中是否存在ndctl-devel包"
if ! dnf list available ndctl-devel &>/dev/null; then
LOG_ERROR "yum源中未找到ndctl-devel包"
exit 255
fi
# 如果未安装则安装ndctl-devel包
if [ $INSTALLED_ALREADY -eq 0 ]; then
LOG_INFO "安装ndctl-devel包"
dnf install -y ndctl-devel
CHECK_RESULT $? 0 0 "安装ndctl-devel包失败"
fi
# 测试man page的可用性
LOG_INFO "检查库函数man page的可用性"
# 列出一些关键的库函数进行测试
LIB_FUNCTIONS="ndctl_new ndctl_unref ndctl_get_provider ndctl_get_ctx"
for func in $LIB_FUNCTIONS; do
LOG_INFO "检查函数 $func 的man page"
man -w 3 $func &>/dev/null
CHECK_RESULT $? 0 0 "函数 $func 的man page不可用"
LOG_INFO "函数 $func 的man page可用"
done
LOG_INFO "所有库函数的man page均可用"
# 环境清理
if [ $INSTALLED_ALREADY -eq 0 ]; then
LOG_INFO "清理环境卸载ndctl-devel包"
dnf remove -y ndctl-devel
CHECK_RESULT $? 0 0 "卸载ndctl-devel包失败"
LOG_INFO "环境已恢复到初始状态"
else
LOG_INFO "保持ndctl-devel包的安装状态"
fi
LOG_INFO "测试完成"
}
main "$@"

View File

@@ -1,69 +0,0 @@
#!/usr/bin/bash
# Copyright (c) 2024 ISCAS .ALL rights reserved.
# This program is licensed under Mulan PSL v2.
# You can use it according to the terms and conditions of the Mulan PSL v2.
# http://license.coscl.org.cn/MulanPSL2
# THIS PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
# See the Mulan PSL v2 for more details.
# #############################################
# @Author : honghua
# @Contact : honghua@iscas.ac.cn
# @Date : 2025-09-12
# @License : Mulan PSL v2
# @Desc : Test the uninstallation of ndctl-devel package
# ############################################
source "$OET_PATH/libs/locallibs/common_lib.sh"
function run_test() {
# 检查是否已安装ndctl-devel软件包
LOG_INFO "检查是否已安装ndctl-devel软件包"
rpm -q ndctl-devel > /dev/null 2>&1
if [ $? -eq 0 ]; then
LOG_INFO "ndctl-devel已安装脚本结束时将保持安装状态"
INSTALLED=1
else
LOG_INFO "ndctl-devel未安装脚本结束时将卸载软件包"
INSTALLED=0
fi
# 检查yum源中是否存在ndctl-devel软件包
LOG_INFO "检查yum源中是否存在ndctl-devel软件包"
dnf list available ndctl-devel > /dev/null 2>&1
CHECK_RESULT $? 0 255 "yum源中不存在ndctl-devel软件包"
# 如果未安装则安装ndctl-devel软件包
if [ $INSTALLED -eq 0 ]; then
LOG_INFO "安装ndctl-devel软件包"
dnf install -y ndctl-devel
CHECK_RESULT $? 0 0 "安装ndctl-devel失败"
fi
# 测试卸载ndctl-devel软件包的功能
LOG_INFO "测试卸载ndctl-devel软件包的功能"
dnf remove -y ndctl-devel
CHECK_RESULT $? 0 0 "卸载ndctl-devel失败"
# 验证卸载是否成功
LOG_INFO "验证ndctl-devel是否已卸载"
rpm -q ndctl-devel > /dev/null 2>&1
CHECK_RESULT $? 1 0 "ndctl-devel未成功卸载"
# 如果最初未安装,则重新安装以恢复环境;否则保持卸载状态
if [ $INSTALLED -eq 0 ]; then
LOG_INFO "恢复环境重新安装ndctl-devel"
dnf install -y ndctl-devel
CHECK_RESULT $? 0 0 "重新安装ndctl-devel失败"
else
LOG_INFO "环境恢复为已安装ndctl-devel的状态"
dnf install -y ndctl-devel
fi
LOG_INFO "测试脚本执行完毕"
}
main "$@"