update testcase for testsuite python3-speechd

This commit is contained in:
2026-04-22 20:11:21 +08:00
parent 925dfed14f
commit 4ee4daa44c
19 changed files with 0 additions and 1535 deletions

View File

@@ -1,78 +0,0 @@
{
"path": "$OET_PATH/testcases/function_test/pkg_test/speech-dispatcher/python3-speechd",
"machine num": 1,
"cases": [
{
"name": "test_python3-speechd_function_init",
"desc": "Test initialization of speechd client"
},
{
"name": "test_python3-speechd_function_speak",
"desc": "Test text-to-speech functionality"
},
{
"name": "test_python3-speechd_function_pause",
"desc": "Test pause speech functionality"
},
{
"name": "test_python3-speechd_function_resume",
"desc": "Test resume speech functionality"
},
{
"name": "test_python3-speechd_function_stop",
"desc": "Test stop speech functionality"
},
{
"name": "test_python3-speechd_function_set_rate",
"desc": "Test speech rate setting"
},
{
"name": "test_python3-speechd_function_set_pitch",
"desc": "Test speech pitch setting"
},
{
"name": "test_python3-speechd_function_set_volume",
"desc": "Test speech volume setting"
},
{
"name": "test_python3-speechd_function_set_lang",
"desc": "Test language setting"
},
{
"name": "test_python3-speechd_function_config",
"desc": "Test configuration loading"
},
{
"name": "test_python3-speechd_function_install",
"desc": "Test installation of python3-speechd package"
},
{
"name": "test_python3-speechd_function_import",
"desc": "Test importing speechd module"
},
{
"name": "test_python3-speechd_function_client",
"desc": "Test creating speechd client"
},
{
"name": "test_python3-speechd_function_rate",
"desc": "Test adjusting speech rate"
},
{
"name": "test_python3-speechd_function_volume",
"desc": "Test adjusting speech volume"
},
{
"name": "test_python3-speechd_function_language",
"desc": "Test setting language"
},
{
"name": "test_python3-speechd_function_status",
"desc": "Test checking client status"
},
{
"name": "test_python3-speechd_function_uninstall",
"desc": "Test uninstalling package"
}
]
}

View File

@@ -1,95 +0,0 @@
#!/usr/bin/bash
# Copyright (c) 2024 ISCAS .ALL rights reserved.
# This program is licensed under Mulan PSL v2.
# You can use it according to the terms and conditions of the Mulan PSL v2.
# http://license.coscl.org.cn/MulanPSL2
# THIS PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
# See the Mulan PSL v2 for more details.
# #############################################
# @Author : honghua
# @Contact : honghua@iscas.ac.cn
# @Date : 2026-03-06
# @License : Mulan PSL v2
# @Desc : Test creating speechd client
# ############################################
source "$OET_PATH/libs/locallibs/common_lib.sh"
function run_test() {
LOG_INFO "开始测试创建speechd客户端"
LOG_INFO "步骤1: 检查是否已安装python3-speechd软件包"
if rpm -q python3-speechd &> /dev/null; then
LOG_INFO "python3-speechd已安装测试结束后将保持安装状态"
installed_before_test=true
else
LOG_INFO "python3-speechd未安装将在测试中安装并在结束后卸载"
installed_before_test=false
fi
LOG_INFO "步骤2: 检查yum源中是否存在python3-speechd软件包"
if ! dnf list available python3-speechd &> /dev/null; then
LOG_ERROR "yum源中未找到python3-speechd软件包"
exit 255
fi
LOG_INFO "步骤3: 如果未安装则安装python3-speechd"
if [ "$installed_before_test" = false ]; then
dnf install -y python3-speechd
CHECK_RESULT $? 0 0 "安装python3-speechd失败"
fi
LOG_INFO "步骤4: 检查speechd模块是否可用"
python3 -c "import speechd"
CHECK_RESULT $? 0 0 "Python无法导入speechd模块"
LOG_INFO "步骤5: 尝试创建SpeechClient对象"
python3 -c "
import speechd
try:
client = speechd.SSIPClient("test_client")
LOG_INFO("成功创建SpeechClient对象")
client.close()
except Exception as e:
LOG_ERROR(f"创建SpeechClient失败: {e}")
exit(1)
"
CHECK_RESULT $? 0 0 "创建SpeechClient对象失败"
LOG_INFO "步骤6: 测试SpeechClient基本方法不实际播放"
python3 -c "
import speechd
client = speechd.SSIPClient("test_client")
try:
# 测试设置优先级
client.set_priority(speechd.Priority.MESSAGE)
# 测试设置语言
client.set_language("en")
# 测试说话设置阻止为True避免实际播放
client.speak("Test message", block=True)
LOG_INFO("SpeechClient基本方法测试成功")
except Exception as e:
LOG_ERROR(f"SpeechClient方法测试失败: {e}")
exit(1)
finally:
client.close()
"
CHECK_RESULT $? 0 0 "SpeechClient基本方法测试失败"
LOG_INFO "步骤7: 环境清理"
if [ "$installed_before_test" = false ]; then
LOG_INFO "卸载测试安装的python3-speechd软件包"
dnf remove -y python3-speechd
CHECK_RESULT $? 0 0 "卸载python3-speechd失败"
else
LOG_INFO "保持python3-speechd安装状态"
fi
LOG_INFO "测试完成创建speechd客户端测试通过"
}
main "$@"

View File

@@ -1,64 +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-06
# @License : Mulan PSL v2
# @Desc : Test configuration loading
# ############################################
source "$OET_PATH/libs/locallibs/common_lib.sh"
function run_test() {
LOG_INFO "开始测试Test configuration loading"
# 检查软件包是否已安装
LOG_INFO "检查python3-speechd是否已安装"
if rpm -q python3-speechd &>/dev/null; then
LOG_INFO "python3-speechd已安装脚本结束时将保持安装状态"
INSTALLED=true
else
LOG_INFO "python3-speechd未安装将在测试结束后卸载"
INSTALLED=false
fi
# 检查yum源中是否有python3-speechd软件包
LOG_INFO "检查yum源中是否有python3-speechd软件包"
if ! dnf list available python3-speechd &>/dev/null; then
LOG_ERROR "yum源中未找到python3-speechd软件包"
exit 255
fi
# 如果未安装,则安装软件包
if [ "$INSTALLED" = false ]; then
LOG_INFO "开始安装python3-speechd"
dnf install -y python3-speechd
CHECK_RESULT $? 0 0 "安装python3-speechd失败"
fi
# 测试配置加载功能
LOG_INFO "测试配置加载功能"
speechd-config --test-load
CHECK_RESULT $? 0 0 "配置加载失败"
# 如果之前未安装,则卸载软件包
if [ "$INSTALLED" = false ]; then
LOG_INFO "卸载python3-speechd"
dnf remove -y python3-speechd
CHECK_RESULT $? 0 0 "卸载python3-speechd失败"
fi
LOG_INFO "测试完成Test configuration loading"
}
main "$@"

View File

@@ -1,69 +0,0 @@
#!/usr/bin/bash
# Copyright (c) 2024 ISCAS .ALL rights reserved.
# This program is licensed under Mulan PSL v2.
# You can use it according to the terms and conditions of the Mulan PSL v2.
# http://license.coscl.org.cn/MulanPSL2
# THIS PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
# See the Mulan PSL v2 for more details.
# #############################################
# @Author : honghua
# @Contact : honghua@iscas.ac.cn
# @Date : 2026-03-06
# @License : Mulan PSL v2
# @Desc : Test importing speechd module
# ############################################
source "$OET_PATH/libs/locallibs/common_lib.sh"
function run_test() {
# 定义软件包名称和模块名称
PACKAGE_NAME="python3-speechd"
MODULE_NAME="speechd"
# 步骤1检查yum源中是否存在指定的软件包
LOG_INFO "步骤1检查yum源中是否存在软件包 $PACKAGE_NAME"
if ! dnf list available "$PACKAGE_NAME" &>/dev/null; then
LOG_ERROR "软件包 $PACKAGE_NAME 在yum源中不存在"
exit 255
fi
# 步骤2检查是否已经安装软件包
LOG_INFO "步骤2检查是否已经安装软件包 $PACKAGE_NAME"
if rpm -q "$PACKAGE_NAME" &>/dev/null; then
LOG_INFO "软件包 $PACKAGE_NAME 已经安装,标记为保持安装状态"
KEEP_INSTALLED=1
else
LOG_INFO "软件包 $PACKAGE_NAME 未安装,标记为需要卸载"
KEEP_INSTALLED=0
fi
# 步骤3如果未安装则安装软件包
if [ "$KEEP_INSTALLED" -eq 0 ]; then
LOG_INFO "步骤3安装软件包 $PACKAGE_NAME"
dnf install -y "$PACKAGE_NAME"
CHECK_RESULT $? 0 0 "安装软件包 $PACKAGE_NAME 失败"
fi
# 步骤4测试导入 speechd 模块
LOG_INFO "步骤4测试导入 $MODULE_NAME 模块"
python3 -c "import $MODULE_NAME"
CHECK_RESULT $? 0 0 "导入 $MODULE_NAME 模块失败"
# 步骤5清理环境
LOG_INFO "步骤5清理环境"
if [ "$KEEP_INSTALLED" -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 "$@"

View File

@@ -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 : 2025-12-01
# @License : Mulan PSL v2
# @Desc : Test initialization of speechd client
# ############################################
source "$OET_PATH/libs/locallibs/common_lib.sh"
function run_test() {
# 检查环境是否已安装python3-speechd
LOG_INFO "检查环境是否已安装python3-speechd"
if dnf list installed python3-speechd &> /dev/null; then
LOG_INFO "python3-speechd已安装"
installed=true
else
LOG_INFO "python3-speechd未安装"
installed=false
fi
# 检查yum源中是否有python3-speechd软件包
LOG_INFO "检查yum源中是否有python3-speechd软件包"
if ! dnf list available python3-speechd &> /dev/null; then
LOG_ERROR "yum源中未找到python3-speechd软件包"
exit 255
fi
# 如果未安装则安装python3-speechd
if [ "$installed" = false ]; then
LOG_INFO "安装python3-speechd"
dnf install -y python3-speechd
CHECK_RESULT $? 0 0 "安装python3-speechd失败"
fi
# 测试speechd客户端初始化
LOG_INFO "测试speechd客户端初始化"
speech-dispatcher --version &> /dev/null
CHECK_RESULT $? 0 0 "speech-dispatcher命令不存在或不支持"
# 执行speechd客户端初始化测试命令
LOG_INFO "执行speechd客户端初始化测试命令"
python3 -c "import speechd; client = speechd.Client()" &> /dev/null
CHECK_RESULT $? 0 0 "speechd客户端初始化失败"
# 清理环境如果脚本开始时未安装则卸载python3-speechd
if [ "$installed" = false ]; then
LOG_INFO "卸载python3-speechd"
dnf remove -y python3-speechd
CHECK_RESULT $? 0 0 "卸载python3-speech失败"
}
main "$@"

View File

@@ -1,134 +0,0 @@
#!/usr/bin/bash
# Copyright (c) 2024 ISCAS .ALL rights reserved.
# This program is licensed under Mulan PSL v2.
# You can use it according to the terms and conditions of the Mulan PSL v2.
# http://license.coscl.org.cn/MulanPSL2
# THIS PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
# See the Mulan PSL v2 for more details.
# #############################################
# @Author : honghua
# @Contact : honghua@iscas.ac.cn
# @Date : 2026-03-06
# @License : Mulan PSL v2
# @Desc : Test installation of python3-speechd package
# ############################################
source "$OET_PATH/libs/locallibs/common_lib.sh"
function run_test() {
# 定义变量
PACKAGE_NAME="python3-speechd"
LOG_FILE="/tmp/test_${PACKAGE_NAME}_$(date +%Y%m%d_%H%M%S).log"
# 日志函数(直接使用)
LOG_INFO() {
echo "[INFO] $*" | tee -a "$LOG_FILE"
}
LOG_ERROR() {
echo "[ERROR] $*" | tee -a "$LOG_FILE"
}
# 检查包是否在yum源中
check_package_in_repo() {
LOG_INFO "检查yum源中是否存在软件包: $PACKAGE_NAME"
dnf list available "$PACKAGE_NAME" &>/dev/null
if [ $? -ne 0 ]; then
LOG_ERROR "软件包 $PACKAGE_NAME 不在yum源中"
exit 255
fi
LOG_INFO "软件包 $PACKAGE_NAME 存在于yum源中"
}
# 检查包是否已安装
check_package_installed() {
LOG_INFO "检查软件包 $PACKAGE_NAME 是否已安装"
rpm -q "$PACKAGE_NAME" &>/dev/null
if [ $? -eq 0 ]; then
LOG_INFO "软件包 $PACKAGE_NAME 已安装"
return 0
else
LOG_INFO "软件包 $PACKAGE_NAME 未安装"
return 1
fi
}
# 安装软件包
install_package() {
LOG_INFO "安装软件包: $PACKAGE_NAME"
dnf install -y "$PACKAGE_NAME"
CHECK_RESULT $? 0 0 "安装软件包 $PACKAGE_NAME 失败"
LOG_INFO "软件包 $PACKAGE_NAME 安装成功"
}
# 卸载软件包
uninstall_package() {
LOG_INFO "卸载软件包: $PACKAGE_NAME"
dnf remove -y "$PACKAGE_NAME"
CHECK_RESULT $? 0 0 "卸载软件包 $PACKAGE_NAME 失败"
LOG_INFO "软件包 $PACKAGE_NAME 卸载成功"
}
# 测试软件包功能
test_package_function() {
LOG_INFO "测试软件包 $PACKAGE_NAME 的基本功能"
# 检查speechd模块是否可以导入
python3 -c "import speechd" 2>&1
CHECK_RESULT $? 0 0 "python3-speechd 模块导入失败"
LOG_INFO "python3-speechd 模块导入成功"
# 检查speechd客户端是否可以创建
python3 -c "
import speechd
client = speechd.SSIPClient("test_client")
if client:
print("SSIPClient创建成功")
client.close()
else:
print("SSIPClient创建失败")
exit(1)
" 2>&1 | grep -q "SSIPClient创建成功"
CHECK_RESULT $? 0 0 "speechd SSIPClient 创建失败"
LOG_INFO "speechd SSIPClient 创建成功"
}
# 主测试流程
main() {
LOG_INFO "开始测试 python3-speechd 软件包安装"
# 步骤1: 检查软件包是否在yum源中
check_package_in_repo
# 步骤2: 检查软件包是否已安装
check_package_installed
local was_installed=$?
# 步骤3: 如果未安装,则安装软件包
if [ $was_installed -eq 1 ]; then
install_package
fi
# 步骤4: 测试软件包功能
test_package_function
# 步骤5: 环境恢复
LOG_INFO "恢复测试环境"
if [ $was_installed -eq 1 ]; then
# 如果测试前未安装,则卸载软件包
uninstall_package
else
LOG_INFO "测试前软件包已安装,保持安装状态"
fi
LOG_INFO "测试完成"
}
# 执行主函数
main "$@"
}
main "$@"

View File

@@ -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-03-06
# @License : Mulan PSL v2
# @Desc : Test setting language
# ############################################
source "$OET_PATH/libs/locallibs/common_lib.sh"
function run_test() {
LOG_INFO "开始测试Test setting language"
LOG_INFO "步骤1检查系统中是否已安装python3-speechd软件包"
if dnf list installed python3-speechd > /dev/null 2>&1; then
LOG_INFO "python3-speechd已安装测试结束后将保持安装状态"
INSTALLED=true
else
LOG_INFO "python3-speechd未安装将在测试过程中安装"
INSTALLED=false
fi
LOG_INFO "步骤2检查yum源中是否有python3-speechd软件包"
if ! dnf list available python3-speechd > /dev/null 2>&1; then
LOG_ERROR "yum源中没有python3-speechd软件包"
exit 255
fi
if [ "$INSTALLED" = false ]; then
LOG_INFO "步骤3安装python3-speechd软件包"
dnf install -y python3-speechd
CHECK_RESULT $? 0 0 "安装python3-speechd失败"
fi
LOG_INFO "步骤4测试设置语言功能"
speechd-set-language --help > /dev/null 2>&1
if [ $? -eq 255 ]; then
LOG_ERROR "speechd-set-language命令不支持或参数不存在"
exit 255
fi
LOG_INFO "步骤5尝试设置语言为英语en"
speechd-set-language en
CHECK_RESULT $? 0 0 "设置语言为英语失败"
LOG_INFO "步骤6尝试设置语言为中文zh"
speechd-set-language zh
CHECK_RESULT $? 0 0 "设置语言为中文失败"
LOG_INFO "步骤7尝试设置不存在的语言xx"
speechd-set-language xx
if [ $? -eq 0 ]; then
LOG_ERROR "设置不存在的语言应该失败"
exit 1
else
LOG_INFO "设置不存在的语言失败,符合预期"
fi
LOG_INFO "步骤8清理环境"
if [ "$INSTALLED" = false ]; then
LOG_INFO "卸载python3-speechd软件包"
dnf remove -y python3-speechd
CHECK_RESULT $? 0 0 "卸载python3-speechd失败"
fi
LOG_INFO "测试完成"
}
main "$@"

View File

@@ -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 : 2025-12-01
# @License : Mulan PSL v2
# @Desc : Test pause speech functionality
# ############################################
source "$OET_PATH/libs/locallibs/common_lib.sh"
function run_test() {
# 检查是否已安装python3-speechd
if dnf list installed python3-speechd &>/dev/null; then
LOG_INFO "python3-speechd已安装脚本结束后将保持安装状态"
INSTALLED=true
else
LOG_INFO "python3-speechd未安装脚本结束后将卸载"
INSTALLED=false
fi
# 检查yum源中是否有python3-speechd软件包
LOG_INFO "检查yum源中是否存在python3-speechd软件包"
if ! dnf list available python3-speechd &>/dev/null; then
LOG_ERROR "yum源中未找到python3-speechd软件包"
exit 255
fi
# 如果未安装则安装python3-speechd
if [ "$INSTALLED" = false ]; then
LOG_INFO "开始安装python3-speechd"
dnf install -y python3-speechd
CHECK_RESULT $? 0 0 "安装python3-speechd失败"
fi
# 测试pause speech功能
LOG_INFO "测试pause speech功能"
speech-dispatcher --pause
CHECK_RESULT $? 0 0 "pause speech功能测试失败"
# 恢复环境如果脚本开始时未安装则卸载python3-speechd
if [ "$INSTALLED" = false ]; then
LOG_INFO "卸载python3-speechd"
dnf remove -y python3-speechd
CHECK_RESULT $? 0 0 "卸载python3-speechd失败"
fi
LOG_INFO "测试脚本执行完毕,环境已恢复"
}
main "$@"

View File

@@ -1,126 +0,0 @@
#!/usr/bin/bash
# Copyright (c) 2024 ISCAS .ALL rights reserved.
# This program is licensed under Mulan PSL v2.
# You can use it according to the terms and conditions of the Mulan PSL v2.
# http://license.coscl.org.cn/MulanPSL2
# THIS PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
# See the Mulan PSL v2 for more details.
# #############################################
# @Author : honghua
# @Contact : honghua@iscas.ac.cn
# @Date : 2026-03-06
# @License : Mulan PSL v2
# @Desc : Test adjusting speech rate
# ############################################
source "$OET_PATH/libs/locallibs/common_lib.sh"
function run_test() {
# 测试调整语音速率功能
LOG_INFO "开始测试调整语音速率功能"
# 检查环境是否已安装python3-speechd
LOG_INFO "步骤1检查python3-speechd是否已安装"
if rpm -q python3-speechd > /dev/null 2>&1; then
LOG_INFO "python3-speechd已安装测试结束后将保持安装状态"
INSTALLED_BEFORE_TEST=true
else
LOG_INFO "python3-speechd未安装将在测试过程中安装"
INSTALLED_BEFORE_TEST=false
fi
# 检查yum源中是否有python3-speechd软件包
LOG_INFO "步骤2检查yum源中是否有python3-speechd软件包"
if ! dnf list available python3-speechd > /dev/null 2>&1; then
LOG_ERROR "yum源中没有python3-speechd软件包"
exit 255
fi
# 如果未安装,则安装软件包
if [ "$INSTALLED_BEFORE_TEST" = "false" ]; then
LOG_INFO "步骤3安装python3-speechd软件包"
dnf install -y python3-speechd
CHECK_RESULT $? 0 0 "安装python3-speechd失败"
fi
# 测试speech-dispatcher命令是否存在
LOG_INFO "步骤4检查speech-dispatcher命令是否存在"
if ! command -v speech-dispatcher > /dev/null 2>&1; then
LOG_ERROR "speech-dispatcher命令不存在"
# 清理环境
if [ "$INSTALLED_BEFORE_TEST" = "false" ]; then
dnf remove -y python3-speechd
fi
exit 255
fi
# 测试speech-dispatcher命令是否支持rate参数
LOG_INFO "步骤5检查speech-dispatcher命令是否支持rate参数"
if ! speech-dispatcher --help 2>&1 | grep -q "rate"; then
LOG_ERROR "speech-dispatcher命令不支持rate参数"
# 清理环境
if [ "$INSTALLED_BEFORE_TEST" = "false" ]; then
dnf remove -y python3-speechd
fi
exit 255
fi
# 测试调整语音速率功能
LOG_INFO "步骤6测试调整语音速率功能"
# 启动speech-dispatcher服务
LOG_INFO "步骤6.1启动speech-dispatcher服务"
systemctl start speech-dispatcher
CHECK_RESULT $? 0 0 "启动speech-dispatcher服务失败"
# 测试设置语音速率为正常值
LOG_INFO "步骤6.2:测试设置语音速率为正常值(100)"
echo "测试文本" | speech-dispatcher --rate 100
CHECK_RESULT $? 0 0 "设置语音速率100失败"
# 测试设置语音速率为较低值
LOG_INFO "步骤6.3:测试设置语音速率为较低值(50)"
echo "测试文本" | speech-dispatcher --rate 50
CHECK_RESULT $? 0 0 "设置语音速率50失败"
# 测试设置语音速率为较高值
LOG_INFO "步骤6.4:测试设置语音速率为较高值(200)"
echo "测试文本" | speech-dispatcher --rate 200
CHECK_RESULT $? 0 0 "设置语音速率200失败"
# 测试无效参数处理
LOG_INFO "步骤6.5:测试无效参数处理"
echo "测试文本" | speech-dispatcher --rate 0 2>&1 | grep -q "error\|invalid\|不支持"
if [ $? -eq 0 ]; then
LOG_INFO "无效参数被正确拒绝"
else
LOG_ERROR "无效参数未被正确处理"
CHECK_RESULT 1 0 0 "无效参数处理测试失败"
fi
# 停止speech-dispatcher服务
LOG_INFO "步骤7停止speech-dispatcher服务"
systemctl stop speech-dispatcher
CHECK_RESULT $? 0 0 "停止speech-dispatcher服务失败"
# 清理环境
LOG_INFO "步骤8清理测试环境"
# 如果测试前未安装,则卸载软件包
if [ "$INSTALLED_BEFORE_TEST" = "false" ]; then
LOG_INFO "卸载python3-speechd软件包"
dnf remove -y python3-speechd
CHECK_RESULT $? 0 0 "卸载python3-speechd失败"
else
LOG_INFO "保持python3-speechd安装状态"
fi
LOG_INFO "测试调整语音速率功能完成"
}
main "$@"

View File

@@ -1,64 +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-01
# @License : Mulan PSL v2
# @Desc : Test resume speech functionality
# ############################################
source "$OET_PATH/libs/locallibs/common_lib.sh"
function run_test() {
# 检查是否已安装python3-speechd
LOG_INFO "检查是否已安装python3-speechd"
if dnf list installed python3-speechd &>/dev/null; then
LOG_INFO "python3-speechd已安装脚本结束后将保持安装状态"
INSTALLED=true
else
LOG_INFO "python3-speechd未安装将在测试后卸载"
INSTALLED=false
fi
# 检查yum源中是否有python3-speechd软件包
LOG_INFO "检查yum源中是否有python3-speechd软件包"
if ! dnf list available python3-speechd &>/dev/null; then
LOG_ERROR "yum源中未找到python3-speechd软件包"
exit 255
fi
# 安装python3-speechd如果未安装
if [ "$INSTALLED" = false ]; then
LOG_INFO "开始安装python3-speechd"
dnf install -y python3-speechd
CHECK_RESULT $? 0 0 "安装python3-speechd失败"
fi
# 测试resume speech功能
LOG_INFO "测试resume speech功能"
speechd-resume
CHECK_RESULT $? 0 0 "执行speechd-resume命令失败"
# 清理环境(如果之前未安装)
if [ "$INSTALLED" = false ]; then
LOG_INFO "卸载python3-speechd"
dnf remove -y python3-speechd
CHECK_RESULT $? 0 0 "卸载python3-speechd失败"
fi
LOG_INFO "测试完成,环境已恢复"
}
main "$@"

View File

@@ -1,74 +0,0 @@
#!/usr/bin/bash
# Copyright (c) 2024 ISCAS .ALL rights reserved.
# This program is licensed under Mulan PSL v2.
# You can use it according to the terms and conditions of the Mulan PSL v2.
# http://license.coscl.org.cn/MulanPSL2
# THIS PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
# See the Mulan PSL v2 for more details.
# #############################################
# @Author : honghua
# @Contact : honghua@iscas.ac.cn
# @Date : 2025-12-01
# @License : Mulan PSL v2
# @Desc : Test language setting
# ############################################
source "$OET_PATH/libs/locallibs/common_lib.sh"
function run_test() {
LOG_INFO "开始测试Test language setting"
# 检查yum源中是否存在python3-speechd软件包
LOG_INFO "检查yum源中是否存在python3-speechd软件包"
dnf list available python3-speechd > /dev/null 2>&1
if [ $? -ne 0 ]; then
LOG_ERROR "yum源中不存在python3-speechd软件包"
exit 255
fi
# 检查是否已安装python3-speechd
LOG_INFO "检查是否已安装python3-speechd"
rpm -q python3-speechd > /dev/null 2>&1
if [ $? -eq 0 ]; then
installed=true
LOG_INFO "python3-speechd已安装测试结束后将保持安装状态"
else
installed=false
LOG_INFO "python3-speechd未安装测试结束后将卸载"
fi
# 如果未安装,则安装软件包
if [ "$installed" = false ]; then
LOG_INFO "安装python3-speechd软件包"
dnf install -y python3-speechd
CHECK_RESULT $? 0 0 "安装python3-speechd失败"
fi
# 测试设置语言功能
LOG_INFO "测试设置语言功能"
speech-dispatcher --language=es > /dev/null 2>&1
CHECK_RESULT $? 0 0 "设置语言失败"
# 检查不支持的参数场景(假设--invalid-param为不支持参数
LOG_INFO "检查不支持的参数场景"
speech-dispatcher --invalid-param > /dev/null 2>&1
if [ $? -ne 255 ]; then
LOG_ERROR "--invalid-param参数未被正确处理"
exit 255
fi
# 清理环境
if [ "$installed" = false ]; then
LOG_INFO "卸载python3-speechd软件包"
dnf remove -y python3-speechd
CHECK_RESULT $? 0 0 "卸载python3-speechd失败"
fi
LOG_INFO "测试完成Test language setting"
}
main "$@"

View File

@@ -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 : 2025-12-01
# @License : Mulan PSL v2
# @Desc : Test speech pitch setting
# ############################################
source "$OET_PATH/libs/locallibs/common_lib.sh"
function run_test() {
# 检查是否已安装python3-speechd
LOG_INFO "检查是否已安装python3-speechd"
if dnf list installed python3-speechd &>/dev/null; then
LOG_INFO "python3-speechd已安装脚本结束后将保持安装状态"
INSTALLED=true
else
LOG_INFO "python3-speechd未安装脚本结束后将卸载"
INSTALLED=false
fi
# 检查yum源中是否有python3-speechd
LOG_INFO "检查yum源中是否有python3-speechd"
if ! dnf list available python3-speechd &>/dev/null; then
LOG_ERROR "yum源中未找到python3-speechd退出"
exit 255
fi
# 安装python3-speechd
if [ "$INSTALLED" = false ]; then
LOG_INFO "开始安装python3-speechd"
dnf install -y python3-speechd
CHECK_RESULT $? 0 0 "安装python3-speechd失败"
fi
# 测试speech pitch设置功能
LOG_INFO "测试speech pitch设置功能"
pitch_output=$(python3 -c "import speechd; client = speechd.Client("test"); client.set_pitch(50); print(client.get_pitch())" 2>&1)
CHECK_RESULT $? 0 0 "设置或获取pitch失败"
# 验证pitch值是否为50
LOG_INFO "验证pitch值是否为50"
if [ "$pitch_output" -eq 50 ]; then
LOG_INFO "pitch设置成功当前值为50"
else
LOG_ERROR "pitch设置失败当前值为$pitch_output"
exit 1
fi
# 清理环境如果脚本开始时未安装则卸载python3-speechd
if [ "$INSTALLED" = false ]; then
LOG_INFO "卸载python3-speechd"
dnf remove -y python3-speechd
CHECK_RESULT $? 0 0 "卸载python3-speechd失败"
fi
LOG_INFO "测试脚本执行完毕"
}
main "$@"

View File

@@ -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 : 2025-12-01
# @License : Mulan PSL v2
# @Desc : Test speech rate setting
# ############################################
source "$OET_PATH/libs/locallibs/common_lib.sh"
function run_test() {
# 检查是否已安装python3-speechd
if rpm -q python3-speechd &>/dev/null; then
LOG_INFO "python3-speechd已安装脚本结束后将保持安装状态"
INSTALLED=true
else
LOG_INFO "python3-speechd未安装脚本结束后将卸载"
INSTALLED=false
fi
# 检查yum源中是否有python3-speechd
LOG_INFO "检查yum源中是否有python3-speechd"
if ! dnf list available python3-speechd &>/dev/null; then
LOG_ERROR "yum源中未找到python3-speechd"
exit 255
fi
# 安装python3-speechd
if [ "$INSTALLED" = false ]; then
LOG_INFO "安装python3-speechd"
dnf install -y python3-speechd
CHECK_RESULT $? 0 0 "安装python3-speechd失败"
fi
# 测试speech rate设置功能
LOG_INFO "测试speech rate设置功能"
speechd-set-rate 50
CHECK_RESULT $? 0 0 "设置speech rate为50失败"
# 检查不支持的参数
LOG_INFO "检查不支持的参数"
speechd-set-rate --invalid-param &>/dev/null
if [ $? -ne 255 ]; then
LOG_ERROR "不支持的参数未正确退出"
exit 255
fi
# 清理环境
if [ "$INSTALLED" = false ]; then
LOG_INFO "卸载python3-speechd"
dnf remove -y python3-speechd
CHECK_RESULT $? 0 0 "卸载python3-speechd失败"
fi
LOG_INFO "测试完成"
}
main "$@"

View File

@@ -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 : 2025-12-01
# @License : Mulan PSL v2
# @Desc : Test speech volume setting
# ############################################
source "$OET_PATH/libs/locallibs/common_lib.sh"
function run_test() {
LOG_INFO "开始测试Test speech volume setting"
# 检查是否已安装python3-speechd
LOG_INFO "检查python3-speechd是否已安装"
if dnf list installed python3-speechd &>/dev/null; then
LOG_INFO "python3-speechd已安装测试结束后将保持安装状态"
INSTALLED=1
else
LOG_INFO "python3-speechd未安装将在测试结束后卸载"
INSTALLED=0
fi
# 检查yum源中是否有python3-speechd
LOG_INFO "检查yum源中是否存在python3-speechd"
if ! dnf list available python3-speechd &>/dev/null; then
LOG_ERROR "yum源中未找到python3-speechd退出测试"
exit 255
fi
# 若未安装则安装python3-speechd
if [ $INSTALLED -eq 0 ]; then
LOG_INFO "安装python3-speechd"
dnf install -y python3-speechd
CHECK_RESULT $? 0 0 "安装python3-speechd失败"
fi
# 测试设置音量功能
LOG_INFO "测试speechd音量设置功能"
speechd-set-volume 50
CHECK_RESULT $? 0 0 "设置音量失败"
# 检查音量设置是否生效假设speechd-get-volume命令存在
LOG_INFO "验证音量设置是否生效"
speechd-get-volume | grep -q "50"
CHECK_RESULT $? 0 0 "音量设置未生效"
# 测试不支持的参数(假设--invalid-option为无效参数
LOG_INFO "测试无效参数"
speechd-set-volume --invalid-option 50
if [ $? -ne 255 ]; then
LOG_ERROR "无效参数未被正确处理"
exit 255
fi
# 清理环境
if [ $INSTALLED -eq 0 ]; then
LOG_INFO "卸载python3-speechd"
dnf remove -y python3-speechd
CHECK_RESULT $? 0 0 "卸载python3-speechd失败"
fi
LOG_INFO "测试完成Test speech volume setting"
}
main "$@"

View File

@@ -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 : 2025-12-01
# @License : Mulan PSL v2
# @Desc : Test text-to-speech functionality
# ############################################
source "$OET_PATH/libs/locallibs/common_lib.sh"
function run_test() {
LOG_INFO "开始测试文本转语音功能"
# 检查是否已安装python3-speechd
LOG_INFO "检查是否已安装python3-speechd"
if dnf list installed python3-speechd &>/dev/null; then
LOG_INFO "python3-speechd已安装脚本结束后将保持安装状态"
INSTALLED=true
else
LOG_INFO "python3-speechd未安装将在测试后卸载"
INSTALLED=false
fi
# 检查yum源中是否有python3-speechd
LOG_INFO "检查yum源中是否有python3-speechd"
if ! dnf list available python3-speechd &>/dev/null; then
LOG_ERROR "yum源中未找到python3-speechd软件包"
exit 255
fi
# 安装python3-speechd
if [ "$INSTALLED" = false ]; then
LOG_INFO "开始安装python3-speechd"
dnf install -y python3-speechd
CHECK_RESULT $? 0 0 "安装python3-speechd失败"
fi
# 测试speak功能
LOG_INFO "测试speak功能"
speak_output=$(speak "测试文本转语音功能" 2>&1)
CHECK_RESULT $? 0 0 "speak命令执行失败"
# 检查speak命令参数是否支持
LOG_INFO "检查speak命令参数是否支持"
if ! speak --help | grep -q "参数"; then
LOG_ERROR "speak命令不支持指定参数"
exit 255
fi
# 清理环境
if [ "$INSTALLED" = false ]; then
LOG_INFO "卸载python3-speechd"
dnf remove -y python3-speechd
CHECK_RESULT $? 0 0 "卸载python3-speechd失败"
fi
LOG_INFO "测试完成,环境已恢复"
}
main "$@"

View File

@@ -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-03-06
# @License : Mulan PSL v2
# @Desc : Test checking client status
# ############################################
source "$OET_PATH/libs/locallibs/common_lib.sh"
function run_test() {
set -e
LOG_INFO "开始测试Test checking client status"
# 检查软件包是否在yum源中
LOG_INFO "检查python3-speechd软件包是否在yum源中"
if ! dnf list available python3-speechd &>/dev/null; then
LOG_ERROR "python3-speechd软件包不在yum源中"
exit 255
fi
# 检查环境是否已安装
LOG_INFO "检查python3-speechd是否已安装"
if rpm -q python3-speechd &>/dev/null; then
LOG_INFO "python3-speechd已安装标记为已存在安装"
INSTALLED="true"
else
LOG_INFO "python3-speechd未安装标记为需要安装"
INSTALLED="false"
fi
# 如果未安装,则安装软件包
if [ "$INSTALLED" = "false" ]; then
LOG_INFO "安装python3-speechd软件包"
dnf install -y python3-speechd
CHECK_RESULT $? 0 0 "安装python3-speechd失败"
fi
# 检查命令参数是否存在
LOG_INFO "检查speech-dispatcher命令是否存在"
if ! command -v speech-dispatcher &>/dev/null; then
LOG_ERROR "speech-dispatcher命令不存在"
exit 255
fi
LOG_INFO "检查speech-dispatcher是否支持--status参数"
if ! speech-dispatcher --help 2>&1 | grep -q -- "--status"; then
LOG_ERROR "speech-dispatcher不支持--status参数"
exit 255
fi
# 执行测试命令
LOG_INFO "执行speech-dispatcher --status命令检查客户端状态"
speech-dispatcher --status
CHECK_RESULT $? 0 0 "speech-dispatcher --status命令执行失败"
# 清理环境:如果测试前未安装,则卸载软件包
if [ "$INSTALLED" = "false" ]; then
LOG_INFO "卸载python3-speechd软件包"
dnf remove -y python3-speechd
CHECK_RESULT $? 0 0 "卸载python3-speechd失败"
LOG_INFO "环境已恢复到测试前状态"
else
LOG_INFO "测试前已安装python3-speechd保持安装状态"
fi
LOG_INFO "测试完成Test checking client status"
}
main "$@"

View File

@@ -1,66 +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-01
# @License : Mulan PSL v2
# @Desc : Test stop speech functionality
# ############################################
source "$OET_PATH/libs/locallibs/common_lib.sh"
function run_test() {
LOG_INFO "开始测试停止语音功能"
# 检查软件包是否在yum源中
LOG_INFO "检查python3-speechd软件包是否在yum源中"
dnf list available python3-speechd >/dev/null 2>&1
if [ $? -ne 0 ]; then
LOG_ERROR "python3-speechd软件包不在yum源中"
exit 255
fi
# 检查是否已安装python3-speechd
LOG_INFO "检查是否已安装python3-speechd"
rpm -q python3-speechd >/dev/null 2>&1
if [ $? -eq 0 ]; then
installed=true
LOG_INFO "python3-speechd已安装测试结束后保持安装状态"
else
installed=false
LOG_INFO "python3-speechd未安装测试结束后将卸载"
fi
# 如果未安装,则安装软件包
if [ "$installed" = false ]; then
LOG_INFO "安装python3-speechd软件包"
dnf install -y python3-speechd
CHECK_RESULT $? 0 0 "安装python3-speechd失败"
fi
# 测试停止语音功能
LOG_INFO "测试停止语音功能"
speech-dispatcher --stop
CHECK_RESULT $? 0 0 "停止语音功能失败"
# 清理环境
if [ "$installed" = false ]; then
LOG_INFO "卸载python3-speechd软件包"
dnf remove -y python3-speechd
CHECK_RESULT $? 0 0 "卸载python3-speechd失败"
fi
LOG_INFO "测试停止语音功能完成"
}
main "$@"

View File

@@ -1,121 +0,0 @@
#!/usr/bin/bash
# Copyright (c) 2024 ISCAS .ALL rights reserved.
# This program is licensed under Mulan PSL v2.
# You can use it according to the terms and conditions of the Mulan PSL v2.
# http://license.coscl.org.cn/MulanPSL2
# THIS PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
# See the Mulan PSL v2 for more details.
# #############################################
# @Author : honghua
# @Contact : honghua@iscas.ac.cn
# @Date : 2026-03-06
# @License : Mulan PSL v2
# @Desc : Test uninstalling package
# ############################################
source "$OET_PATH/libs/locallibs/common_lib.sh"
function run_test() {
# 定义颜色输出函数(可选,用于日志高亮)
LOG_INFO() {
echo -e "\033[32m[INFO]\033[0m $1"
}
LOG_ERROR() {
echo -e "\033[31m[ERROR]\033[0m $1"
}
# 定义检查结果函数模拟CHECK_RESULT
CHECK_RESULT() {
local actual=$1
local expect=$2
local code=$3
local reason=$4
if [ $actual -ne $expect ]; then
LOG_ERROR "$reason"
exit $code
fi
}
# 定义SSH_CMD函数模拟SSH_CMD
SSH_CMD() {
local cmd=$1
local ip=$2
local pass=$3
local user=$4
# 模拟SSH执行命令实际使用时替换为真实SSH命令
echo "模拟SSH执行: ssh $user@$ip "$cmd""
# 这里假设SSH成功执行实际使用时需要处理SSH失败情况
return 0
}
# 测试脚本主体
LOG_INFO "开始测试卸载python3-speechd包"
# 步骤1检查yum源中是否存在python3-speechd包
LOG_INFO "步骤1检查yum源中是否存在python3-speechd包"
dnf list available python3-speechd &> /dev/null
if [ $? -ne 0 ]; then
LOG_ERROR "yum源中未找到python3-speechd包"
exit 255
fi
# 步骤2检查当前是否已安装python3-speechd
LOG_INFO "步骤2检查当前是否已安装python3-speechd"
if rpm -q python3-speechd &> /dev/null; then
LOG_INFO "python3-speechd已安装测试结束后将保持安装状态"
INSTALLED_BEFORE=true
else
LOG_INFO "python3-speechd未安装测试前将先安装"
INSTALLED_BEFORE=false
fi
# 步骤3如果未安装则先安装python3-speechd
if [ "$INSTALLED_BEFORE" = "false" ]; then
LOG_INFO "步骤3安装python3-speechd包"
dnf install -y python3-speechd
CHECK_RESULT $? 0 0 "安装python3-speechd失败"
fi
# 步骤4验证python3-speechd功能例如检查speechd服务状态
LOG_INFO "步骤4验证python3-speechd功能"
systemctl is-active speech-dispatcherd &> /dev/null
CHECK_RESULT $? 0 0 "speech-dispatcherd服务未运行"
# 步骤5卸载python3-speechd包
LOG_INFO "步骤5卸载python3-speechd包"
dnf remove -y python3-speechd
CHECK_RESULT $? 0 0 "卸载python3-speechd失败"
# 步骤6验证卸载后包是否已移除
LOG_INFO "步骤6验证卸载后包是否已移除"
if rpm -q python3-speechd &> /dev/null; then
LOG_ERROR "卸载后python3-speechd仍存在"
exit 1
fi
# 步骤7验证卸载后相关服务是否停止
LOG_INFO "步骤7验证卸载后相关服务是否停止"
systemctl is-active speech-dispatcherd &> /dev/null
if [ $? -eq 0 ]; then
LOG_ERROR "卸载后speech-dispatcherd服务仍在运行"
exit 1
fi
# 步骤8环境恢复
LOG_INFO "步骤8环境恢复"
if [ "$INSTALLED_BEFORE" = "false" ]; then
LOG_INFO "测试前未安装python3-speechd无需恢复"
else
LOG_INFO "重新安装python3-speechd以恢复环境"
dnf install -y python3-speechd
CHECK_RESULT $? 0 0 "恢复安装python3-speechd失败"
fi
LOG_INFO "测试完成卸载python3-speechd包功能正常"
}
main "$@"

View File

@@ -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-03-06
# @License : Mulan PSL v2
# @Desc : Test adjusting speech volume
# ############################################
source "$OET_PATH/libs/locallibs/common_lib.sh"
function run_test() {
LOG_INFO "开始测试Test adjusting speech volume"
# 检查环境是否已安装python3-speechd
LOG_INFO "步骤1检查python3-speechd是否已安装"
if dnf list installed python3-speechd &>/dev/null; then
LOG_INFO "python3-speechd已安装将保持安装状态"
ALREADY_INSTALLED=1
else
LOG_INFO "python3-speechd未安装将在测试中安装"
ALREADY_INSTALLED=0
fi
# 检查yum源中是否有python3-speechd软件包
LOG_INFO "步骤2检查yum源中是否有python3-speechd软件包"
if ! dnf list available python3-speechd &>/dev/null; then
LOG_ERROR "yum源中未找到python3-speechd软件包"
exit 255
fi
# 如果未安装则安装python3-speechd
if [ $ALREADY_INSTALLED -eq 0 ]; then
LOG_INFO "步骤3安装python3-speechd"
dnf install -y python3-speechd
CHECK_RESULT $? 0 0 "安装python3-speechd失败"
fi
# 测试调整语音音量功能
LOG_INFO "步骤4测试调整语音音量功能"
if ! python3 -c "import speechd; client = speechd.SSIPClient("test"); client.set_volume(50); client.close()" &>/dev/null; then
LOG_ERROR "调整语音音量功能测试失败"
CHECK_RESULT 1 0 0 "调整语音音量功能异常"
else
LOG_INFO "调整语音音量功能测试成功"
fi
# 环境恢复如果测试前未安装则卸载python3-speechd
if [ $ALREADY_INSTALLED -eq 0 ]; then
LOG_INFO "步骤5卸载python3-speechd"
dnf remove -y python3-speechd
CHECK_RESULT $? 0 0 "卸载python3-speechd失败"
LOG_INFO "已恢复环境卸载python3-speechd"
else
LOG_INFO "步骤5保持python3-speechd安装状态"
fi
LOG_INFO "测试完成Test adjusting speech volume"
}
main "$@"