update testcase for testsuite python-backlash-help
This commit is contained in:
@@ -1,30 +0,0 @@
|
||||
{
|
||||
"path": "$OET_PATH/testcases/function_test/pkg_test/python-backlash/python-backlash-help",
|
||||
"machine num": 1,
|
||||
"cases": [
|
||||
{
|
||||
"name": "test_python-backlash-help_function_init",
|
||||
"desc": "Test package initialization"
|
||||
},
|
||||
{
|
||||
"name": "test_python-backlash-help_function_install",
|
||||
"desc": "Test package installation"
|
||||
},
|
||||
{
|
||||
"name": "test_python-backlash-help_function_uninstall",
|
||||
"desc": "Test package uninstallation"
|
||||
},
|
||||
{
|
||||
"name": "test_python-backlash-help_function_import",
|
||||
"desc": "Test basic module import"
|
||||
},
|
||||
{
|
||||
"name": "test_python-backlash-help_function_version",
|
||||
"desc": "Test package version check"
|
||||
},
|
||||
{
|
||||
"name": "test_python-backlash-help_function_help",
|
||||
"desc": "Test help command or function"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,63 +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-04-05
|
||||
# @License : Mulan PSL v2
|
||||
# @Desc : Test help command or function
|
||||
# ############################################
|
||||
|
||||
source "$OET_PATH/libs/locallibs/common_lib.sh"
|
||||
|
||||
function run_test() {
|
||||
LOG_INFO "开始测试:Test help command or function"
|
||||
|
||||
# 检查是否已经安装了python3-backlash-help包
|
||||
if dnf list installed python3-backlash-help &>/dev/null; then
|
||||
LOG_INFO "python3-backlash-help 已安装,脚本结束时将保持安装状态"
|
||||
INSTALLED_BEFORE=true
|
||||
else
|
||||
LOG_INFO "python3-backlash-help 未安装,将在测试过程中安装"
|
||||
INSTALLED_BEFORE=false
|
||||
fi
|
||||
|
||||
# 检查yum源中是否有python3-backlash-help包
|
||||
LOG_INFO "检查yum源中是否有python3-backlash-help包"
|
||||
if ! dnf list available python3-backlash-help &>/dev/null; then
|
||||
LOG_ERROR "yum源中未找到python3-backlash-help包"
|
||||
exit 255
|
||||
fi
|
||||
|
||||
# 如果未安装,则安装python3-backlash-help包
|
||||
if [ "$INSTALLED_BEFORE" = false ]; then
|
||||
LOG_INFO "安装python3-backlash-help包"
|
||||
dnf install -y python3-backlash-help
|
||||
CHECK_RESULT $? 0 0 "安装python3-backlash-help包失败"
|
||||
fi
|
||||
|
||||
# 测试help命令或函数
|
||||
LOG_INFO "测试python3-backlash-help的help命令或函数"
|
||||
python3 -m backlash.help --help
|
||||
CHECK_RESULT $? 0 0 "执行python3-backlash-help的help命令或函数失败"
|
||||
|
||||
# 如果测试前未安装,则在测试结束后卸载
|
||||
if [ "$INSTALLED_BEFORE" = false ]; then
|
||||
LOG_INFO "卸载python3-backlash-help包"
|
||||
dnf remove -y python3-backlash-help
|
||||
CHECK_RESULT $? 0 0 "卸载python3-backlash-help包失败"
|
||||
fi
|
||||
|
||||
LOG_INFO "测试完成,环境已恢复"
|
||||
}
|
||||
|
||||
main "$@"
|
||||
@@ -1,82 +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-04-05
|
||||
# @License : Mulan PSL v2
|
||||
# @Desc : Test basic module import
|
||||
# ############################################
|
||||
|
||||
source "$OET_PATH/libs/locallibs/common_lib.sh"
|
||||
|
||||
function run_test() {
|
||||
# 检查Python是否已安装
|
||||
LOG_INFO "检查Python是否已安装"
|
||||
python3 --version > /dev/null 2>&1
|
||||
python_installed=$?
|
||||
|
||||
# 定义软件包名称
|
||||
PACKAGE_NAME="python3"
|
||||
|
||||
# 检查yum源中是否有该软件包
|
||||
LOG_INFO "检查yum源中是否有$PACKAGE_NAME软件包"
|
||||
dnf list available $PACKAGE_NAME > /dev/null 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
LOG_ERROR "yum源中未找到$PACKAGE_NAME软件包"
|
||||
exit 255
|
||||
fi
|
||||
|
||||
# 如果Python未安装,则安装
|
||||
if [ $python_installed -ne 0 ]; then
|
||||
LOG_INFO "Python未安装,开始安装$PACKAGE_NAME"
|
||||
dnf install -y $PACKAGE_NAME
|
||||
CHECK_RESULT $? 0 0 "安装$PACKAGE_NAME失败"
|
||||
LOG_INFO "$PACKAGE_NAME安装成功"
|
||||
else
|
||||
LOG_INFO "Python已安装,跳过安装步骤"
|
||||
fi
|
||||
|
||||
# 测试基本模块导入
|
||||
LOG_INFO "测试Python基本模块导入"
|
||||
python3 -c "import sys; import os; import math; import json; import re"
|
||||
CHECK_RESULT $? 0 0 "Python基本模块导入失败"
|
||||
|
||||
# 测试不存在的模块导入
|
||||
LOG_INFO "测试导入不存在的模块"
|
||||
python3 -c "import nonexistent_module" 2>&1 | grep -q "ModuleNotFoundError"
|
||||
CHECK_RESULT $? 0 0 "导入不存在的模块未按预期失败"
|
||||
|
||||
# 测试help函数
|
||||
LOG_INFO "测试Python help函数"
|
||||
python3 -c "help("modules")" > /dev/null 2>&1
|
||||
CHECK_RESULT $? 0 0 "Python help函数执行失败"
|
||||
|
||||
# 测试backlash(应为backslash,假设是测试转义字符)
|
||||
LOG_INFO "测试Python中的反斜杠处理"
|
||||
python3 -c "print("Hello\\nWorld")" | grep -q "Hello"
|
||||
CHECK_RESULT $? 0 0 "Python反斜杠处理测试失败"
|
||||
|
||||
# 环境恢复
|
||||
if [ $python_installed -ne 0 ]; then
|
||||
LOG_INFO "恢复环境:卸载$PACKAGE_NAME"
|
||||
dnf remove -y $PACKAGE_NAME
|
||||
CHECK_RESULT $? 0 0 "卸载$PACKAGE_NAME失败"
|
||||
LOG_INFO "环境恢复完成"
|
||||
else
|
||||
LOG_INFO "Python是预先安装的,保持安装状态"
|
||||
fi
|
||||
|
||||
LOG_INFO "测试完成"
|
||||
}
|
||||
|
||||
main "$@"
|
||||
@@ -1,113 +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-02
|
||||
# @License : Mulan PSL v2
|
||||
# @Desc : Test package initialization
|
||||
# ############################################
|
||||
|
||||
source "$OET_PATH/libs/locallibs/common_lib.sh"
|
||||
|
||||
function run_test() {
|
||||
|
||||
# 检查软件包是否已安装
|
||||
check_package_installed() {
|
||||
if dnf list installed "$1" &>/dev/null; then
|
||||
LOG_INFO "软件包 $1 已安装"
|
||||
return 0
|
||||
else
|
||||
LOG_INFO "软件包 $1 未安装"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# 检查软件包是否在yum源中
|
||||
check_package_in_repo() {
|
||||
if dnf list available "$1" &>/dev/null; then
|
||||
LOG_INFO "软件包 $1 在yum源中可用"
|
||||
return 0
|
||||
else
|
||||
LOG_ERROR "软件包 $1 不在yum源中"
|
||||
exit 255
|
||||
fi
|
||||
}
|
||||
|
||||
# 安装软件包
|
||||
install_package() {
|
||||
LOG_INFO "开始安装软件包 $1"
|
||||
dnf install -y "$1"
|
||||
CHECK_RESULT $? 0 0 "安装软件包 $1 失败"
|
||||
}
|
||||
|
||||
# 卸载软件包
|
||||
uninstall_package() {
|
||||
LOG_INFO "开始卸载软件包 $1"
|
||||
dnf remove -y "$1"
|
||||
CHECK_RESULT $? 0 0 "卸载软件包 $1 失败"
|
||||
}
|
||||
|
||||
# Test package initialization main function
|
||||
main() {
|
||||
LOG_INFO "[步骤1] 检查测试环境是否已安装指定软件包"
|
||||
PACKAGE="python-backlash-help-function-init"
|
||||
|
||||
if check_package_installed "$PACKAGE"; then
|
||||
INSTALLED=true
|
||||
LOG_INFO "[步骤1完成] $PACKAGE 已安装,脚本结束时将保持安装状态"
|
||||
else
|
||||
INSTALLED=false
|
||||
LOG_INFO "[步骤1完成] $PACKAGE 未安装"
|
||||
|
||||
LOG_INFO "[步骤2] 检查yum源中是否存在 $PACKAGE"
|
||||
check_package_in_repo "$PACKAGE"
|
||||
|
||||
LOG_INFO "[步骤3] 安装 $PACKAGE"
|
||||
install_package "$PACKAGE"
|
||||
CHECK_RESULT $? 0 255 "无法从yum源安装$PACKAGE"
|
||||
|
||||
# Verify installation was successful
|
||||
if ! check_package_installed "$PACKAGE"; then
|
||||
LOG_ERROR "[步骤3失败]未能成功验证$PACKAGE的安装状态"
|
||||
exit 255
|
||||
fi
|
||||
echo "[步骤3完成]$package 成功安装"
|
||||
fi
|
||||
|
||||
# Test command with parameters
|
||||
LOG_INFO "[步骤4]测试命令参数支持性"
|
||||
if ! command -v backlash-help-function-init &> /dev/null ; then
|
||||
echo "--help参数不存在或不支持"
|
||||
exit 255
|
||||
else
|
||||
backlash-help-function-init --help &> /dev/null
|
||||
CHECK_RESULT \$? 0 255 "--help参数执行失败"
|
||||
fi
|
||||
|
||||
# Clean up if needed
|
||||
if [ "$INSTALLED" = false ]; then
|
||||
uninstall_package "$package"
|
||||
CHECK_RESULT \$? 0 0 \"卸载失败\"
|
||||
echo \"[清理完成]环境已恢复\"
|
||||
else
|
||||
echo \"[无需清理]保持原状\"
|
||||
fi
|
||||
}
|
||||
|
||||
main "$@"
|
||||
|
||||
exit $?
|
||||
|
||||
}
|
||||
|
||||
main "$@"
|
||||
@@ -1,110 +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-04-05
|
||||
# @License : Mulan PSL v2
|
||||
# @Desc : Test package installation
|
||||
# ############################################
|
||||
|
||||
source "$OET_PATH/libs/locallibs/common_lib.sh"
|
||||
|
||||
function run_test() {
|
||||
# 环境变量定义(根据实际环境配置)
|
||||
NODE2_IPV4=""
|
||||
NODE2_PASSWORD=""
|
||||
NODE2_USER=""
|
||||
|
||||
# 测试软件包名称
|
||||
PACKAGE_NAME="python-backlash-help-function"
|
||||
|
||||
# 检查软件包是否已在yum源中
|
||||
LOG_INFO "步骤1:检查软件包 ${PACKAGE_NAME} 是否在yum源中"
|
||||
dnf list available ${PACKAGE_NAME} &> /dev/null
|
||||
if [ $? -ne 0 ]; then
|
||||
LOG_ERROR "软件包 ${PACKAGE_NAME} 不在yum源中"
|
||||
exit 255
|
||||
fi
|
||||
|
||||
# 检查当前环境是否已安装该软件包
|
||||
LOG_INFO "步骤2:检查当前环境是否已安装 ${PACKAGE_NAME}"
|
||||
rpm -q ${PACKAGE_NAME} &> /dev/null
|
||||
if [ $? -eq 0 ]; then
|
||||
LOG_INFO "软件包 ${PACKAGE_NAME} 已安装,测试后保持安装状态"
|
||||
INSTALLED_BEFORE=1
|
||||
else
|
||||
LOG_INFO "软件包 ${PACKAGE_NAME} 未安装,测试后将卸载"
|
||||
INSTALLED_BEFORE=0
|
||||
fi
|
||||
|
||||
# 安装软件包(如果未安装)
|
||||
if [ ${INSTALLED_BEFORE} -eq 0 ]; then
|
||||
LOG_INFO "步骤3:安装软件包 ${PACKAGE_NAME}"
|
||||
dnf install -y ${PACKAGE_NAME}
|
||||
CHECK_RESULT $? 0 0 "安装软件包失败"
|
||||
fi
|
||||
|
||||
# 验证软件包安装成功
|
||||
LOG_INFO "步骤4:验证软件包 ${PACKAGE_NAME} 安装成功"
|
||||
rpm -q ${PACKAGE_NAME}
|
||||
CHECK_RESULT $? 0 0 "软件包未正确安装"
|
||||
|
||||
# 测试软件包基本功能(根据实际软件包功能调整)
|
||||
LOG_INFO "步骤5:测试软件包基本功能"
|
||||
# 示例:检查软件包提供的命令是否存在
|
||||
# 假设软件包安装后提供命令 "backlash-help"
|
||||
if command -v backlash-help &> /dev/null; then
|
||||
LOG_INFO "软件包命令 backlash-help 存在"
|
||||
else
|
||||
LOG_ERROR "软件包命令 backlash-help 不存在"
|
||||
exit 255
|
||||
fi
|
||||
|
||||
# 测试命令参数(示例)
|
||||
LOG_INFO "步骤6:测试命令 backlash-help 的 --help 参数"
|
||||
backlash-help --help &> /dev/null
|
||||
CHECK_RESULT $? 0 0 "命令 backlash-help --help 执行失败"
|
||||
|
||||
# 测试不支持的参数(预期失败)
|
||||
LOG_INFO "步骤7:测试命令 backlash-help 的不支持参数 --invalid-param"
|
||||
backlash-help --invalid-param &> /dev/null
|
||||
if [ $? -eq 255 ]; then
|
||||
LOG_INFO "不支持参数 --invalid-param 正确处理"
|
||||
else
|
||||
LOG_ERROR "不支持参数 --invalid-param 未正确处理"
|
||||
exit 255
|
||||
fi
|
||||
|
||||
# 在多服务器环境下测试(如果配置了第二服务器)
|
||||
if [ -n "${NODE2_IPV4}" ] && [ -n "${NODE2_USER}" ] && [ -n "${NODE2_PASSWORD}" ]; then
|
||||
LOG_INFO "步骤8:在第二服务器上验证软件包"
|
||||
SSH_CMD "rpm -q ${PACKAGE_NAME}" ${NODE2_IPV4} ${NODE2_PASSWORD} ${NODE2_USER}
|
||||
CHECK_RESULT $? 0 0 "第二服务器上软件包验证失败"
|
||||
else
|
||||
LOG_INFO "步骤8:未配置第二服务器,跳过多服务器测试"
|
||||
fi
|
||||
|
||||
# 清理环境:如果测试前未安装,则卸载软件包
|
||||
if [ ${INSTALLED_BEFORE} -eq 0 ]; then
|
||||
LOG_INFO "步骤9:清理环境,卸载软件包 ${PACKAGE_NAME}"
|
||||
dnf remove -y ${PACKAGE_NAME}
|
||||
CHECK_RESULT $? 0 0 "卸载软件包失败"
|
||||
LOG_INFO "环境已恢复到测试前状态"
|
||||
else
|
||||
LOG_INFO "步骤9:测试前已安装软件包,保持安装状态"
|
||||
fi
|
||||
|
||||
LOG_INFO "测试完成:Test package installation"
|
||||
}
|
||||
|
||||
main "$@"
|
||||
@@ -1,68 +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-04-05
|
||||
# @License : Mulan PSL v2
|
||||
# @Desc : Test package uninstallation
|
||||
# ############################################
|
||||
|
||||
source "$OET_PATH/libs/locallibs/common_lib.sh"
|
||||
|
||||
function run_test() {
|
||||
LOG_INFO "开始测试:Test package uninstallation"
|
||||
|
||||
LOG_INFO "步骤1: 检查环境是否已安装python-backlash-help-function软件包"
|
||||
if dnf list installed python-backlash-help-function &>/dev/null; then
|
||||
LOG_INFO "软件包已安装,测试前无需安装"
|
||||
INSTALLED_BEFORE_TEST=true
|
||||
else
|
||||
LOG_INFO "软件包未安装,将在测试步骤中安装"
|
||||
INSTALLED_BEFORE_TEST=false
|
||||
fi
|
||||
|
||||
LOG_INFO "步骤2: 检查yum源中是否存在python-backlash-help-function软件包"
|
||||
if ! dnf list available python-backlash-help-function &>/dev/null; then
|
||||
LOG_ERROR "yum源中未找到python-backlash-help-function软件包"
|
||||
exit 255
|
||||
fi
|
||||
|
||||
LOG_INFO "步骤3: 检查dnf remove命令是否支持--help参数"
|
||||
if ! dnf remove --help &>/dev/null; then
|
||||
LOG_ERROR "dnf remove命令不支持--help参数"
|
||||
exit 255
|
||||
fi
|
||||
|
||||
if [ "$INSTALLED_BEFORE_TEST" = false ]; then
|
||||
LOG_INFO "步骤4: 安装python-backlash-help-function软件包"
|
||||
dnf install -y python-backlash-help-function
|
||||
CHECK_RESULT $? 0 0 "安装python-backlash-help-function失败"
|
||||
fi
|
||||
|
||||
LOG_INFO "步骤5: 执行dnf remove --help命令测试卸载帮助功能"
|
||||
dnf remove --help
|
||||
CHECK_RESULT $? 0 0 "执行dnf remove --help命令失败"
|
||||
|
||||
LOG_INFO "步骤6: 环境恢复"
|
||||
if [ "$INSTALLED_BEFORE_TEST" = false ]; then
|
||||
LOG_INFO "卸载测试安装的python-backlash-help-function软件包"
|
||||
dnf remove -y python-backlash-help-function
|
||||
CHECK_RESULT $? 0 0 "卸载python-backlash-help-function失败"
|
||||
else
|
||||
LOG_INFO "测试前已安装,保持安装状态"
|
||||
fi
|
||||
|
||||
LOG_INFO "测试完成"
|
||||
}
|
||||
|
||||
main "$@"
|
||||
@@ -1,98 +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-04-05
|
||||
# @License : Mulan PSL v2
|
||||
# @Desc : Test package version check
|
||||
# ############################################
|
||||
|
||||
source "$OET_PATH/libs/locallibs/common_lib.sh"
|
||||
|
||||
function run_test() {
|
||||
# 测试python-backlash-help-function软件包版本检查
|
||||
LOG_INFO "开始测试:Test package version check"
|
||||
|
||||
# 检查是否已安装python-backlash-help-function
|
||||
LOG_INFO "步骤1:检查python-backlash-help-function是否已安装"
|
||||
dnf list installed python-backlash-help-function > /dev/null 2>&1
|
||||
is_installed=$?
|
||||
|
||||
# 记录初始安装状态
|
||||
if [ $is_installed -eq 0 ]; then
|
||||
LOG_INFO "python-backlash-help-function已安装"
|
||||
already_installed=1
|
||||
else
|
||||
LOG_INFO "python-backlash-help-function未安装"
|
||||
already_installed=0
|
||||
fi
|
||||
|
||||
# 检查yum源中是否有该软件包
|
||||
LOG_INFO "步骤2:检查yum源中是否有python-backlash-help-function软件包"
|
||||
dnf list available python-backlash-help-function > /dev/null 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
LOG_ERROR "yum源中未找到python-backlash-help-function软件包"
|
||||
exit 255
|
||||
fi
|
||||
|
||||
# 如果未安装,则安装软件包
|
||||
if [ $already_installed -eq 0 ]; then
|
||||
LOG_INFO "步骤3:安装python-backlash-help-function软件包"
|
||||
dnf install -y python-backlash-help-function
|
||||
CHECK_RESULT $? 0 0 "安装python-backlash-help-function失败"
|
||||
fi
|
||||
|
||||
# 检查软件包版本
|
||||
LOG_INFO "步骤4:检查python-backlash-help-function软件包版本"
|
||||
rpm -q python-backlash-help-function
|
||||
CHECK_RESULT $? 0 0 "查询python-backlash-help-function版本失败"
|
||||
|
||||
# 检查--help参数是否支持
|
||||
LOG_INFO "步骤5:检查python-backlash-help-function的--help参数"
|
||||
python-backlash-help-function --help > /dev/null 2>&1
|
||||
CHECK_RESULT $? 0 0 "python-backlash-help-function不支持--help参数"
|
||||
|
||||
# 检查版本参数
|
||||
LOG_INFO "步骤6:检查python-backlash-help-function的版本参数"
|
||||
python-backlash-help-function --version > /dev/null 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
# 尝试其他可能的版本参数
|
||||
python-backlash-help-function -v > /dev/null 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
python-backlash-help-function -V > /dev/null 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
LOG_ERROR "python-backlash-help-function不支持版本参数"
|
||||
exit 255
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# 执行功能测试
|
||||
LOG_INFO "步骤7:执行python-backlash-help-function基本功能测试"
|
||||
python-backlash-help-function --help | grep -q "usage\|Usage\|帮助"
|
||||
CHECK_RESULT $? 0 0 "python-backlash-help-function基本功能测试失败"
|
||||
|
||||
# 环境清理
|
||||
LOG_INFO "步骤8:清理测试环境"
|
||||
if [ $already_installed -eq 0 ]; then
|
||||
LOG_INFO "卸载测试安装的python-backlash-help-function软件包"
|
||||
dnf remove -y python-backlash-help-function
|
||||
CHECK_RESULT $? 0 0 "卸载python-backlash-help-function失败"
|
||||
else
|
||||
LOG_INFO "保持原有的python-backlash-help-function安装状态"
|
||||
fi
|
||||
|
||||
LOG_INFO "测试完成:python-backlash-help-function版本检查测试通过"
|
||||
}
|
||||
|
||||
main "$@"
|
||||
Reference in New Issue
Block a user