update testcase for testsuite gnu-getopt-help

This commit is contained in:
2026-04-18 02:47:04 +08:00
parent 22d5bdb203
commit 8b589dd3f3
3 changed files with 0 additions and 161 deletions

View File

@@ -1,14 +0,0 @@
{
"path": "$OET_PATH/testcases/function_test/pkg_test/gnu-getopt/gnu-getopt-help",
"machine num": 1,
"cases": [
{
"name": "test_gnu-getopt-help_function_basic",
"desc": "Test basic functionality of gnu-getopt-help"
},
{
"name": "test_gnu-getopt-help_function_parse",
"desc": "Test parsing functionality of gnu-getopt-help"
}
]
}

View File

@@ -1,72 +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-11-29
# @License : Mulan PSL v2
# @Desc : Test basic functionality of gnu-getopt-help
# ############################################
source "$OET_PATH/libs/locallibs/common_lib.sh"
function run_test() {
# 检查是否已安装gnu-getopt-help
LOG_INFO "检查是否已安装gnu-getopt-help..."
rpm -q gnu-getopt-help > /dev/null 2>&1
if [ $? -eq 0 ]; then
LOG_INFO "gnu-getopt-help已安装保持安装状态"
installed=true
else
LOG_INFO "gnu-getopt-help未安装将在测试后卸载"
installed=false
fi
# 检查yum源中是否有gnu-getopt-help软件包
LOG_INFO "检查yum源中是否有gnu-getopt-help软件包..."
dnf list available gnu-getopt-help > /dev/null 2>&1
if [ $? -ne 0 ]; then
LOG_ERROR "yum源中未找到gnu-getopt-help软件包"
exit 255
fi
# 安装gnu-getopt-help如果未安装
if [ "$installed" = false ]; then
LOG_INFO "安装gnu-getopt-help..."
dnf install -y gnu-getopt-help
CHECK_RESULT $? 0 0 "安装gnu-getopt-help失败"
fi
# 测试gnu-getopt-help基本功能
LOG_INFO "测试gnu-getopt-help基本功能..."
gnu-getopt-help --help > /dev/null 2>&1
CHECK_RESULT $? 0 0 "gnu-getopt-help --help命令执行失败"
# 测试不支持的参数(应失败)
LOG_INFO "测试不支持的参数(应失败)..."
gnu-getopt-help --invalid-option > /dev/null 2>&1
if [ $? -ne 255 ]; then
LOG_ERROR "不支持的参数未按预期退出"
exit 255
fi
# 清理环境(如果之前未安装)
if [ "$installed" = false ]; then
LOG_INFO "卸载gnu-getopt-help..."
dnf remove -y gnu-getopt-help
CHECK_RESULT $? 0 0 "卸载gnu-getopt-help失败"
fi
LOG_INFO "测试完成,环境已恢复"
}
main "$@"

View File

@@ -1,75 +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-12-10
# @License : Mulan PSL v2
# @Desc : Test parsing functionality of gnu-getopt-help
# ############################################
source "$OET_PATH/libs/locallibs/common_lib.sh"
function run_test() {
# 测试gnu-getopt-help的解析功能
LOG_INFO "开始测试gnu-getopt-help的解析功能"
# 检查是否已安装gnu-getopt-help
LOG_INFO "检查gnu-getopt-help是否已安装"
if ! dnf list installed gnu-getopt-help &>/dev/null; then
LOG_INFO "gnu-getopt-help未安装将进行安装"
# 检查yum源中是否有该软件包
if ! dnf list available gnu-getopt-help &>/dev/null; then
LOG_ERROR "yum源中未找到gnu-getopt-help软件包"
exit 255
fi
# 安装软件包
dnf install -y gnu-getopt-help
CHECK_RESULT $? 0 0 "安装gnu-getopt-help失败"
# 标记需要卸载
NEED_UNINSTALL=1
else
LOG_INFO "gnu-getopt-help已安装无需重复安装"
fi
# 测试命令参数解析功能
LOG_INFO "测试gnu-getopt-help的命令参数解析功能"
output=$(gnu-getopt-help --help)
CHECK_RESULT $? 0 0 "执行gnu-getopt-help --help失败"
# 检查输出是否包含帮助信息
if [[ "$output" != *"Usage:"* ]]; then
LOG_ERROR "gnu-getopt-help --help输出不符合预期"
exit 255
fi
# 测试不支持的参数
LOG_INFO "测试不支持的参数"
gnu-getopt-help --invalid-option &>/dev/null
if [ $? -ne 255 ]; then
LOG_ERROR "不支持的参数未返回预期退出码255"
exit 255
fi
# 清理环境
if [ "$NEED_UNINSTALL" -eq 1 ]; then
LOG_INFO "卸载gnu-getopt-help"
dnf remove -y gnu-getopt-help
CHECK_RESULT $? 0 0 "卸载gnu-getopt-help失败"
fi
LOG_INFO "测试完成,环境已恢复"
}
main "$@"