forked from redrsoe2100/os-autotest
create testsuite for src at rpm at
This commit is contained in:
@@ -0,0 +1,98 @@
|
||||
#!/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-10
|
||||
# @License : Mulan PSL v2
|
||||
# @Desc : Test basic functionality of at package
|
||||
# ############################################
|
||||
|
||||
source "$OET_PATH/libs/locallibs/common_lib.sh"
|
||||
|
||||
function run_test() {
|
||||
|
||||
LOG_INFO "开始测试 at 软件包的基本功能"
|
||||
|
||||
# 检查是否已安装 at 软件包
|
||||
if rpm -q at &> /dev/null; then
|
||||
LOG_INFO "at 软件包已安装,测试完成后将保持安装状态"
|
||||
installed=true
|
||||
else
|
||||
LOG_INFO "at 软件包未安装,将在测试完成后卸载"
|
||||
installed=false
|
||||
fi
|
||||
|
||||
# 检查 yum 源中是否有 at 软件包
|
||||
LOG_INFO "检查 yum 源中是否存在 at 软件包"
|
||||
if ! dnf list available at &> /dev/null; then
|
||||
LOG_ERROR "yum 源中未找到 at 软件包"
|
||||
exit 255
|
||||
fi
|
||||
|
||||
# 安装 at 软件包
|
||||
LOG_INFO "安装 at 软件包"
|
||||
dnf install -y at || {
|
||||
LOG_ERROR "安装 at 软件包失败"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# 检查 at 命令是否可用
|
||||
LOG_INFO "检查 at 命令是否可用"
|
||||
if ! command -v at &> /dev/null; then
|
||||
LOG_ERROR "at 命令未找到"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 测试 atd.service是否运行正常
|
||||
LOG_INFO "启动并检查atd.service状态"
|
||||
systemctl start atd || {
|
||||
LOG_ERROR "启动atd.service失败"
|
||||
exit $?
|
||||
}
|
||||
CHECK_RESULT $? 0 0 "启动atd.service失败"
|
||||
|
||||
systemctl status atd || {
|
||||
LOG_ERROR "检查atd.service状态失败"
|
||||
exit $?
|
||||
}
|
||||
CHECK_RESULT $? 0 0 "检查atd.service状态失败"
|
||||
|
||||
#测试基本at命令功能:添加任务并检查任务列表
|
||||
LOG_INFO "测试基本at命令功能:添加任务并检查任务列表"
|
||||
echo "ls > /dev/null" | at now +1 minute || {
|
||||
LOG_ERROR "添加任务失败"
|
||||
exit $?
|
||||
}
|
||||
CHECK_RESULT $? 0 0 "添加任务失败"
|
||||
|
||||
sleep 5 #等待任务被处理
|
||||
|
||||
atq || {
|
||||
LOG_ERROR"查看任务列表失败"
|
||||
exit $?
|
||||
}
|
||||
CHECK_RESULT $? 0 0 "查看任务列表失败"
|
||||
|
||||
#清理环境:如果最初未安装则卸载at软件包
|
||||
if [ "$installed" = false ]; then
|
||||
LOG_INFO"卸载at软件包以恢复环境"
|
||||
dnf remove -y || {
|
||||
LOG_ERROR"卸载at软件包失败"
|
||||
exit$?
|
||||
}
|
||||
fi
|
||||
|
||||
LOG_INFO"测试完成"
|
||||
}
|
||||
|
||||
main "$@"
|
||||
Reference in New Issue
Block a user