update testcase for testsuite lvm2-test
This commit is contained in:
@@ -6,82 +6,6 @@
|
||||
"name": "test_lvm2-test_function_basic",
|
||||
"desc": "Test basic commands of lvm2-test"
|
||||
},
|
||||
{
|
||||
"name": "test_lvm2_testsuite_flavours",
|
||||
"desc": "使用--flavours参数指定测试套件运行的风味列表"
|
||||
},
|
||||
{
|
||||
"name": "test_lvm2_testsuite_only",
|
||||
"desc": "使用--only参数指定要运行的测试列表"
|
||||
},
|
||||
{
|
||||
"name": "test_lvm2_testsuite_outdir",
|
||||
"desc": "使用--outdir参数指定输出文件的目录"
|
||||
},
|
||||
{
|
||||
"name": "test_lvm2_testsuite_testdir",
|
||||
"desc": "使用--testdir参数指定测试所在的目录"
|
||||
},
|
||||
{
|
||||
"name": "test_lvm2_testsuite_workdir",
|
||||
"desc": "使用--workdir参数指定运行测试时的工作目录"
|
||||
},
|
||||
{
|
||||
"name": "test_lvm2_testsuite_batch",
|
||||
"desc": "使用--batch参数以简洁格式运行自动化测试"
|
||||
},
|
||||
{
|
||||
"name": "test_lvm2_testsuite_verbose",
|
||||
"desc": "使用--verbose参数以更详细的格式运行自动化测试"
|
||||
},
|
||||
{
|
||||
"name": "test_lvm2_testsuite_interactive",
|
||||
"desc": "使用--interactive参数以交互式详细格式运行测试"
|
||||
},
|
||||
{
|
||||
"name": "test_lvm2_testsuite_fatal_timeouts",
|
||||
"desc": "使用--fatal-timeouts参数在连续遇到2次超时后退出"
|
||||
},
|
||||
{
|
||||
"name": "test_lvm2_testsuite_continue",
|
||||
"desc": "使用--continue参数以追加模式记录日志"
|
||||
},
|
||||
{
|
||||
"name": "test_lvm2_testsuite_heartbeat",
|
||||
"desc": "使用--heartbeat参数指定定期更新的心跳文件"
|
||||
},
|
||||
{
|
||||
"name": "test_lvm2_testsuite_watch",
|
||||
"desc": "使用--watch参数指定要监视和打印的文件列表"
|
||||
},
|
||||
{
|
||||
"name": "test_lvm2_testsuite_timeout",
|
||||
"desc": "使用--timeout参数设置被视为超时的静默周期"
|
||||
},
|
||||
{
|
||||
"name": "test_lvm2_testsuite_nokmsg",
|
||||
"desc": "使用--nokmsg参数禁止尝试读取内核消息"
|
||||
},
|
||||
{
|
||||
"name": "test_lvm2_testsuite_env_upper_t",
|
||||
"desc": "使用环境变量T来指定要运行的测试列表"
|
||||
},
|
||||
{
|
||||
"name": "test_lvm2_testsuite_env_INTERACTIVE",
|
||||
"desc": "使用环境变量INTERACTIVE来启用交互式模式"
|
||||
},
|
||||
{
|
||||
"name": "test_lvm2_testsuite_env_VERBOSE",
|
||||
"desc": "使用环境变量VERBOSE来启用详细模式"
|
||||
},
|
||||
{
|
||||
"name": "test_lvm2_testsuite_env_BATCH",
|
||||
"desc": "使用环境变量BATCH来启用简洁模式"
|
||||
},
|
||||
{
|
||||
"name": "test_lvm2_testsuite_env_LVM_TEST_CAN_CLOBBER_DMESG",
|
||||
"desc": "使用环境变量LVM_TEST_CAN_CLOBBER_DMESG允许测试刷新内核消息"
|
||||
},
|
||||
{
|
||||
"name": "test_lvm2-test_function_install",
|
||||
"desc": "Test the installation process of the lvm2-test package"
|
||||
@@ -89,26 +13,6 @@
|
||||
{
|
||||
"name": "test_lvm2-test_function_uninstall",
|
||||
"desc": "Test the uninstallation process of the lvm2-test package"
|
||||
},
|
||||
{
|
||||
"name": "test_lvm2-test_function_check_install",
|
||||
"desc": "Verify that the lvm2-test package is correctly installed on the system"
|
||||
},
|
||||
{
|
||||
"name": "test_lvm2-test_function_run_suite",
|
||||
"desc": "Test executing the lvm2 test suite with default parameters"
|
||||
},
|
||||
{
|
||||
"name": "test_lvm2-test_function_list_tests",
|
||||
"desc": "Test listing available tests within the lvm2 test suite"
|
||||
},
|
||||
{
|
||||
"name": "test_lvm2-test_function_help_output",
|
||||
"desc": "Verify the help output of the lvm2 test suite command"
|
||||
},
|
||||
{
|
||||
"name": "test_lvm2-test_function_version",
|
||||
"desc": "Check the version information of the installed lvm2-test package"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,70 +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-01-29
|
||||
# @License : Mulan PSL v2
|
||||
# @Desc : Verify that the lvm2-test package is correctly installed on the system
|
||||
# ############################################
|
||||
|
||||
source "$OET_PATH/libs/locallibs/common_lib.sh"
|
||||
|
||||
function run_test() {
|
||||
LOG_INFO "开始测试:验证系统是否正确安装了 lvm2-test 软件包"
|
||||
|
||||
# 检查是否已安装 lvm2-test
|
||||
if rpm -q lvm2-test &>/dev/null; then
|
||||
LOG_INFO "lvm2-test 已安装,测试开始"
|
||||
installed=true
|
||||
else
|
||||
LOG_INFO "lvm2-test 未安装,将作为测试步骤进行安装"
|
||||
installed=false
|
||||
fi
|
||||
|
||||
# 检查 yum 源中是否有 lvm2-test 软件包
|
||||
LOG_INFO "检查 yum 源中是否存在 lvm2-test 软件包"
|
||||
if ! dnf list available lvm2-test &>/dev/null; then
|
||||
LOG_ERROR "yum 源中未找到 lvm2-test 软件包"
|
||||
exit 255
|
||||
fi
|
||||
|
||||
# 如果未安装,则安装 lvm2-test
|
||||
if [ "$installed" = false ]; then
|
||||
LOG_INFO "安装 lvm2-test 软件包"
|
||||
dnf install -y lvm2-test
|
||||
CHECK_RESULT $? 0 0 "安装 lvm2-test 失败"
|
||||
fi
|
||||
|
||||
# 验证 lvm2-test 是否成功安装
|
||||
LOG_INFO "验证 lvm2-test 是否成功安装"
|
||||
rpm -q lvm2-test &>/dev/null
|
||||
CHECK_RESULT $? 0 0 "lvm2-test 未正确安装"
|
||||
|
||||
# 测试 lvm2-test 提供的命令(示例:检查 lvm 命令是否存在)
|
||||
LOG_INFO "检查 lvm 命令是否存在"
|
||||
command -v lvm &>/dev/null
|
||||
CHECK_RESULT $? 0 0 "lvm 命令不存在"
|
||||
|
||||
# 清理环境:如果测试前未安装,则卸载 lvm2-test
|
||||
if [ "$installed" = false ]; then
|
||||
LOG_INFO "卸载 lvm2-test 软件包"
|
||||
dnf remove -y lvm2-test
|
||||
CHECK_RESULT $? 0 0 "卸载 lvm2-test 失败"
|
||||
else
|
||||
LOG_INFO "测试前已安装 lvm2-test,保持安装状态"
|
||||
fi
|
||||
|
||||
LOG_INFO "测试完成:lvm2-test 软件包安装验证通过"
|
||||
}
|
||||
|
||||
main "$@"
|
||||
@@ -1,77 +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-01-29
|
||||
# @License : Mulan PSL v2
|
||||
# @Desc : Verify the help output of the lvm2 test suite command
|
||||
# ############################################
|
||||
|
||||
source "$OET_PATH/libs/locallibs/common_lib.sh"
|
||||
|
||||
function run_test() {
|
||||
LOG_INFO "开始测试:验证 lvm2 测试套件命令的帮助输出"
|
||||
|
||||
# 检查是否已安装 lvm2-test 软件包
|
||||
LOG_INFO "检查 lvm2-test 软件包是否已安装"
|
||||
if dnf list installed lvm2-test &> /dev/null; then
|
||||
LOG_INFO "lvm2-test 软件包已安装,测试后保持安装状态"
|
||||
INSTALLED=true
|
||||
else
|
||||
LOG_INFO "lvm2-test 软件包未安装,将在测试后卸载"
|
||||
INSTALLED=false
|
||||
fi
|
||||
|
||||
# 检查 yum 源中是否有 lvm2-test 软件包
|
||||
LOG_INFO "检查 yum 源中是否存在 lvm2-test 软件包"
|
||||
if ! dnf list available lvm2-test &> /dev/null; then
|
||||
LOG_ERROR "yum 源中未找到 lvm2-test 软件包"
|
||||
exit 255
|
||||
fi
|
||||
|
||||
# 如果未安装,则安装软件包
|
||||
if ! $INSTALLED; then
|
||||
LOG_INFO "安装 lvm2-test 软件包"
|
||||
dnf install -y lvm2-test
|
||||
CHECK_RESULT $? 0 0 "安装 lvm2-test 软件包失败"
|
||||
fi
|
||||
|
||||
# 检查 lvm2-test 命令的帮助参数
|
||||
LOG_INFO "检查 lvm2-test 命令是否支持帮助参数"
|
||||
if ! lvm2-test --help &> /dev/null; then
|
||||
LOG_ERROR "lvm2-test 命令不支持 --help 参数"
|
||||
# 如果未安装,则卸载软件包
|
||||
if ! $INSTALLED; then
|
||||
LOG_INFO "卸载 lvm2-test 软件包"
|
||||
dnf remove -y lvm2-test
|
||||
CHECK_RESULT $? 0 0 "卸载 lvm2-test 软件包失败"
|
||||
fi
|
||||
exit 255
|
||||
fi
|
||||
|
||||
# 执行 lvm2-test 命令的帮助输出
|
||||
LOG_INFO "执行 lvm2-test 命令的帮助输出"
|
||||
lvm2-test --help
|
||||
CHECK_RESULT $? 0 0 "执行 lvm2-test 命令帮助输出失败"
|
||||
|
||||
# 如果测试前未安装,则卸载软件包
|
||||
if ! $INSTALLED; then
|
||||
LOG_INFO "卸载 lvm2-test 软件包"
|
||||
dnf remove -y lvm2-test
|
||||
CHECK_RESULT $? 0 0 "卸载 lvm2-test 软件包失败"
|
||||
fi
|
||||
|
||||
LOG_INFO "测试完成:lvm2 测试套件命令的帮助输出验证成功"
|
||||
}
|
||||
|
||||
main "$@"
|
||||
@@ -1,71 +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-01-29
|
||||
# @License : Mulan PSL v2
|
||||
# @Desc : Test listing available tests within the lvm2 test suite
|
||||
# ############################################
|
||||
|
||||
source "$OET_PATH/libs/locallibs/common_lib.sh"
|
||||
|
||||
function run_test() {
|
||||
LOG_INFO "开始测试:列出lvm2测试套件中的可用测试"
|
||||
|
||||
# 检查是否已安装lvm2-test软件包
|
||||
LOG_INFO "检查lvm2-test软件包是否已安装"
|
||||
if dnf list installed lvm2-test &>/dev/null; then
|
||||
LOG_INFO "lvm2-test已安装,测试后保持安装状态"
|
||||
INSTALLED=true
|
||||
else
|
||||
LOG_INFO "lvm2-test未安装,将在测试前安装并在测试后卸载"
|
||||
INSTALLED=false
|
||||
fi
|
||||
|
||||
# 检查yum源中是否有lvm2-test软件包
|
||||
LOG_INFO "检查yum源中是否有lvm2-test软件包"
|
||||
if ! dnf list available lvm2-test &>/dev/null; then
|
||||
LOG_ERROR "yum源中未找到lvm2-test软件包"
|
||||
exit 255
|
||||
fi
|
||||
|
||||
# 如果未安装,则安装lvm2-test软件包
|
||||
if [ "$INSTALLED" = false ]; then
|
||||
LOG_INFO "安装lvm2-test软件包"
|
||||
dnf install -y lvm2-test
|
||||
CHECK_RESULT $? 0 0 "安装lvm2-test软件包失败"
|
||||
fi
|
||||
|
||||
# 检查lvm2-test命令是否支持列出可用测试的参数
|
||||
LOG_INFO "检查lvm2-test命令是否支持列出可用测试的参数"
|
||||
if ! lvm2-test --help 2>&1 | grep -q "list-tests"; then
|
||||
LOG_ERROR "lvm2-test命令不支持列出可用测试的参数"
|
||||
exit 255
|
||||
fi
|
||||
|
||||
# 执行列出可用测试的命令
|
||||
LOG_INFO "执行列出lvm2测试套件中可用测试的命令"
|
||||
lvm2-test list-tests
|
||||
CHECK_RESULT $? 0 0 "列出lvm2测试套件中可用测试失败"
|
||||
|
||||
# 清理环境:如果测试前未安装,则卸载lvm2-test软件包
|
||||
if [ "$INSTALLED" = false ]; then
|
||||
LOG_INFO "卸载lvm2-test软件包"
|
||||
dnf remove -y lvm2-test
|
||||
CHECK_RESULT $? 0 0 "卸载lvm2-test软件包失败"
|
||||
fi
|
||||
|
||||
LOG_INFO "测试完成:成功列出lvm2测试套件中的可用测试"
|
||||
}
|
||||
|
||||
main "$@"
|
||||
@@ -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-01-29
|
||||
# @License : Mulan PSL v2
|
||||
# @Desc : Test executing the lvm2 test suite with default parameters
|
||||
# ############################################
|
||||
|
||||
source "$OET_PATH/libs/locallibs/common_lib.sh"
|
||||
|
||||
function run_test() {
|
||||
LOG_INFO "开始测试:使用默认参数执行lvm2测试套件"
|
||||
|
||||
# 检查环境是否已安装lvm2
|
||||
LOG_INFO "检查lvm2是否已安装"
|
||||
if dnf list installed lvm2 > /dev/null 2>&1; then
|
||||
LOG_INFO "lvm2已安装,测试结束后将保持安装状态"
|
||||
INSTALLED_BEFORE=true
|
||||
else
|
||||
LOG_INFO "lvm2未安装,将在测试过程中安装并在测试结束后卸载"
|
||||
INSTALLED_BEFORE=false
|
||||
fi
|
||||
|
||||
# 检查yum源中是否有lvm2软件包
|
||||
LOG_INFO "检查yum源中是否有lvm2软件包"
|
||||
if ! dnf list available lvm2 > /dev/null 2>&1; then
|
||||
LOG_ERROR "yum源中没有lvm2软件包"
|
||||
exit 255
|
||||
fi
|
||||
|
||||
# 如果未安装,则安装lvm2
|
||||
if [ "$INSTALLED_BEFORE" = false ]; then
|
||||
LOG_INFO "安装lvm2软件包"
|
||||
dnf install -y lvm2
|
||||
CHECK_RESULT $? 0 0 "安装lvm2失败"
|
||||
fi
|
||||
|
||||
# 检查lvm2-test命令是否存在
|
||||
LOG_INFO "检查lvm2-test命令是否存在"
|
||||
if ! command -v lvm2-test > /dev/null 2>&1; then
|
||||
LOG_ERROR "lvm2-test命令不存在"
|
||||
exit 255
|
||||
fi
|
||||
|
||||
# 检查lvm2-test命令是否支持默认参数
|
||||
LOG_INFO "检查lvm2-test命令是否支持默认参数"
|
||||
if ! lvm2-test --help 2>&1 | grep -q "run_suite"; then
|
||||
LOG_ERROR "lvm2-test命令不支持run_suite参数"
|
||||
exit 255
|
||||
fi
|
||||
|
||||
# 执行lvm2-test run_suite命令
|
||||
LOG_INFO "执行lvm2-test run_suite命令"
|
||||
lvm2-test run_suite
|
||||
CHECK_RESULT $? 0 0 "执行lvm2-test run_suite失败"
|
||||
|
||||
# 测试完成后清理环境
|
||||
LOG_INFO "清理测试环境"
|
||||
if [ "$INSTALLED_BEFORE" = false ]; then
|
||||
LOG_INFO "卸载lvm2软件包"
|
||||
dnf remove -y lvm2
|
||||
CHECK_RESULT $? 0 0 "卸载lvm2失败"
|
||||
else
|
||||
LOG_INFO "保持lvm2安装状态"
|
||||
fi
|
||||
|
||||
LOG_INFO "测试完成"
|
||||
}
|
||||
|
||||
main "$@"
|
||||
@@ -1,67 +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-01-29
|
||||
# @License : Mulan PSL v2
|
||||
# @Desc : Check the version information of the installed lvm2-test package
|
||||
# ############################################
|
||||
|
||||
source "$OET_PATH/libs/locallibs/common_lib.sh"
|
||||
|
||||
function run_test() {
|
||||
LOG_INFO "开始测试:检查已安装的lvm2-test软件包的版本信息"
|
||||
|
||||
# 检查是否已安装lvm2-test
|
||||
if dnf list installed lvm2-test &>/dev/null; then
|
||||
LOG_INFO "lvm2-test已安装,跳过安装步骤"
|
||||
INSTALLED_BEFORE=1
|
||||
else
|
||||
LOG_INFO "lvm2-test未安装,开始安装"
|
||||
INSTALLED_BEFORE=0
|
||||
# 检查yum源中是否有lvm2-test软件包
|
||||
if ! dnf list available lvm2-test &>/dev/null; then
|
||||
LOG_ERROR "yum源中未找到lvm2-test软件包"
|
||||
exit 255
|
||||
fi
|
||||
dnf install -y lvm2-test
|
||||
CHECK_RESULT $? 0 0 "安装lvm2-test失败"
|
||||
fi
|
||||
|
||||
# 检查lvm2-test命令是否支持--version参数
|
||||
LOG_INFO "检查lvm2-test命令是否支持--version参数"
|
||||
lvm2-test --version &>/dev/null
|
||||
if [ $? -eq 255 ]; then
|
||||
LOG_ERROR "lvm2-test命令不支持--version参数"
|
||||
exit 255
|
||||
fi
|
||||
|
||||
# 执行lvm2-test --version命令
|
||||
LOG_INFO "执行lvm2-test --version命令"
|
||||
lvm2-test --version
|
||||
CHECK_RESULT $? 0 0 "执行lvm2-test --version命令失败"
|
||||
|
||||
# 环境恢复
|
||||
LOG_INFO "环境恢复"
|
||||
if [ $INSTALLED_BEFORE -eq 0 ]; then
|
||||
LOG_INFO "卸载lvm2-test软件包"
|
||||
dnf remove -y lvm2-test
|
||||
CHECK_RESULT $? 0 0 "卸载lvm2-test失败"
|
||||
else
|
||||
LOG_INFO "保持lvm2-test安装状态"
|
||||
fi
|
||||
|
||||
LOG_INFO "测试完成"
|
||||
}
|
||||
|
||||
main "$@"
|
||||
@@ -1,70 +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-01-29
|
||||
# @License : Mulan PSL v2
|
||||
# @Desc : 使用--batch参数以简洁格式运行自动化测试
|
||||
# ############################################
|
||||
|
||||
source "$OET_PATH/libs/locallibs/common_lib.sh"
|
||||
|
||||
function run_test() {
|
||||
LOG_INFO "开始测试:使用--batch参数以简洁格式运行自动化测试"
|
||||
LOG_INFO "步骤1: 检查lvm2-testsuite软件包是否在yum源中"
|
||||
if ! dnf list available lvm2-testsuite &> /dev/null; then
|
||||
LOG_ERROR "yum源中未找到lvm2-testsuite软件包"
|
||||
exit 255
|
||||
fi
|
||||
LOG_INFO "lvm2-testsuite软件包在yum源中存在"
|
||||
|
||||
LOG_INFO "步骤2: 检查系统是否已安装lvm2-testsuite"
|
||||
if rpm -q lvm2-testsuite &> /dev/null; then
|
||||
LOG_INFO "lvm2-testsuite已安装,测试后将保持安装状态"
|
||||
INSTALLED="true"
|
||||
else
|
||||
LOG_INFO "lvm2-testsuite未安装,将在测试中安装"
|
||||
INSTALLED="false"
|
||||
fi
|
||||
|
||||
if [ "$INSTALLED" = "false" ]; then
|
||||
LOG_INFO "步骤3: 安装lvm2-testsuite软件包"
|
||||
dnf install -y lvm2-testsuite
|
||||
CHECK_RESULT $? 0 0 "安装lvm2-testsuite失败"
|
||||
fi
|
||||
|
||||
LOG_INFO "步骤4: 检查lvm2-testsuite是否支持--batch参数"
|
||||
if ! lvm2-testsuite --help 2>&1 | grep -q -- "--batch"; then
|
||||
LOG_ERROR "lvm2-testsuite命令不支持--batch参数"
|
||||
if [ "$INSTALLED" = "false" ]; then
|
||||
dnf remove -y lvm2-testsuite
|
||||
fi
|
||||
exit 255
|
||||
fi
|
||||
|
||||
LOG_INFO "步骤5: 使用--batch参数运行lvm2-testsuite"
|
||||
lvm2-testsuite --batch
|
||||
CHECK_RESULT $? 0 0 "使用--batch参数运行lvm2-testsuite失败"
|
||||
|
||||
if [ "$INSTALLED" = "false" ]; then
|
||||
LOG_INFO "步骤6: 卸载lvm2-testsuite软件包"
|
||||
dnf remove -y lvm2-testsuite
|
||||
CHECK_RESULT $? 0 0 "卸载lvm2-testsuite失败"
|
||||
else
|
||||
LOG_INFO "步骤6: 保持lvm2-testsuite安装状态"
|
||||
fi
|
||||
|
||||
LOG_INFO "测试完成"
|
||||
}
|
||||
|
||||
main "$@"
|
||||
@@ -1,102 +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-01-29
|
||||
# @License : Mulan PSL v2
|
||||
# @Desc : 使用--continue参数以追加模式记录日志
|
||||
# ############################################
|
||||
|
||||
source "$OET_PATH/libs/locallibs/common_lib.sh"
|
||||
|
||||
function run_test() {
|
||||
LOG_INFO "开始测试:使用--continue参数以追加模式记录日志"
|
||||
|
||||
# 检查是否已安装lvm2-testsuite
|
||||
LOG_INFO "步骤1:检查是否已安装lvm2-testsuite"
|
||||
if dnf list installed lvm2-testsuite &>/dev/null; then
|
||||
LOG_INFO "lvm2-testsuite已安装,脚本结束后将保持安装状态"
|
||||
installed_flag=1
|
||||
else
|
||||
LOG_INFO "lvm2-testsuite未安装,将在测试步骤中安装"
|
||||
installed_flag=0
|
||||
fi
|
||||
|
||||
# 检查yum源中是否有lvm2-testsuite软件包
|
||||
LOG_INFO "步骤2:检查yum源中是否有lvm2-testsuite软件包"
|
||||
if ! dnf list available lvm2-testsuite &>/dev/null; then
|
||||
LOG_ERROR "yum源中未找到lvm2-testsuite软件包"
|
||||
exit 255
|
||||
fi
|
||||
|
||||
# 如果未安装,则安装lvm2-testsuite
|
||||
if [ $installed_flag -eq 0 ]; then
|
||||
LOG_INFO "步骤3:安装lvm2-testsuite"
|
||||
dnf install -y lvm2-testsuite
|
||||
CHECK_RESULT $? 0 0 "安装lvm2-testsuite失败"
|
||||
fi
|
||||
|
||||
# 检查--continue参数是否支持
|
||||
LOG_INFO "步骤4:检查--continue参数是否支持"
|
||||
if ! lvm2-testsuite --help 2>&1 | grep -q "\-\-continue"; then
|
||||
LOG_ERROR "lvm2-testsuite不支持--continue参数"
|
||||
if [ $installed_flag -eq 0 ]; then
|
||||
LOG_INFO "清理:卸载lvm2-testsuite"
|
||||
dnf remove -y lvm2-testsuite
|
||||
fi
|
||||
exit 255
|
||||
fi
|
||||
|
||||
# 创建测试日志文件
|
||||
LOG_INFO "步骤5:创建测试日志文件"
|
||||
log_file="test_continue.log"
|
||||
echo "初始日志内容" > $log_file
|
||||
CHECK_RESULT $? 0 0 "创建日志文件失败"
|
||||
|
||||
# 第一次运行测试,记录日志
|
||||
LOG_INFO "步骤6:第一次运行lvm2-testsuite并记录日志"
|
||||
lvm2-testsuite --continue $log_file
|
||||
CHECK_RESULT $? 0 0 "第一次运行lvm2-testsuite失败"
|
||||
|
||||
# 第二次运行测试,使用--continue参数追加日志
|
||||
LOG_INFO "步骤7:第二次运行lvm2-testsuite,使用--continue参数追加日志"
|
||||
lvm2-testsuite --continue $log_file
|
||||
CHECK_RESULT $? 0 0 "第二次运行lvm2-testsuite失败"
|
||||
|
||||
# 检查日志文件是否包含两次运行的日志
|
||||
LOG_INFO "步骤8:检查日志文件是否包含两次运行的日志"
|
||||
log_lines=$(wc -l < $log_file)
|
||||
if [ $log_lines -gt 1 ]; then
|
||||
LOG_INFO "日志文件成功追加了内容"
|
||||
CHECK_RESULT $? 0 0 "日志追加失败"
|
||||
else
|
||||
LOG_ERROR "日志文件未成功追加内容"
|
||||
CHECK_RESULT $? 1 0 "日志追加验证失败"
|
||||
fi
|
||||
|
||||
# 清理测试日志文件
|
||||
LOG_INFO "步骤9:清理测试日志文件"
|
||||
rm -f $log_file
|
||||
CHECK_RESULT $? 0 0 "删除日志文件失败"
|
||||
|
||||
# 如果脚本开始时未安装lvm2-testsuite,则卸载
|
||||
if [ $installed_flag -eq 0 ]; then
|
||||
LOG_INFO "步骤10:卸载lvm2-testsuite"
|
||||
dnf remove -y lvm2-testsuite
|
||||
CHECK_RESULT $? 0 0 "卸载lvm2-testsuite失败"
|
||||
fi
|
||||
|
||||
LOG_INFO "测试完成:使用--continue参数以追加模式记录日志"
|
||||
}
|
||||
|
||||
main "$@"
|
||||
@@ -1,127 +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-01-29
|
||||
# @License : Mulan PSL v2
|
||||
# @Desc : 使用环境变量BATCH来启用简洁模式
|
||||
# ############################################
|
||||
|
||||
source "$OET_PATH/libs/locallibs/common_lib.sh"
|
||||
|
||||
function run_test() {
|
||||
# 定义日志函数
|
||||
LOG_INFO() {
|
||||
echo "[INFO] $*"
|
||||
}
|
||||
|
||||
LOG_ERROR() {
|
||||
echo "[ERROR] $*"
|
||||
}
|
||||
|
||||
# 检查软件包是否在yum源中
|
||||
check_package_in_repo() {
|
||||
local pkg=$1
|
||||
dnf list available "$pkg" &>/dev/null
|
||||
if [ $? -ne 0 ]; then
|
||||
LOG_ERROR "软件包 $pkg 不在yum源中"
|
||||
exit 255
|
||||
fi
|
||||
}
|
||||
|
||||
# 检查命令参数是否存在
|
||||
check_command_option() {
|
||||
local cmd=$1
|
||||
local opt=$2
|
||||
$cmd --help 2>/dev/null | grep -q "\<$opt\>"
|
||||
if [ $? -ne 0 ]; then
|
||||
LOG_ERROR "命令 $cmd 不支持参数 $opt"
|
||||
exit 255
|
||||
fi
|
||||
}
|
||||
|
||||
# 执行命令并检查结果
|
||||
run_command() {
|
||||
local cmd=$1
|
||||
shift
|
||||
LOG_INFO "执行命令: $cmd $*"
|
||||
$cmd "$@"
|
||||
local ret=$?
|
||||
if [ $ret -ne 0 ]; then
|
||||
LOG_ERROR "命令执行失败: $cmd $*"
|
||||
exit $ret
|
||||
fi
|
||||
return $ret
|
||||
}
|
||||
|
||||
# 主测试函数
|
||||
main() {
|
||||
LOG_INFO "开始测试:使用环境变量BATCH来启用简洁模式"
|
||||
|
||||
# 定义需要安装的软件包
|
||||
PACKAGE="lvm2-testsuite"
|
||||
|
||||
# 检查软件包是否已在yum源中
|
||||
LOG_INFO "检查软件包 $PACKAGE 是否在yum源中"
|
||||
check_package_in_repo "$PACKAGE"
|
||||
|
||||
# 检查是否已安装
|
||||
LOG_INFO "检查软件包 $PACKAGE 是否已安装"
|
||||
if rpm -q "$PACKAGE" &>/dev/null; then
|
||||
LOG_INFO "软件包 $PACKAGE 已安装,测试结束后将保持安装状态"
|
||||
INSTALLED=1
|
||||
else
|
||||
LOG_INFO "软件包 $PACKAGE 未安装,将进行安装"
|
||||
INSTALLED=0
|
||||
fi
|
||||
|
||||
# 如果未安装,则安装软件包
|
||||
if [ $INSTALLED -eq 0 ]; then
|
||||
LOG_INFO "安装软件包 $PACKAGE"
|
||||
run_command dnf install -y "$PACKAGE"
|
||||
CHECK_RESULT $? 0 0 "安装软件包失败"
|
||||
fi
|
||||
|
||||
# 检查BATCH环境变量参数
|
||||
LOG_INFO "检查lvm2-testsuite是否支持BATCH环境变量"
|
||||
# 这里假设lvm2-testsuite命令为lvm2-testsuite,实际可能需要调整
|
||||
TEST_CMD="lvm2-testsuite"
|
||||
check_command_option "$TEST_CMD" "BATCH"
|
||||
|
||||
# 设置BATCH环境变量并执行测试
|
||||
LOG_INFO "设置BATCH环境变量为1,执行测试"
|
||||
export BATCH=1
|
||||
run_command $TEST_CMD
|
||||
CHECK_RESULT $? 0 0 "启用BATCH模式执行测试失败"
|
||||
|
||||
# 清理环境变量
|
||||
LOG_INFO "清理BATCH环境变量"
|
||||
unset BATCH
|
||||
|
||||
# 如果测试前未安装,则卸载软件包
|
||||
if [ $INSTALLED -eq 0 ]; then
|
||||
LOG_INFO "卸载软件包 $PACKAGE"
|
||||
run_command dnf remove -y "$PACKAGE"
|
||||
CHECK_RESULT $? 0 0 "卸载软件包失败"
|
||||
else
|
||||
LOG_INFO "测试前已安装软件包,保持安装状态"
|
||||
fi
|
||||
|
||||
LOG_INFO "测试完成:使用环境变量BATCH来启用简洁模式"
|
||||
}
|
||||
|
||||
# 执行主测试函数
|
||||
main
|
||||
}
|
||||
|
||||
main "$@"
|
||||
@@ -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 : 2026-01-29
|
||||
# @License : Mulan PSL v2
|
||||
# @Desc : 使用环境变量INTERACTIVE来启用交互式模式
|
||||
# ############################################
|
||||
|
||||
source "$OET_PATH/libs/locallibs/common_lib.sh"
|
||||
|
||||
function run_test() {
|
||||
LOG_INFO "开始测试:使用环境变量INTERACTIVE来启用交互式模式"
|
||||
LOG_INFO "步骤1:检查是否已安装lvm2-testsuite环境"
|
||||
if dnf list installed lvm2-testsuite &>/dev/null; then
|
||||
LOG_INFO "lvm2-testsuite已安装,脚本结束后将保持安装状态"
|
||||
ENV_INSTALLED=1
|
||||
else
|
||||
LOG_INFO "lvm2-testsuite未安装,将在测试步骤中安装,并在脚本结束前卸载"
|
||||
ENV_INSTALLED=0
|
||||
fi
|
||||
|
||||
LOG_INFO "步骤2:检查yum源中是否有lvm2-testsuite软件包"
|
||||
if ! dnf list available lvm2-testsuite &>/dev/null; then
|
||||
LOG_ERROR "yum源中未找到lvm2-testsuite软件包"
|
||||
exit 255
|
||||
fi
|
||||
|
||||
LOG_INFO "步骤3:检查INTERACTIVE环境变量是否设置"
|
||||
if [ -z "$INTERACTIVE" ]; then
|
||||
LOG_INFO "INTERACTIVE环境变量未设置,将启用交互式模式"
|
||||
export INTERACTIVE=1
|
||||
else
|
||||
LOG_INFO "INTERACTIVE环境变量已设置为:$INTERACTIVE"
|
||||
fi
|
||||
|
||||
LOG_INFO "步骤4:检查lvm2-testsuite命令参数是否支持INTERACTIVE"
|
||||
if ! lvm2-testsuite --help 2>/dev/null | grep -q "INTERACTIVE"; then
|
||||
LOG_ERROR "lvm2-testsuite命令不支持INTERACTIVE参数"
|
||||
exit 255
|
||||
fi
|
||||
|
||||
LOG_INFO "步骤5:如果未安装lvm2-testsuite,则安装"
|
||||
if [ $ENV_INSTALLED -eq 0 ]; then
|
||||
dnf install -y lvm2-testsuite
|
||||
CHECK_RESULT $? 0 0 "安装lvm2-testsuite失败"
|
||||
fi
|
||||
|
||||
LOG_INFO "步骤6:执行lvm2-testsuite命令,启用交互式模式"
|
||||
lvm2-testsuite --interactive=$INTERACTIVE
|
||||
CHECK_RESULT $? 0 0 "执行lvm2-testsuite命令失败"
|
||||
|
||||
LOG_INFO "步骤7:环境恢复"
|
||||
if [ $ENV_INSTALLED -eq 0 ]; then
|
||||
LOG_INFO "卸载lvm2-testsuite软件包"
|
||||
dnf remove -y lvm2-testsuite
|
||||
CHECK_RESULT $? 0 0 "卸载lvm2-testsuite失败"
|
||||
else
|
||||
LOG_INFO "保持lvm2-testsuite安装状态"
|
||||
fi
|
||||
|
||||
LOG_INFO "测试完成"
|
||||
}
|
||||
|
||||
main "$@"
|
||||
@@ -1,87 +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-01-29
|
||||
# @License : Mulan PSL v2
|
||||
# @Desc : 使用环境变量LVM_TEST_CAN_CLOBBER_DMESG允许测试刷新内核消息
|
||||
# ############################################
|
||||
|
||||
source "$OET_PATH/libs/locallibs/common_lib.sh"
|
||||
|
||||
function run_test() {
|
||||
LOG_INFO "开始测试环境变量LVM_TEST_CAN_CLOBBER_DMESG允许测试刷新内核消息"
|
||||
|
||||
LOG_INFO "步骤1: 检查是否已安装lvm2-test套件"
|
||||
if rpm -q lvm2-test > /dev/null 2>&1; then
|
||||
LOG_INFO "lvm2-test已安装,脚本结束后将保持安装状态"
|
||||
INSTALLED_BEFORE=1
|
||||
else
|
||||
LOG_INFO "lvm2-test未安装,将进行安装"
|
||||
INSTALLED_BEFORE=0
|
||||
fi
|
||||
|
||||
LOG_INFO "步骤2: 检查yum源中是否存在lvm2-test软件包"
|
||||
dnf list available lvm2-test > /dev/null 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
LOG_ERROR "yum源中未找到lvm2-test软件包"
|
||||
exit 255
|
||||
fi
|
||||
|
||||
if [ $INSTALLED_BEFORE -eq 0 ]; then
|
||||
LOG_INFO "步骤3: 安装lvm2-test软件包"
|
||||
dnf install -y lvm2-test
|
||||
CHECK_RESULT $? 0 0 "安装lvm2-test失败"
|
||||
fi
|
||||
|
||||
LOG_INFO "步骤4: 检查lvm2-testsuite命令是否支持--with-dmest选项"
|
||||
lvm2-testsuite --help 2>&1 | grep -q "with-dmest"
|
||||
if [ $? -ne 0 ]; then
|
||||
LOG_ERROR "lvm2-testsuite命令不支持--with-dmest参数"
|
||||
if [ $INSTALLED_BEFORE -eq 0 ]; then
|
||||
LOG_INFO "清理环境:卸载lvm2-test软件包"
|
||||
dnf remove -y lvm2-test
|
||||
CHECK_RESULT $? 0 0 "卸载lvm2-test失败"
|
||||
fi
|
||||
exit 255
|
||||
fi
|
||||
|
||||
LOG_INFO "步骤5: 设置环境变量LVM_TEST_CAN_CLOBBER_DMESG"
|
||||
export LVM_TEST_CAN_CLOBBER_DMESG=1
|
||||
|
||||
LOG_INFO "步骤6: 执行lvm2-testsuite测试,验证环境变量生效"
|
||||
lvm2-testsuite --with-dmest > /tmp/lvm_test_output.log 2>&1
|
||||
TEST_RESULT=$?
|
||||
|
||||
if [ $TEST_RESULT -eq 0 ]; then
|
||||
LOG_INFO "测试执行成功,环境变量LVM_TEST_CAN_CLOBBER_DMESG生效"
|
||||
else
|
||||
LOG_ERROR "测试执行失败,退出码: $TEST_RESULT"
|
||||
if [ $INSTALLED_BEFORE -eq 0 ]; then
|
||||
LOG_INFO "清理环境:卸载lvm2-test软件包"
|
||||
dnf remove -y lvm2-test
|
||||
CHECK_RESULT $? 0 0 "卸载lvm2-test失败"
|
||||
fi
|
||||
exit $TEST_RESULT
|
||||
fi
|
||||
|
||||
if [ $INSTALLED_BEFORE -eq 0 ]; then
|
||||
LOG_INFO "步骤7: 清理环境,卸载lvm2-test软件包"
|
||||
dnf remove -y lvm2-test
|
||||
CHECK_RESULT $? 0 0 "卸载lvm2-test失败"
|
||||
fi
|
||||
|
||||
LOG_INFO "测试完成,环境已恢复到初始状态"
|
||||
}
|
||||
|
||||
main "$@"
|
||||
@@ -1,67 +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-01-29
|
||||
# @License : Mulan PSL v2
|
||||
# @Desc : 使用环境变量VERBOSE来启用详细模式
|
||||
# ############################################
|
||||
|
||||
source "$OET_PATH/libs/locallibs/common_lib.sh"
|
||||
|
||||
function run_test() {
|
||||
LOG_INFO "开始测试:使用环境变量VERBOSE来启用详细模式"
|
||||
LOG_INFO "步骤1: 检查环境是否已安装lvm2-testsuite"
|
||||
if dnf list installed lvm2-testsuite &>/dev/null; then
|
||||
LOG_INFO "lvm2-testsuite已安装,脚本结束时将保持安装状态"
|
||||
ENV_INSTALLED="yes"
|
||||
else
|
||||
LOG_INFO "lvm2-testsuite未安装,将在测试过程中安装,并在脚本结束前卸载"
|
||||
ENV_INSTALLED="no"
|
||||
fi
|
||||
LOG_INFO "步骤2: 检查yum源中是否有lvm2-testsuite软件包"
|
||||
if ! dnf list available lvm2-testsuite &>/dev/null; then
|
||||
LOG_ERROR "yum源中未找到lvm2-testsuite软件包"
|
||||
exit 255
|
||||
fi
|
||||
if [ "$ENV_INSTALLED" = "no" ]; then
|
||||
LOG_INFO "步骤3: 安装lvm2-testsuite软件包"
|
||||
dnf install -y lvm2-testsuite
|
||||
CHECK_RESULT $? 0 0 "安装lvm2-testsuite失败"
|
||||
fi
|
||||
LOG_INFO "步骤4: 设置VERBOSE环境变量并运行测试"
|
||||
export VERBOSE=1
|
||||
LOG_INFO "步骤5: 检查lvm2-testsuite是否支持VERBOSE参数"
|
||||
if ! lvm2-testsuite --help 2>&1 | grep -q VERBOSE; then
|
||||
LOG_ERROR "lvm2-testsuite不支持VERBOSE参数"
|
||||
if [ "$ENV_INSTALLED" = "no" ]; then
|
||||
LOG_INFO "清理环境:卸载lvm2-testsuite"
|
||||
dnf remove -y lvm2-testsuite
|
||||
CHECK_RESULT $? 0 0 "卸载lvm2-testsuite失败"
|
||||
fi
|
||||
exit 255
|
||||
fi
|
||||
LOG_INFO "步骤6: 执行lvm2-testsuite测试"
|
||||
lvm2-testsuite
|
||||
CHECK_RESULT $? 0 0 "lvm2-testsuite测试失败"
|
||||
LOG_INFO "步骤7: 清理环境"
|
||||
if [ "$ENV_INSTALLED" = "no" ]; then
|
||||
LOG_INFO "卸载lvm2-testsuite"
|
||||
dnf remove -y lvm2-testsuite
|
||||
CHECK_RESULT $? 0 0 "卸载lvm2-testsuite失败"
|
||||
fi
|
||||
unset VERBOSE
|
||||
LOG_INFO "测试完成"
|
||||
}
|
||||
|
||||
main "$@"
|
||||
@@ -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-01-29
|
||||
# @License : Mulan PSL v2
|
||||
# @Desc : 使用环境变量T来指定要运行的测试列表
|
||||
# ############################################
|
||||
|
||||
source "$OET_PATH/libs/locallibs/common_lib.sh"
|
||||
|
||||
function run_test() {
|
||||
# 判断是否已安装lvm2-testsuite
|
||||
LOG_INFO "检查是否已安装lvm2-testsuite"
|
||||
if dnf list installed lvm2-testsuite &>/dev/null; then
|
||||
LOG_INFO "lvm2-testsuite已安装,将保持安装状态"
|
||||
INSTALLED=true
|
||||
else
|
||||
LOG_INFO "lvm2-testsuite未安装,将在测试过程中安装"
|
||||
INSTALLED=false
|
||||
fi
|
||||
|
||||
# 检查yum源中是否有lvm2-testsuite软件包
|
||||
LOG_INFO "检查yum源中是否有lvm2-testsuite软件包"
|
||||
if ! dnf list available lvm2-testsuite &>/dev/null; then
|
||||
LOG_ERROR "yum源中未找到lvm2-testsuite软件包"
|
||||
exit 255
|
||||
fi
|
||||
|
||||
# 如果未安装,则安装lvm2-testsuite
|
||||
if [ "$INSTALLED" = false ]; then
|
||||
LOG_INFO "安装lvm2-testsuite软件包"
|
||||
dnf install -y lvm2-testsuite
|
||||
CHECK_RESULT $? 0 0 "安装lvm2-testsuite失败"
|
||||
fi
|
||||
|
||||
# 检查环境变量T是否设置
|
||||
LOG_INFO "检查环境变量T是否设置"
|
||||
if [ -z "$T" ]; then
|
||||
LOG_ERROR "环境变量T未设置,无法指定要运行的测试列表"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 检查lvm2-testsuite是否支持-T参数
|
||||
LOG_INFO "检查lvm2-testsuite是否支持-T参数"
|
||||
if ! lvm2-testsuite --help | grep -q "\-T"; then
|
||||
LOG_ERROR "lvm2-testsuite不支持-T参数"
|
||||
exit 255
|
||||
fi
|
||||
|
||||
# 使用环境变量T运行指定的测试列表
|
||||
LOG_INFO "运行指定的测试列表:$T"
|
||||
lvm2-testsuite -T "$T"
|
||||
CHECK_RESULT $? 0 0 "运行测试列表失败"
|
||||
|
||||
# 如果测试开始时未安装,则卸载lvm2-testsuite
|
||||
if [ "$INSTALLED" = false ]; then
|
||||
LOG_INFO "卸载lvm2-testsuite软件包"
|
||||
dnf remove -y lvm2-testsuite
|
||||
CHECK_RESULT $? 0 0 "卸载lvm2-testsuite失败"
|
||||
fi
|
||||
|
||||
LOG_INFO "测试完成"
|
||||
}
|
||||
|
||||
main "$@"
|
||||
@@ -1,79 +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-01-29
|
||||
# @License : Mulan PSL v2
|
||||
# @Desc : 使用--fatal-timeouts参数在连续遇到2次超时后退出
|
||||
# ############################################
|
||||
|
||||
source "$OET_PATH/libs/locallibs/common_lib.sh"
|
||||
|
||||
function run_test() {
|
||||
set -e
|
||||
|
||||
LOG_INFO "检查是否已安装lvm2-testsuite软件包"
|
||||
if dnf list installed lvm2-testsuite &>/dev/null; then
|
||||
LOG_INFO "lvm2-testsuite已安装,脚本结束后将保持安装状态"
|
||||
installed_flag=1
|
||||
else
|
||||
LOG_INFO "lvm2-testsuite未安装,将在测试过程中安装,并在脚本结束前卸载"
|
||||
installed_flag=0
|
||||
fi
|
||||
|
||||
LOG_INFO "检查yum源中是否存在lvm2-testsuite软件包"
|
||||
if ! dnf list available lvm2-testsuite &>/dev/null; then
|
||||
LOG_ERROR "yum源中未找到lvm2-testsuite软件包"
|
||||
exit 255
|
||||
fi
|
||||
|
||||
LOG_INFO "检查lvm2-testsuite命令是否支持--fatal-timeouts参数"
|
||||
if ! lvm2-testsuite --help 2>&1 | grep -q -- "--fatal-timeouts"; then
|
||||
LOG_ERROR "lvm2-testsuite命令不支持--fatal-timeouts参数"
|
||||
exit 255
|
||||
fi
|
||||
|
||||
if [ $installed_flag -eq 0 ]; then
|
||||
LOG_INFO "安装lvm2-testsuite软件包"
|
||||
dnf install -y lvm2-testsuite
|
||||
CHECK_RESULT $? 0 0 "安装lvm2-testsuite软件包失败"
|
||||
fi
|
||||
|
||||
LOG_INFO "执行测试:使用--fatal-timeouts参数在连续遇到2次超时后退出"
|
||||
LOG_INFO "注意:此测试需要构造超时场景,这里使用一个会超时的命令进行模拟"
|
||||
timeout_cmd="sleep 10"
|
||||
timeout 1 $timeout_cmd
|
||||
first_timeout_result=$?
|
||||
timeout 1 $timeout_cmd
|
||||
second_timeout_result=$?
|
||||
|
||||
LOG_INFO "第一次超时执行结果: $first_timeout_result"
|
||||
LOG_INFO "第二次超时执行结果: $second_timeout_result"
|
||||
|
||||
LOG_INFO "运行lvm2-testsuite --fatal-timeouts测试"
|
||||
lvm2-testsuite --fatal-timeouts
|
||||
test_result=$?
|
||||
|
||||
LOG_INFO "测试执行完成,退出码为: $test_result"
|
||||
CHECK_RESULT $test_result 0 0 "lvm2-testsuite --fatal-timeouts测试失败"
|
||||
|
||||
if [ $installed_flag -eq 0 ]; then
|
||||
LOG_INFO "卸载lvm2-testsuite软件包"
|
||||
dnf remove -y lvm2-testsuite
|
||||
CHECK_RESULT $? 0 0 "卸载lvm2-testsuite软件包失败"
|
||||
fi
|
||||
|
||||
LOG_INFO "测试完成,环境已恢复"
|
||||
}
|
||||
|
||||
main "$@"
|
||||
@@ -1,70 +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-01-29
|
||||
# @License : Mulan PSL v2
|
||||
# @Desc : 使用--flavours参数指定测试套件运行的风味列表
|
||||
# ############################################
|
||||
|
||||
source "$OET_PATH/libs/locallibs/common_lib.sh"
|
||||
|
||||
function run_test() {
|
||||
LOG_INFO "开始测试:使用--flavours参数指定测试套件运行的风味列表"
|
||||
LOG_INFO "步骤1:检查lvm2-testsuite软件包是否在yum源中"
|
||||
dnf list available lvm2-testsuite > /dev/null 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
LOG_ERROR "yum源中未找到lvm2-testsuite软件包"
|
||||
exit 255
|
||||
fi
|
||||
|
||||
LOG_INFO "步骤2:检查当前环境是否已安装lvm2-testsuite"
|
||||
rpm -q lvm2-testsuite > /dev/null 2>&1
|
||||
if [ $? -eq 0 ]; then
|
||||
INSTALLED=1
|
||||
LOG_INFO "lvm2-testsuite已安装,测试结束后将保持安装状态"
|
||||
else
|
||||
INSTALLED=0
|
||||
LOG_INFO "lvm2-testsuite未安装,将作为测试步骤安装"
|
||||
fi
|
||||
|
||||
if [ $INSTALLED -eq 0 ]; then
|
||||
LOG_INFO "步骤3:安装lvm2-testsuite软件包"
|
||||
dnf install -y lvm2-testsuite
|
||||
CHECK_RESULT $? 0 0 "安装lvm2-testsuite失败"
|
||||
fi
|
||||
|
||||
LOG_INFO "步骤4:检查lvm2-testsuite命令是否支持--flavours参数"
|
||||
lvm2-testsuite --help 2>&1 | grep -q "\-\-flavours"
|
||||
if [ $? -ne 0 ]; then
|
||||
LOG_ERROR "lvm2-testsuite命令不支持--flavours参数"
|
||||
exit 255
|
||||
fi
|
||||
|
||||
LOG_INFO "步骤5:执行lvm2-testsuite命令,使用--flavours参数指定风味列表"
|
||||
lvm2-testsuite --flavours "thin,raid" --dry-run
|
||||
CHECK_RESULT $? 0 0 "使用--flavours参数执行lvm2-testsuite失败"
|
||||
|
||||
LOG_INFO "步骤6:清理测试环境"
|
||||
if [ $INSTALLED -eq 0 ]; then
|
||||
LOG_INFO "卸载lvm2-testsuite软件包"
|
||||
dnf remove -y lvm2-testsuite
|
||||
CHECK_RESULT $? 0 0 "卸载lvm2-testsuite失败"
|
||||
else
|
||||
LOG_INFO "测试开始前已安装lvm2-testsuite,保持安装状态"
|
||||
fi
|
||||
|
||||
LOG_INFO "测试完成"
|
||||
}
|
||||
|
||||
main "$@"
|
||||
@@ -1,77 +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-01-29
|
||||
# @License : Mulan PSL v2
|
||||
# @Desc : 使用--heartbeat参数指定定期更新的心跳文件
|
||||
# ############################################
|
||||
|
||||
source "$OET_PATH/libs/locallibs/common_lib.sh"
|
||||
|
||||
function run_test() {
|
||||
LOG_INFO "开始测试:使用--heartbeat参数指定定期更新的心跳文件"
|
||||
LOG_INFO "步骤1:检查yum源中是否包含lvm2-testsuite软件包"
|
||||
dnf list lvm2-testsuite > /dev/null 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
LOG_ERROR "yum源中未找到lvm2-testsuite软件包"
|
||||
exit 255
|
||||
fi
|
||||
LOG_INFO "步骤2:检查当前环境中是否已安装lvm2-testsuite"
|
||||
rpm -q lvm2-testsuite > /dev/null 2>&1
|
||||
if [ $? -eq 0 ]; then
|
||||
LOG_INFO "lvm2-testsuite已安装,标记为已安装状态"
|
||||
INSTALLED=1
|
||||
else
|
||||
LOG_INFO "lvm2-testsuite未安装,标记为未安装状态"
|
||||
INSTALLED=0
|
||||
fi
|
||||
LOG_INFO "步骤3:如果未安装,则安装lvm2-testsuite"
|
||||
if [ $INSTALLED -eq 0 ]; then
|
||||
dnf install -y lvm2-testsuite > /dev/null 2>&1
|
||||
CHECK_RESULT $? 0 0 "安装lvm2-testsuite失败"
|
||||
fi
|
||||
LOG_INFO "步骤4:检查lvcreate命令是否支持--heartbeat参数"
|
||||
lvcreate --help | grep -q -- --heartbeat
|
||||
if [ $? -ne 0 ]; then
|
||||
LOG_ERROR "lvcreate命令不支持--heartbeat参数"
|
||||
if [ $INSTALLED -eq 0 ]; then
|
||||
LOG_INFO "清理环境:卸载lvm2-testsuite"
|
||||
dnf remove -y lvm2-testsuite > /dev/null 2>&1
|
||||
fi
|
||||
exit 255
|
||||
fi
|
||||
LOG_INFO "步骤5:创建测试用的物理卷和卷组"
|
||||
pvcreate /dev/loop0 > /dev/null 2>&1
|
||||
CHECK_RESULT $? 0 0 "创建物理卷失败"
|
||||
vgcreate testvg /dev/loop0 > /dev/null 2>&1
|
||||
CHECK_RESULT $? 0 0 "创建卷组失败"
|
||||
LOG_INFO "步骤6:使用--heartbeat参数创建逻辑卷"
|
||||
lvcreate --heartbeat /dev/testvg -L 10M -n testlv > /dev/null 2>&1
|
||||
CHECK_RESULT $? 0 0 "使用--heartbeat参数创建逻辑卷失败"
|
||||
LOG_INFO "步骤7:检查逻辑卷是否成功创建"
|
||||
lvs /dev/testvg/testlv > /dev/null 2>&1
|
||||
CHECK_RESULT $? 0 0 "逻辑卷未成功创建"
|
||||
LOG_INFO "步骤8:清理测试创建的卷组和物理卷"
|
||||
lvremove -f /dev/testvg/testlv > /dev/null 2>&1
|
||||
vgremove testvg > /dev/null 2>&1
|
||||
pvremove /dev/loop0 > /dev/null 2>&1
|
||||
LOG_INFO "步骤9:如果之前未安装,则卸载lvm2-testsuite"
|
||||
if [ $INSTALLED -eq 0 ]; then
|
||||
dnf remove -y lvm2-testsuite > /dev/null 2>&1
|
||||
CHECK_RESULT $? 0 0 "卸载lvm2-testsuite失败"
|
||||
fi
|
||||
LOG_INFO "测试完成:使用--heartbeat参数指定定期更新的心跳文件"
|
||||
}
|
||||
|
||||
main "$@"
|
||||
@@ -1,57 +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-01-29
|
||||
# @License : Mulan PSL v2
|
||||
# @Desc : 使用--interactive参数以交互式详细格式运行测试
|
||||
# ############################################
|
||||
|
||||
source "$OET_PATH/libs/locallibs/common_lib.sh"
|
||||
|
||||
function run_test() {
|
||||
LOG_INFO "检查yum源中是否存在lvm2-testsuite软件包"
|
||||
if ! dnf list available lvm2-testsuite &>/dev/null; then
|
||||
LOG_ERROR "yum源中未找到lvm2-testsuite软件包"
|
||||
exit 255
|
||||
fi
|
||||
|
||||
LOG_INFO "检查--interactive参数是否被支持"
|
||||
if ! lvm2-testsuite --help 2>&1 | grep -q -- --interactive; then
|
||||
LOG_ERROR "lvm2-testsuite不支持--interactive参数"
|
||||
exit 255
|
||||
fi
|
||||
|
||||
LOG_INFO "检查lvm2-testsuite是否已安装"
|
||||
if ! command -v lvm2-testsuite &>/dev/null; then
|
||||
LOG_INFO "lvm2-testsuite未安装,开始安装"
|
||||
dnf install -y lvm2-testsuite
|
||||
CHECK_RESULT $? 0 0 "安装lvm2-testsuite失败"
|
||||
INSTALLED=1
|
||||
else
|
||||
LOG_INFO "lvm2-testsuite已安装"
|
||||
INSTALLED=0
|
||||
fi
|
||||
|
||||
LOG_INFO "以交互式详细格式运行lvm2-testsuite测试"
|
||||
lvm2-testsuite --interactive
|
||||
CHECK_RESULT $? 0 0 "以交互式详细格式运行lvm2-testsuite测试失败"
|
||||
|
||||
if [ $INSTALLED -eq 1 ]; then
|
||||
LOG_INFO "卸载lvm2-testsuite软件包"
|
||||
dnf remove -y lvm2-testsuite
|
||||
CHECK_RESULT $? 0 0 "卸载lvm2-testsuite失败"
|
||||
fi
|
||||
}
|
||||
|
||||
main "$@"
|
||||
@@ -1,61 +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-01-29
|
||||
# @License : Mulan PSL v2
|
||||
# @Desc : 使用--nokmsg参数禁止尝试读取内核消息
|
||||
# ############################################
|
||||
|
||||
source "$OET_PATH/libs/locallibs/common_lib.sh"
|
||||
|
||||
function run_test() {
|
||||
LOG_INFO "开始测试:使用--nokmsg参数禁止尝试读取内核消息"
|
||||
LOG_INFO "步骤1: 检查环境是否已安装lvm2-testsuite软件包"
|
||||
if dnf list installed lvm2-testsuite &> /dev/null; then
|
||||
LOG_INFO "lvm2-testsuite已安装,脚本结束时将保持安装状态"
|
||||
INSTALLED=true
|
||||
else
|
||||
LOG_INFO "lvm2-testsuite未安装,将在测试过程中安装"
|
||||
INSTALLED=false
|
||||
fi
|
||||
LOG_INFO "步骤2: 检查yum源中是否存在lvm2-testsuite软件包"
|
||||
if ! dnf list available lvm2-testsuite &> /dev/null; then
|
||||
LOG_ERROR "yum源中未找到lvm2-testsuite软件包"
|
||||
exit 255
|
||||
fi
|
||||
if [ "$INSTALLED" = false ]; then
|
||||
LOG_INFO "步骤3: 安装lvm2-testsuite软件包"
|
||||
dnf install -y lvm2-testsuite
|
||||
CHECK_RESULT $? 0 0 "安装lvm2-testsuite失败"
|
||||
fi
|
||||
LOG_INFO "步骤4: 检查lvm2-testsuite命令是否支持--nokmsg参数"
|
||||
if ! lvm2-testsuite --help 2>&1 | grep -q -- --nokmsg; then
|
||||
LOG_ERROR "lvm2-testsuite命令不支持--nokmsg参数"
|
||||
exit 255
|
||||
fi
|
||||
LOG_INFO "步骤5: 执行带--nokmsg参数的lvm2-testsuite命令"
|
||||
lvm2-testsuite --nokmsg
|
||||
CHECK_RESULT $? 0 0 "执行lvm2-testsuite --nokmsg失败"
|
||||
LOG_INFO "步骤6: 清理环境"
|
||||
if [ "$INSTALLED" = false ]; then
|
||||
LOG_INFO "卸载lvm2-testsuite软件包"
|
||||
dnf remove -y lvm2-testsuite
|
||||
CHECK_RESULT $? 0 0 "卸载lvm2-testsuite失败"
|
||||
else
|
||||
LOG_INFO "环境已安装lvm2-testsuite,保持安装状态"
|
||||
fi
|
||||
LOG_INFO "测试完成"
|
||||
}
|
||||
|
||||
main "$@"
|
||||
@@ -1,103 +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-01-29
|
||||
# @License : Mulan PSL v2
|
||||
# @Desc : 使用--only参数指定要运行的测试列表
|
||||
# ############################################
|
||||
|
||||
source "$OET_PATH/libs/locallibs/common_lib.sh"
|
||||
|
||||
function run_test() {
|
||||
# 定义日志函数
|
||||
LOG_INFO() {
|
||||
echo "[INFO] $*"
|
||||
}
|
||||
LOG_ERROR() {
|
||||
echo "[ERROR] $*"
|
||||
}
|
||||
|
||||
# 定义检查函数
|
||||
CHECK_RESULT() {
|
||||
if [ $1 -ne $2 ]; then
|
||||
LOG_ERROR "$4"
|
||||
exit $3
|
||||
fi
|
||||
}
|
||||
|
||||
# 定义远程执行函数
|
||||
SSH_CMD() {
|
||||
local cmd=$1
|
||||
local ip=$2
|
||||
local password=$3
|
||||
local user=${4:-root}
|
||||
sshpass -p "$password" ssh -o StrictHostKeyChecking=no "$user@$ip" "$cmd"
|
||||
}
|
||||
|
||||
# 定义软件包安装状态
|
||||
PACKAGE_INSTALLED=0
|
||||
|
||||
# 步骤1:检查是否已安装lvm2-testsuite
|
||||
LOG_INFO "步骤1:检查是否已安装lvm2-testsuite软件包"
|
||||
if dnf list installed lvm2-testsuite &>/dev/null; then
|
||||
LOG_INFO "lvm2-testsuite已安装"
|
||||
PACKAGE_INSTALLED=1
|
||||
else
|
||||
LOG_INFO "lvm2-testsuite未安装,将在测试步骤中安装"
|
||||
fi
|
||||
|
||||
# 步骤2:检查yum源中是否有lvm2-testsuite软件包
|
||||
LOG_INFO "步骤2:检查yum源中是否有lvm2-testsuite软件包"
|
||||
if ! dnf list available lvm2-testsuite &>/dev/null; then
|
||||
LOG_ERROR "yum源中未找到lvm2-testsuite软件包"
|
||||
exit 255
|
||||
fi
|
||||
LOG_INFO "yum源中存在lvm2-testsuite软件包"
|
||||
|
||||
# 步骤3:安装lvm2-testsuite(如果未安装)
|
||||
if [ $PACKAGE_INSTALLED -eq 0 ]; then
|
||||
LOG_INFO "步骤3:安装lvm2-testsuite软件包"
|
||||
dnf install -y lvm2-testsuite
|
||||
CHECK_RESULT $? 0 255 "安装lvm2-testsuite失败"
|
||||
LOG_INFO "lvm2-testsuite安装成功"
|
||||
fi
|
||||
|
||||
# 步骤4:检查--only参数是否支持
|
||||
LOG_INFO "步骤4:检查--only参数是否支持"
|
||||
if ! /usr/share/lvm2-testsuite/runtest.sh --help 2>&1 | grep -q "\-\-only"; then
|
||||
LOG_ERROR "runtest.sh不支持--only参数"
|
||||
exit 255
|
||||
fi
|
||||
LOG_INFO "runtest.sh支持--only参数"
|
||||
|
||||
# 步骤5:使用--only参数运行指定测试
|
||||
LOG_INFO "步骤5:使用--only参数运行指定测试"
|
||||
/usr/share/lvm2-testsuite/runtest.sh --only unit
|
||||
CHECK_RESULT $? 0 1 "使用--only参数运行测试失败"
|
||||
|
||||
# 步骤6:清理环境
|
||||
LOG_INFO "步骤6:清理环境"
|
||||
if [ $PACKAGE_INSTALLED -eq 0 ]; then
|
||||
LOG_INFO "卸载lvm2-testsuite软件包"
|
||||
dnf remove -y lvm2-testsuite
|
||||
CHECK_RESULT $? 0 1 "卸载lvm2-testsuite失败"
|
||||
LOG_INFO "lvm2-testsuite卸载成功"
|
||||
else
|
||||
LOG_INFO "保持lvm2-testsuite安装状态"
|
||||
fi
|
||||
|
||||
LOG_INFO "测试完成"
|
||||
}
|
||||
|
||||
main "$@"
|
||||
@@ -1,94 +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-01-29
|
||||
# @License : Mulan PSL v2
|
||||
# @Desc : 使用--outdir参数指定输出文件的目录
|
||||
# ############################################
|
||||
|
||||
source "$OET_PATH/libs/locallibs/common_lib.sh"
|
||||
|
||||
function run_test() {
|
||||
LOG_INFO "开始测试:使用--outdir参数指定输出文件的目录"
|
||||
|
||||
# 步骤1:检查是否已安装lvm2-testsuite软件包
|
||||
LOG_INFO "步骤1:检查是否已安装lvm2-testsuite软件包"
|
||||
if dnf list installed lvm2-testsuite &>/dev/null; then
|
||||
LOG_INFO "lvm2-testsuite已安装,标记为需要保持安装状态"
|
||||
INSTALLED_BEFORE_TEST=true
|
||||
else
|
||||
LOG_INFO "lvm2-testsuite未安装,标记为需要测试后卸载"
|
||||
INSTALLED_BEFORE_TEST=false
|
||||
fi
|
||||
|
||||
# 步骤2:检查yum源中是否有lvm2-testsuite软件包
|
||||
LOG_INFO "步骤2:检查yum源中是否有lvm2-testsuite软件包"
|
||||
if ! dnf list available lvm2-testsuite &>/dev/null; then
|
||||
LOG_ERROR "yum源中未找到lvm2-testsuite软件包"
|
||||
exit 255
|
||||
fi
|
||||
|
||||
# 步骤3:如果未安装,则安装lvm2-testsuite软件包
|
||||
LOG_INFO "步骤3:如果未安装,则安装lvm2-testsuite软件包"
|
||||
if [ "$INSTALLED_BEFORE_TEST" = false ]; then
|
||||
dnf install -y lvm2-testsuite
|
||||
CHECK_RESULT $? 0 0 "安装lvm2-testsuite软件包失败"
|
||||
LOG_INFO "lvm2-testsuite软件包安装成功"
|
||||
fi
|
||||
|
||||
# 步骤4:检查--outdir参数是否支持
|
||||
LOG_INFO "步骤4:检查--outdir参数是否支持"
|
||||
if ! lvm2-testsuite --help | grep -q -- "--outdir"; then
|
||||
LOG_ERROR "lvm2-testsuite命令不支持--outdir参数"
|
||||
exit 255
|
||||
fi
|
||||
|
||||
# 步骤5:创建临时输出目录
|
||||
LOG_INFO "步骤5:创建临时输出目录"
|
||||
OUTPUT_DIR=$(mktemp -d)
|
||||
LOG_INFO "临时输出目录创建成功:$OUTPUT_DIR"
|
||||
|
||||
# 步骤6:使用--outdir参数运行lvm2-testsuite
|
||||
LOG_INFO "步骤6:使用--outdir参数运行lvm2-testsuite"
|
||||
lvm2-testsuite --outdir="$OUTPUT_DIR"
|
||||
CHECK_RESULT $? 0 0 "使用--outdir参数运行lvm2-testsuite失败"
|
||||
|
||||
# 步骤7:检查输出目录中是否有文件生成
|
||||
LOG_INFO "步骤7:检查输出目录中是否有文件生成"
|
||||
if [ -n "$(ls -A "$OUTPUT_DIR" 2>/dev/null)" ]; then
|
||||
LOG_INFO "输出目录中有文件生成,--outdir参数功能正常"
|
||||
else
|
||||
LOG_ERROR "输出目录中无文件生成,--outdir参数功能异常"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 步骤8:清理临时输出目录
|
||||
LOG_INFO "步骤8:清理临时输出目录"
|
||||
rm -rf "$OUTPUT_DIR"
|
||||
CHECK_RESULT $? 0 0 "清理临时输出目录失败"
|
||||
|
||||
# 步骤9:如果测试前未安装,则卸载lvm2-testsuite软件包
|
||||
LOG_INFO "步骤9:如果测试前未安装,则卸载lvm2-testsuite软件包"
|
||||
if [ "$INSTALLED_BEFORE_TEST" = false ]; then
|
||||
dnf remove -y lvm2-testsuite
|
||||
CHECK_RESULT $? 0 0 "卸载lvm2-testsuite软件包失败"
|
||||
LOG_INFO "lvm2-testsuite软件包卸载成功"
|
||||
else
|
||||
LOG_INFO "测试前已安装lvm2-testsuite,保持安装状态"
|
||||
fi
|
||||
|
||||
LOG_INFO "测试完成:使用--outdir参数指定输出文件的目录"
|
||||
}
|
||||
|
||||
main "$@"
|
||||
@@ -1,83 +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-01-29
|
||||
# @License : Mulan PSL v2
|
||||
# @Desc : 使用--testdir参数指定测试所在的目录
|
||||
# ############################################
|
||||
|
||||
source "$OET_PATH/libs/locallibs/common_lib.sh"
|
||||
|
||||
function run_test() {
|
||||
set -e
|
||||
|
||||
LOG_INFO "开始测试:使用--testdir参数指定测试所在的目录"
|
||||
|
||||
# 检查lvm2-testsuite是否已安装
|
||||
LOG_INFO "检查lvm2-testsuite是否已安装"
|
||||
if dnf list installed lvm2-testsuite &>/dev/null; then
|
||||
LOG_INFO "lvm2-testsuite已安装,标记为无需卸载"
|
||||
NEED_UNINSTALL=0
|
||||
else
|
||||
LOG_INFO "lvm2-testsuite未安装,标记为需要卸载"
|
||||
NEED_UNINSTALL=1
|
||||
fi
|
||||
|
||||
# 检查yum源中是否有lvm2-testsuite软件包
|
||||
LOG_INFO "检查yum源中是否有lvm2-testsuite软件包"
|
||||
if ! dnf list available lvm2-testsuite &>/dev/null; then
|
||||
LOG_ERROR "yum源中未找到lvm2-testsuite软件包"
|
||||
exit 255
|
||||
fi
|
||||
|
||||
# 如果未安装,则安装lvm2-testsuite
|
||||
if [ $NEED_UNINSTALL -eq 1 ]; then
|
||||
LOG_INFO "安装lvm2-testsuite软件包"
|
||||
dnf install -y lvm2-testsuite
|
||||
CHECK_RESULT $? 0 0 "安装lvm2-testsuite失败"
|
||||
fi
|
||||
|
||||
# 检查lvm2-testsuite命令是否支持--testdir参数
|
||||
LOG_INFO "检查lvm2-testsuite命令是否支持--testdir参数"
|
||||
if ! lvm2-testsuite --help 2>&1 | grep -q "\-\-testdir"; then
|
||||
LOG_ERROR "lvm2-testsuite命令不支持--testdir参数"
|
||||
exit 255
|
||||
fi
|
||||
|
||||
# 创建测试目录
|
||||
LOG_INFO "创建测试目录/tmp/test_lvm2"
|
||||
mkdir -p /tmp/test_lvm2
|
||||
CHECK_RESULT $? 0 0 "创建测试目录失败"
|
||||
|
||||
# 执行lvm2-testsuite命令,使用--testdir参数指定测试目录
|
||||
LOG_INFO "执行lvm2-testsuite命令,指定测试目录为/tmp/test_lvm2"
|
||||
lvm2-testsuite --testdir /tmp/test_lvm2
|
||||
CHECK_RESULT $? 0 0 "lvm2-testsuite执行失败"
|
||||
|
||||
# 清理测试目录
|
||||
LOG_INFO "清理测试目录/tmp/test_lvm2"
|
||||
rm -rf /tmp/test_lvm2
|
||||
CHECK_RESULT $? 0 0 "清理测试目录失败"
|
||||
|
||||
# 如果之前未安装lvm2-testsuite,则在测试结束后卸载
|
||||
if [ $NEED_UNINSTALL -eq 1 ]; then
|
||||
LOG_INFO "卸载lvm2-testsuite软件包"
|
||||
dnf remove -y lvm2-testsuite
|
||||
CHECK_RESULT $? 0 0 "卸载lvm2-testsuite失败"
|
||||
fi
|
||||
|
||||
LOG_INFO "测试完成:使用--testdir参数指定测试所在的目录"
|
||||
}
|
||||
|
||||
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-01-29
|
||||
# @License : Mulan PSL v2
|
||||
# @Desc : 使用--timeout参数设置被视为超时的静默周期
|
||||
# ############################################
|
||||
|
||||
source "$OET_PATH/libs/locallibs/common_lib.sh"
|
||||
|
||||
function run_test() {
|
||||
LOG_INFO "开始测试:使用--timeout参数设置被视为超时的静默周期"
|
||||
|
||||
# 检查是否已安装lvm2-testsuite
|
||||
LOG_INFO "检查是否已安装lvm2-testsuite"
|
||||
if rpm -q lvm2-testsuite > /dev/null 2>&1; then
|
||||
LOG_INFO "lvm2-testsuite已安装,测试结束后将保持安装状态"
|
||||
INSTALLED=1
|
||||
else
|
||||
LOG_INFO "lvm2-testsuite未安装,将在测试前安装"
|
||||
INSTALLED=0
|
||||
fi
|
||||
|
||||
# 检查yum源中是否有lvm2-testsuite软件包
|
||||
LOG_INFO "检查yum源中是否有lvm2-testsuite软件包"
|
||||
dnf list available lvm2-testsuite > /dev/null 2>&1
|
||||
CHECK_RESULT $? 0 0 "yum源中未找到lvm2-testsuite软件包"
|
||||
if [ $? -ne 0 ]; then
|
||||
LOG_ERROR "yum源中未找到lvm2-testsuite软件包"
|
||||
exit 255
|
||||
fi
|
||||
|
||||
# 如果未安装,则安装lvm2-testsuite
|
||||
if [ $INSTALLED -eq 0 ]; then
|
||||
LOG_INFO "安装lvm2-testsuite"
|
||||
dnf install -y lvm2-testsuite
|
||||
CHECK_RESULT $? 0 0 "安装lvm2-testsuite失败"
|
||||
fi
|
||||
|
||||
# 检查--timeout参数是否被支持
|
||||
LOG_INFO "检查--timeout参数是否被支持"
|
||||
lvm2-testsuite --help 2>&1 | grep -q -- "--timeout"
|
||||
CHECK_RESULT $? 0 0 "lvm2-testsuite不支持--timeout参数"
|
||||
if [ $? -ne 0 ]; then
|
||||
LOG_ERROR "lvm2-testsuite不支持--timeout参数"
|
||||
# 恢复环境:如果之前未安装,则卸载软件包
|
||||
if [ $INSTALLED -eq 0 ]; then
|
||||
LOG_INFO "恢复环境:卸载lvm2-testsuite"
|
||||
dnf remove -y lvm2-testsuite
|
||||
fi
|
||||
exit 255
|
||||
fi
|
||||
|
||||
# 使用--timeout参数执行测试
|
||||
LOG_INFO "使用--timeout参数执行测试"
|
||||
lvm2-testsuite --timeout 30
|
||||
CHECK_RESULT $? 0 0 "使用--timeout参数执行测试失败"
|
||||
|
||||
# 恢复环境:如果之前未安装,则卸载软件包
|
||||
if [ $INSTALLED -eq 0 ]; then
|
||||
LOG_INFO "恢复环境:卸载lvm2-testsuite"
|
||||
dnf remove -y lvm2-testsuite
|
||||
CHECK_RESULT $? 0 0 "卸载lvm2-testsuite失败"
|
||||
else
|
||||
LOG_INFO "保持lvm2-testsuite安装状态"
|
||||
fi
|
||||
|
||||
LOG_INFO "测试完成"
|
||||
}
|
||||
|
||||
main "$@"
|
||||
@@ -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-01-29
|
||||
# @License : Mulan PSL v2
|
||||
# @Desc : 使用--verbose参数以更详细的格式运行自动化测试
|
||||
# ############################################
|
||||
|
||||
source "$OET_PATH/libs/locallibs/common_lib.sh"
|
||||
|
||||
function run_test() {
|
||||
LOG_INFO "开始测试:使用--verbose参数以更详细的格式运行自动化测试"
|
||||
|
||||
# 检查是否已安装lvm2-testsuite
|
||||
if dnf list installed lvm2-testsuite &> /dev/null; then
|
||||
LOG_INFO "lvm2-testsuite已安装,脚本结束后将保持安装状态"
|
||||
INSTALLED_BEFORE=1
|
||||
else
|
||||
LOG_INFO "lvm2-testsuite未安装,将在测试过程中安装,并在脚本结束前卸载"
|
||||
INSTALLED_BEFORE=0
|
||||
fi
|
||||
|
||||
# 检查yum源中是否有lvm2-testsuite软件包
|
||||
LOG_INFO "检查yum源中是否有lvm2-testsuite软件包"
|
||||
if ! dnf list available lvm2-testsuite &> /dev/null; then
|
||||
LOG_ERROR "yum源中未找到lvm2-testsuite软件包"
|
||||
exit 255
|
||||
fi
|
||||
|
||||
# 如果未安装,则安装lvm2-testsuite
|
||||
if [ $INSTALLED_BEFORE -eq 0 ]; then
|
||||
LOG_INFO "安装lvm2-testsuite软件包"
|
||||
dnf install -y lvm2-testsuite
|
||||
CHECK_RESULT $? 0 0 "安装lvm2-testsuite失败"
|
||||
fi
|
||||
|
||||
# 检查lvm2-testsuite命令是否支持--verbose参数
|
||||
LOG_INFO "检查lvm2-testsuite命令是否支持--verbose参数"
|
||||
if ! lvm2-testsuite --help 2>&1 | grep -q -- "--verbose"; then
|
||||
LOG_ERROR "lvm2-testsuite命令不支持--verbose参数"
|
||||
# 如果之前未安装,则需要卸载已安装的软件包
|
||||
if [ $INSTALLED_BEFORE -eq 0 ]; then
|
||||
dnf remove -y lvm2-testsuite
|
||||
fi
|
||||
exit 255
|
||||
fi
|
||||
|
||||
# 使用--verbose参数运行lvm2-testsuite
|
||||
LOG_INFO "使用--verbose参数运行lvm2-testsuite"
|
||||
lvm2-testsuite --verbose
|
||||
CHECK_RESULT $? 0 0 "使用--verbose参数运行lvm2-testsuite失败"
|
||||
|
||||
# 清理环境:如果之前未安装,则卸载lvm2-testsuite
|
||||
if [ $INSTALLED_BEFORE -eq 0 ]; then
|
||||
LOG_INFO "卸载lvm2-testsuite软件包"
|
||||
dnf remove -y lvm2-testsuite
|
||||
CHECK_RESULT $? 0 0 "卸载lvm2-testsuite失败"
|
||||
fi
|
||||
|
||||
LOG_INFO "测试完成:使用--verbose参数以更详细的格式运行自动化测试"
|
||||
}
|
||||
|
||||
main "$@"
|
||||
@@ -1,119 +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-01-29
|
||||
# @License : Mulan PSL v2
|
||||
# @Desc : 使用--watch参数指定要监视和打印的文件列表
|
||||
# ############################################
|
||||
|
||||
source "$OET_PATH/libs/locallibs/common_lib.sh"
|
||||
|
||||
function run_test() {
|
||||
# 检查是否以root用户运行
|
||||
if [[ $EUID -ne 0 ]]; then
|
||||
LOG_ERROR "此脚本必须以root权限运行"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 定义软件包名称
|
||||
PACKAGE_NAME="lvm2-testsuite"
|
||||
|
||||
# 步骤1: 检查软件包是否已在yum源中
|
||||
LOG_INFO "步骤1: 检查软件包是否在yum源中"
|
||||
dnf list available $PACKAGE_NAME &> /dev/null
|
||||
if [[ $? -ne 0 ]]; then
|
||||
LOG_ERROR "软件包 $PACKAGE_NAME 不在yum源中"
|
||||
exit 255
|
||||
fi
|
||||
|
||||
# 步骤2: 检查系统是否已安装软件包
|
||||
LOG_INFO "步骤2: 检查系统是否已安装软件包"
|
||||
rpm -q $PACKAGE_NAME &> /dev/null
|
||||
if [[ $? -eq 0 ]]; then
|
||||
LOG_INFO "软件包 $PACKAGE_NAME 已安装,测试结束后将保持安装状态"
|
||||
INSTALLED_BEFORE_TEST=1
|
||||
else
|
||||
LOG_INFO "软件包 $PACKAGE_NAME 未安装,将在测试前安装并在测试后卸载"
|
||||
INSTALLED_BEFORE_TEST=0
|
||||
fi
|
||||
|
||||
# 步骤3: 如果未安装,则安装软件包
|
||||
if [[ $INSTALLED_BEFORE_TEST -eq 0 ]]; then
|
||||
LOG_INFO "步骤3: 安装软件包 $PACKAGE_NAME"
|
||||
dnf install -y $PACKAGE_NAME
|
||||
CHECK_RESULT $? 0 0 "安装软件包 $PACKAGE_NAME 失败"
|
||||
fi
|
||||
|
||||
# 步骤4: 检查--watch参数是否支持
|
||||
LOG_INFO "步骤4: 检查--watch参数是否支持"
|
||||
if ! lvm2-testsuite --help 2>&1 | grep -q -- "--watch"; then
|
||||
LOG_ERROR "lvm2-testsuite 命令不支持 --watch 参数"
|
||||
if [[ $INSTALLED_BEFORE_TEST -eq 0 ]]; then
|
||||
LOG_INFO "清理环境:卸载软件包 $PACKAGE_NAME"
|
||||
dnf remove -y $PACKAGE_NAME
|
||||
fi
|
||||
exit 255
|
||||
fi
|
||||
|
||||
# 步骤5: 创建测试文件
|
||||
LOG_INFO "步骤5: 创建测试文件"
|
||||
TEST_FILE1="/tmp/test_file1.txt"
|
||||
TEST_FILE2="/tmp/test_file2.txt"
|
||||
echo "测试文件1内容" > $TEST_FILE1
|
||||
echo "测试文件2内容" > $TEST_FILE2
|
||||
CHECK_RESULT $? 0 0 "创建测试文件失败"
|
||||
|
||||
# 步骤6: 执行带--watch参数的测试
|
||||
LOG_INFO "步骤6: 执行带--watch参数的测试"
|
||||
# 使用timeout防止命令长时间运行
|
||||
timeout 5s lvm2-testsuite --watch $TEST_FILE1 $TEST_FILE2 &> /tmp/watch_output.txt
|
||||
EXIT_CODE=$?
|
||||
# 检查命令是否被timeout终止(退出码124)或成功执行
|
||||
if [[ $EXIT_CODE -eq 124 ]] || [[ $EXIT_CODE -eq 0 ]]; then
|
||||
LOG_INFO "lvm2-testsuite --watch 命令执行成功或被正常终止"
|
||||
CHECK_RESULT 0 0 0 "命令执行失败"
|
||||
else
|
||||
LOG_ERROR "lvm2-testsuite --watch 命令执行失败,退出码: $EXIT_CODE"
|
||||
CHECK_RESULT $EXIT_CODE 0 1 "命令执行失败"
|
||||
fi
|
||||
|
||||
# 步骤7: 检查输出是否包含文件信息
|
||||
LOG_INFO "步骤7: 检查输出是否包含监视的文件信息"
|
||||
if grep -q "$TEST_FILE1" /tmp/watch_output.txt && grep -q "$TEST_FILE2" /tmp/watch_output.txt; then
|
||||
LOG_INFO "输出中包含监视的文件信息"
|
||||
CHECK_RESULT 0 0 0 "输出中未找到监视的文件信息"
|
||||
else
|
||||
LOG_ERROR "输出中未找到监视的文件信息"
|
||||
CHECK_RESULT 1 0 0 "输出中未找到监视的文件信息"
|
||||
fi
|
||||
|
||||
# 步骤8: 清理测试文件
|
||||
LOG_INFO "步骤8: 清理测试文件"
|
||||
rm -f $TEST_FILE1 $TEST_FILE2 /tmp/watch_output.txt
|
||||
CHECK_RESULT $? 0 0 "清理测试文件失败"
|
||||
|
||||
# 步骤9: 恢复环境
|
||||
LOG_INFO "步骤9: 恢复环境"
|
||||
if [[ $INSTALLED_BEFORE_TEST -eq 0 ]]; then
|
||||
LOG_INFO "卸载软件包 $PACKAGE_NAME"
|
||||
dnf remove -y $PACKAGE_NAME
|
||||
CHECK_RESULT $? 0 0 "卸载软件包 $PACKAGE_NAME 失败"
|
||||
else
|
||||
LOG_INFO "保持软件包 $PACKAGE_NAME 的安装状态"
|
||||
fi
|
||||
|
||||
LOG_INFO "测试完成"
|
||||
}
|
||||
|
||||
main "$@"
|
||||
@@ -1,94 +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-01-29
|
||||
# @License : Mulan PSL v2
|
||||
# @Desc : 使用--workdir参数指定运行测试时的工作目录
|
||||
# ############################################
|
||||
|
||||
source "$OET_PATH/libs/locallibs/common_lib.sh"
|
||||
|
||||
function run_test() {
|
||||
# 定义变量
|
||||
TEST_PACKAGE="lvm2-testsuite"
|
||||
WORKDIR_PARAM="--workdir"
|
||||
WORKDIR_PATH="/tmp/lvm2_test_workdir"
|
||||
|
||||
# 检查软件包是否存在
|
||||
LOG_INFO "检查软件包 $TEST_PACKAGE 是否在yum源中"
|
||||
dnf list available "$TEST_PACKAGE" &>/dev/null
|
||||
if [ $? -ne 0 ]; then
|
||||
LOG_ERROR "软件包 $TEST_PACKAGE 不在yum源中"
|
||||
exit 255
|
||||
fi
|
||||
|
||||
# 检查环境是否已安装
|
||||
LOG_INFO "检查环境是否已安装 $TEST_PACKAGE"
|
||||
rpm -q "$TEST_PACKAGE" &>/dev/null
|
||||
if [ $? -eq 0 ]; then
|
||||
LOG_INFO "环境已安装 $TEST_PACKAGE,标记为已安装状态"
|
||||
INSTALLED="true"
|
||||
else
|
||||
LOG_INFO "环境未安装 $TEST_PACKAGE,标记为未安装状态"
|
||||
INSTALLED="false"
|
||||
fi
|
||||
|
||||
# 如果未安装,则安装软件包
|
||||
if [ "$INSTALLED" = "false" ]; then
|
||||
LOG_INFO "安装软件包 $TEST_PACKAGE"
|
||||
dnf install -y "$TEST_PACKAGE"
|
||||
CHECK_RESULT $? 0 0 "安装软件包 $TEST_PACKAGE 失败"
|
||||
fi
|
||||
|
||||
# 检查 --workdir 参数是否支持
|
||||
LOG_INFO "检查 lvm2-testsuite 是否支持 $WORKDIR_PARAM 参数"
|
||||
lvm2-testsuite --help 2>&1 | grep -q "$WORKDIR_PARAM"
|
||||
if [ $? -ne 0 ]; then
|
||||
LOG_ERROR "lvm2-testsuite 不支持 $WORKDIR_PARAM 参数"
|
||||
exit 255
|
||||
fi
|
||||
|
||||
# 创建工作目录
|
||||
LOG_INFO "创建工作目录 $WORKDIR_PATH"
|
||||
mkdir -p "$WORKDIR_PATH"
|
||||
CHECK_RESULT $? 0 0 "创建工作目录 $WORKDIR_PATH 失败"
|
||||
|
||||
# 使用 --workdir 参数运行测试
|
||||
LOG_INFO "使用 $WORKDIR_PARAM 参数指定工作目录运行测试"
|
||||
lvm2-testsuite "$WORKDIR_PARAM" "$WORKDIR_PATH"
|
||||
CHECK_RESULT $? 0 0 "使用 $WORKDIR_PARAM 参数运行测试失败"
|
||||
|
||||
# 检查工作目录是否被使用
|
||||
LOG_INFO "检查工作目录 $WORKDIR_PATH 是否被使用"
|
||||
if [ -f "$WORKDIR_PATH/test.log" ] || [ -d "$WORKDIR_PATH/results" ]; then
|
||||
LOG_INFO "工作目录 $WORKDIR_PATH 被成功使用"
|
||||
else
|
||||
LOG_ERROR "工作目录 $WORKDIR_PATH 未被使用"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 清理工作目录
|
||||
LOG_INFO "清理工作目录 $WORKDIR_PATH"
|
||||
rm -rf "$WORKDIR_PATH"
|
||||
CHECK_RESULT $? 0 0 "清理工作目录 $WORKDIR_PATH 失败"
|
||||
|
||||
# 如果之前未安装,则卸载软件包
|
||||
if [ "$INSTALLED" = "false" ]; then
|
||||
LOG_INFO "卸载软件包 $TEST_PACKAGE"
|
||||
dnf remove -y "$TEST_PACKAGE"
|
||||
CHECK_RESULT $? 0 0 "卸载软件包 $TEST_PACKAGE 失败"
|
||||
fi
|
||||
}
|
||||
|
||||
main "$@"
|
||||
Reference in New Issue
Block a user