diff --git a/suite2cases/function_test/pkg_test/coreutils/coreutils.json b/suite2cases/function_test/pkg_test/coreutils/coreutils.json index e0cfb04b7ff..772d1d199bf 100644 --- a/suite2cases/function_test/pkg_test/coreutils/coreutils.json +++ b/suite2cases/function_test/pkg_test/coreutils/coreutils.json @@ -506,10 +506,6 @@ "name": "test_coreutils_du_k", "desc": "以KB(1024字节)为单位显示文件大小" }, - { - "name": "test_coreutils_du_time_atime", - "desc": "显示目录或任何子目录中文件的最后访问时间" - }, { "name": "test_coreutils_du_time_style_full_iso", "desc": "以完全ISO格式(例如2024-01-01 10:30:00.000000000 +0800)显示时间" @@ -1014,10 +1010,6 @@ "name": "test_coreutils_nproc_upper_version", "desc": "测试带--version参数的nproc命令,应输出版本信息" }, - { - "name": "test_coreutils_numfmt_suffix", - "desc": "测试 numfmt 为输出数字添加后缀,并接受输入数字的可选后缀" - }, { "name": "test_coreutils_numfmt_invalid_warn", "desc": "测试 numfmt 在遇到无效输入时发出警告但继续处理并返回成功退出状态" @@ -1522,10 +1514,6 @@ "name": "test_coreutils_b2sum__version", "desc": "使用 --version 参数输出版本信息" }, - { - "name": "test_coreutils_base32_w_num_0", - "desc": "使用-w 0参数,编码时禁用自动换行" - }, { "name": "test_coreutils_base32_wrap_num_0", "desc": "使用--wrap=0参数,编码时禁用自动换行" @@ -2030,10 +2018,6 @@ "name": "test_coreutils_env_v", "desc": "使用-v参数打印详细的处理步骤信息" }, - { - "name": "test_coreutils_env_i_v", - "desc": "组合使用-i和-v参数,清空环境并打印详细步骤" - }, { "name": "test_coreutils_env_dash_only", "desc": "仅使用单个短横线“-”作为参数(等同于-i)" @@ -2538,10 +2522,6 @@ "name": "test_coreutils_mv_backup_numbered", "desc": "测试移动文件时创建带编号的备份" }, - { - "name": "test_coreutils_mv_t", - "desc": "测试使用目标目录参数移动多个源文件" - }, { "name": "test_coreutils_mv_upper_t", "desc": "测试将目标作为普通文件处理(非目录)" @@ -3046,10 +3026,6 @@ "name": "test_coreutils_dd_oflag_sync", "desc": "使用dd命令并设置输出标志为同步I/O进行数据写入" }, - { - "name": "test_coreutils_dd_conv_fsync", - "desc": "使用dd命令在完成前同步输出文件数据和元数据" - }, { "name": "test_coreutils_df", "desc": "不带任何参数执行df命令,显示所有文件系统的信息" @@ -3554,10 +3530,6 @@ "name": "test_coreutils_nproc_no_arg", "desc": "测试不带任何参数执行nproc命令,打印当前进程可用的处理单元数量" }, - { - "name": "test_coreutils_nproc_all", - "desc": "测试使用--all参数执行nproc命令,打印已安装的处理器的数量" - }, { "name": "test_coreutils_numfmt__to_si", "desc": "测试将数字转换为SI单位格式" @@ -4062,10 +4034,6 @@ "name": "test_coreutils_sort_version", "desc": "测试显示版本信息并退出" }, - { - "name": "test_coreutils_split_d", - "desc": "测试使用数字后缀" - }, { "name": "test_coreutils_split_x", "desc": "测试使用十六进制后缀" @@ -4570,10 +4538,6 @@ "name": "test_coreutils_uname_v", "desc": "测试-v选项,预期输出内核版本" }, - { - "name": "test_coreutils_uname_m", - "desc": "测试-m选项,预期输出机器硬件名称" - }, { "name": "test_coreutils_uname_i", "desc": "测试-i选项,预期输出硬件平台(非便携式)" diff --git a/testcases/function_test/pkg_test/coreutils/coreutils/test_coreutils_base32_w_num_0.sh b/testcases/function_test/pkg_test/coreutils/coreutils/test_coreutils_base32_w_num_0.sh deleted file mode 100644 index 7be5c6fee17..00000000000 --- a/testcases/function_test/pkg_test/coreutils/coreutils/test_coreutils_base32_w_num_0.sh +++ /dev/null @@ -1,88 +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-02-14 -# @License : Mulan PSL v2 -# @Desc : 使用-w 0参数,编码时禁用自动换行 -# ############################################ - -source "$OET_PATH/libs/locallibs/common_lib.sh" - -function run_test() { - LOG_INFO "开始测试:使用-w 0参数,编码时禁用自动换行" - - # 检查是否已安装coreutils软件包 - LOG_INFO "检查coreutils软件包是否已安装" - if ! dnf list installed coreutils &>/dev/null; then - LOG_INFO "coreutils未安装,将在测试过程中安装" - INSTALLED=0 - else - LOG_INFO "coreutils已安装" - INSTALLED=1 - fi - - # 检查yum源中是否有coreutils软件包 - LOG_INFO "检查yum源中是否有coreutils软件包" - if ! dnf list available coreutils &>/dev/null; then - LOG_ERROR "yum源中无coreutils软件包" - exit 255 - fi - - # 如果未安装,则安装coreutils - if [ $INSTALLED -eq 0 ]; then - LOG_INFO "安装coreutils软件包" - dnf install -y coreutils - CHECK_RESULT $? 0 0 "安装coreutils失败" - fi - - # 检查base32命令是否支持-w参数 - LOG_INFO "检查base32命令是否支持-w参数" - if ! base32 --help 2>&1 | grep -q "\-w"; then - LOG_ERROR "base32命令不支持-w参数" - exit 255 - fi - - # 测试使用-w 0参数编码时禁用自动换行 - LOG_INFO "测试使用-w 0参数编码时禁用自动换行" - echo "testdata" > test_input.txt - base32 -w 0 test_input.txt > test_output.txt - CHECK_RESULT $? 0 0 "base32命令执行失败" - - # 验证输出中是否没有换行符 - LOG_INFO "验证输出中是否没有换行符" - if grep -q $"\n" test_output.txt; then - LOG_ERROR "输出中包含换行符,与预期不符" - CHECK_RESULT 1 0 0 "输出中包含换行符" - else - LOG_INFO "输出中无换行符,符合预期" - CHECK_RESULT 0 0 0 "输出中无换行符" - fi - - # 清理测试文件 - LOG_INFO "清理测试文件" - rm -f test_input.txt test_output.txt - - # 如果测试前未安装coreutils,则在测试后卸载 - if [ $INSTALLED -eq 0 ]; then - LOG_INFO "卸载coreutils软件包" - dnf remove -y coreutils - CHECK_RESULT $? 0 0 "卸载coreutils失败" - else - LOG_INFO "保持coreutils安装状态" - fi - - LOG_INFO "测试完成" -} - -main "$@" \ No newline at end of file diff --git a/testcases/function_test/pkg_test/coreutils/coreutils/test_coreutils_dd_conv_fsync.sh b/testcases/function_test/pkg_test/coreutils/coreutils/test_coreutils_dd_conv_fsync.sh deleted file mode 100644 index 0fd00afab94..00000000000 --- a/testcases/function_test/pkg_test/coreutils/coreutils/test_coreutils_dd_conv_fsync.sh +++ /dev/null @@ -1,80 +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-24 -# @License : Mulan PSL v2 -# @Desc : 使用dd命令在完成前同步输出文件数据和元数据 -# ############################################ - -source "$OET_PATH/libs/locallibs/common_lib.sh" - -function run_test() { - LOG_INFO "开始测试dd命令的conv=fsync参数功能" - LOG_INFO "步骤1: 检查dd命令是否已安装" - if ! command -v dd &> /dev/null; then - LOG_INFO "dd命令未安装,尝试通过coreutils安装" - if dnf list available coreutils &> /dev/null; then - dnf install -y coreutils - CHECK_RESULT $? 0 0 "安装coreutils失败" - INSTALLED=true - LOG_INFO "coreutils安装成功" - else - LOG_ERROR "yum源中未找到coreutils软件包" - exit 255 - fi - else - LOG_INFO "dd命令已安装" - INSTALLED=false - fi - - LOG_INFO "步骤2: 检查dd命令是否支持conv=fsync参数" - dd --help | grep -q "fsync" - if [ $? -ne 0 ]; then - LOG_ERROR "dd命令不支持conv=fsync参数" - if [ "$INSTALLED" = true ]; then - LOG_INFO "清理安装的coreutils软件包" - dnf remove -y coreutils - fi - exit 255 - fi - LOG_INFO "dd命令支持conv=fsync参数" - - LOG_INFO "步骤3: 创建测试文件" - TEST_INPUT="/tmp/test_input.txt" - TEST_OUTPUT="/tmp/test_output.txt" - echo "This is a test file for dd conv=fsync" > "$TEST_INPUT" - CHECK_RESULT $? 0 0 "创建测试输入文件失败" - - LOG_INFO "步骤4: 使用dd命令带conv=fsync参数复制文件" - dd if="$TEST_INPUT" of="$TEST_OUTPUT" conv=fsync - CHECK_RESULT $? 0 0 "dd命令执行失败" - - LOG_INFO "步骤5: 验证输出文件内容" - cmp "$TEST_INPUT" "$TEST_OUTPUT" - CHECK_RESULT $? 0 0 "输出文件内容与输入文件不一致" - - LOG_INFO "步骤6: 清理测试文件" - rm -f "$TEST_INPUT" "$TEST_OUTPUT" - CHECK_RESULT $? 0 0 "删除测试文件失败" - - if [ "$INSTALLED" = true ]; then - LOG_INFO "步骤7: 卸载测试安装的coreutils软件包" - dnf remove -y coreutils - CHECK_RESULT $? 0 0 "卸载coreutils失败" - fi - - LOG_INFO "测试完成,环境已恢复" -} - -main "$@" \ No newline at end of file diff --git a/testcases/function_test/pkg_test/coreutils/coreutils/test_coreutils_du_time_atime.sh b/testcases/function_test/pkg_test/coreutils/coreutils/test_coreutils_du_time_atime.sh deleted file mode 100644 index 9641cd68bda..00000000000 --- a/testcases/function_test/pkg_test/coreutils/coreutils/test_coreutils_du_time_atime.sh +++ /dev/null @@ -1,110 +0,0 @@ -#!/usr/bin/bash - -# Copyright (c) 2024 ISCAS .ALL rights reserved. -# This program is licensed under Mulan PSL v2. -# You can use it according to the terms and conditions of the Mulan PSL v2. -# http://license.coscl.org.cn/MulanPSL2 -# THIS PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, -# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, -# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. -# See the Mulan PSL v2 for more details. - -# ############################################# -# @Author : honghua -# @Contact : honghua@iscas.ac.cn -# @Date : 2025-12-19 -# @License : Mulan PSL v2 -# @Desc : 显示目录或任何子目录中文件的最后访问时间 -# ############################################ - -source "$OET_PATH/libs/locallibs/common_lib.sh" - -function run_test() { - # 设置严格模式,避免环境破坏 - set -e - - # 定义软件包名称 - PACKAGE_NAME="coreutils" - - # 检查是否已安装coreutils - LOG_INFO "步骤1:检查系统是否已安装${PACKAGE_NAME}软件包" - if dnf list installed ${PACKAGE_NAME} &>/dev/null; then - LOG_INFO "检测到${PACKAGE_NAME}已安装" - INSTALLED_BEFORE=1 - else - LOG_INFO "检测到${PACKAGE_NAME}未安装" - INSTALLED_BEFORE=0 - fi - - # 检查yum源中是否存在coreutils软件包 - LOG_INFO "步骤2:检查yum源中是否存在${PACKAGE_NAME}软件包" - if ! dnf list available ${PACKAGE_NAME} &>/dev/null; then - LOG_ERROR "yum源中未找到${PACKAGE_NAME}软件包" - exit 255 - fi - - # 如果未安装,则进行安装 - if [ ${INSTALLED_BEFORE} -eq 0 ]; then - LOG_INFO "步骤3:开始安装${PACKAGE_NAME}软件包" - dnf install -y ${PACKAGE_NAME} - CHECK_RESULT $? 0 0 "安装${PACKAGE_NAME}失败" - LOG_INFO "${PACKAGE_NAME}软件包安装成功" - else - LOG_INFO "步骤3:${PACKAGE_NAME}已安装,跳过安装步骤" - fi - - # 检查du命令是否支持--time=atime参数 - LOG_INFO "步骤4:检查du命令是否支持--time参数" - if ! du --help 2>/dev/null | grep -q "\-\-time"; then - LOG_ERROR "du命令不支持--time参数" - exit 255 - fi - - # 检查du命令是否支持atime时间类型 - LOG_INFO "步骤5:检查du命令是否支持atime时间类型" - if ! du --time=atime --help 2>/dev/null; then - LOG_ERROR "du命令不支持atime时间类型" - exit 255 - fi - - # 创建测试目录和文件 - LOG_INFO "步骤6:创建测试目录和文件" - TEST_DIR=$(mktemp -d /tmp/test_coreutils_du_time_atime.XXXXXX) - echo "测试文件内容" > ${TEST_DIR}/test_file.txt - # 设置特定的访问时间用于测试 - touch -a -t 202301010000 ${TEST_DIR}/test_file.txt - - # 执行du命令查看最后访问时间 - LOG_INFO "步骤7:执行du命令显示目录中文件的最后访问时间" - du --time=atime -h ${TEST_DIR} > /tmp/du_output.txt - CHECK_RESULT $? 0 0 "执行du命令失败" - - # 验证输出结果包含目录信息 - LOG_INFO "步骤8:验证du命令输出结果" - if [[ -s /tmp/du_output.txt ]]; then - LOG_INFO "du命令执行成功,输出结果如下:" - cat /tmp/du_output.txt - else - LOG_ERROR "du命令未输出任何结果" - exit 1 - fi - - # 清理测试文件 - LOG_INFO "步骤9:清理测试文件" - rm -rf ${TEST_DIR} - rm -f /tmp/du_output.txt - - # 如果测试开始时未安装,则在测试结束后卸载软件包 - if [ ${INSTALLED_BEFORE} -eq 0 ]; then - LOG_INFO "步骤10:卸载${PACKAGE_NAME}软件包,恢复原始状态" - dnf remove -y ${PACKAGE_NAME} - CHECK_RESULT $? 0 0 "卸载${PACKAGE_NAME}失败" - LOG_INFO "${PACKAGE_NAME}软件包已成功卸载" - else - LOG_INFO "步骤10:保持${PACKAGE_NAME}软件包安装状态" - fi - - LOG_INFO "测试脚本执行完毕" -} - -main "$@" \ No newline at end of file diff --git a/testcases/function_test/pkg_test/coreutils/coreutils/test_coreutils_env_i_v.sh b/testcases/function_test/pkg_test/coreutils/coreutils/test_coreutils_env_i_v.sh deleted file mode 100644 index 03aa80aba11..00000000000 --- a/testcases/function_test/pkg_test/coreutils/coreutils/test_coreutils_env_i_v.sh +++ /dev/null @@ -1,88 +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-02-14 -# @License : Mulan PSL v2 -# @Desc : 组合使用-i和-v参数,清空环境并打印详细步骤 -# ############################################ - -source "$OET_PATH/libs/locallibs/common_lib.sh" - -function run_test() { - # 定义软件包名称和命令 - PACKAGE_NAME="coreutils" - COMMAND="env" - PARAM_I="-i" - PARAM_V="-v" - - # 步骤1:检查yum源中是否存在指定软件包 - LOG_INFO "步骤1:检查yum源中是否存在${PACKAGE_NAME}软件包" - dnf list available ${PACKAGE_NAME} &>/dev/null - if [ $? -ne 0 ]; then - LOG_ERROR "yum源中不存在${PACKAGE_NAME}软件包" - exit 255 - fi - - # 步骤2:检查环境是否已安装指定软件包 - LOG_INFO "步骤2:检查环境是否已安装${PACKAGE_NAME}软件包" - rpm -q ${PACKAGE_NAME} &>/dev/null - if [ $? -eq 0 ]; then - INSTALLED="true" - LOG_INFO "环境已安装${PACKAGE_NAME}软件包" - else - INSTALLED="false" - LOG_INFO "环境未安装${PACKAGE_NAME}软件包,将进行安装" - fi - - # 步骤3:如果未安装,则安装软件包 - if [ "${INSTALLED}" = "false" ]; then - LOG_INFO "步骤3:安装${PACKAGE_NAME}软件包" - dnf install -y ${PACKAGE_NAME} - CHECK_RESULT $? 0 0 "安装${PACKAGE_NAME}软件包失败" - fi - - # 步骤4:检查命令是否支持-i参数 - LOG_INFO "步骤4:检查${COMMAND}命令是否支持-i参数" - ${COMMAND} ${PARAM_I} /bin/true &>/dev/null - if [ $? -eq 255 ]; then - LOG_ERROR "${COMMAND}命令不支持-i参数" - exit 255 - fi - - # 步骤5:检查命令是否支持-v参数 - LOG_INFO "步骤5:检查${COMMAND}命令是否支持-v参数" - ${COMMAND} ${PARAM_V} &>/dev/null - if [ $? -eq 255 ]; then - LOG_ERROR "${COMMAND}命令不支持-v参数" - exit 255 - fi - - # 步骤6:组合使用-i和-v参数执行命令 - LOG_INFO "步骤6:组合使用-i和-v参数执行${COMMAND}命令" - ${COMMAND} ${PARAM_I} ${PARAM_V} - CHECK_RESULT $? 0 0 "组合使用-i和-v参数执行${COMMAND}命令失败" - - # 步骤7:清理环境,如果之前未安装则卸载软件包 - if [ "${INSTALLED}" = "false" ]; then - LOG_INFO "步骤7:卸载${PACKAGE_NAME}软件包" - dnf remove -y ${PACKAGE_NAME} - CHECK_RESULT $? 0 0 "卸载${PACKAGE_NAME}软件包失败" - else - LOG_INFO "步骤7:环境已安装${PACKAGE_NAME}软件包,保持安装状态" - fi - - LOG_INFO "测试脚本执行完成" -} - -main "$@" \ No newline at end of file diff --git a/testcases/function_test/pkg_test/coreutils/coreutils/test_coreutils_mv_t.sh b/testcases/function_test/pkg_test/coreutils/coreutils/test_coreutils_mv_t.sh deleted file mode 100644 index 6f538014717..00000000000 --- a/testcases/function_test/pkg_test/coreutils/coreutils/test_coreutils_mv_t.sh +++ /dev/null @@ -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-02-14 -# @License : Mulan PSL v2 -# @Desc : 测试使用目标目录参数移动多个源文件 -# ############################################ - -source "$OET_PATH/libs/locallibs/common_lib.sh" - -function run_test() { - LOG_INFO "开始测试:测试使用目标目录参数移动多个源文件" - - LOG_INFO "步骤1: 检查coreutils软件包是否已安装" - if rpm -q coreutils > /dev/null 2>&1; then - LOG_INFO "coreutils已安装,脚本结束时将保持安装状态" - INSTALLED_BEFORE="yes" - else - LOG_INFO "coreutils未安装,将在测试过程中安装" - INSTALLED_BEFORE="no" - fi - - LOG_INFO "步骤2: 检查yum源中是否存在coreutils软件包" - if ! dnf list available coreutils > /dev/null 2>&1; then - LOG_ERROR "yum源中未找到coreutils软件包" - exit 255 - fi - - if [ "$INSTALLED_BEFORE" = "no" ]; then - LOG_INFO "步骤3: 安装coreutils软件包" - dnf install -y coreutils - CHECK_RESULT $? 0 0 "安装coreutils失败" - fi - - LOG_INFO "步骤4: 准备测试文件" - TEST_DIR=$(mktemp -d) - cd "$TEST_DIR" || exit 1 - echo "file1 content" > file1.txt - echo "file2 content" > file2.txt - echo "file3 content" > file3.txt - DEST_DIR=$(mktemp -d) - - LOG_INFO "步骤5: 验证mv命令支持-t参数" - mv --help 2>&1 | grep -q -- "-t" - if [ $? -ne 0 ]; then - LOG_ERROR "mv命令不支持-t参数" - exit 255 - fi - - LOG_INFO "步骤6: 执行mv -t命令移动多个文件" - mv -t "$DEST_DIR" file1.txt file2.txt file3.txt - CHECK_RESULT $? 0 0 "mv -t命令执行失败" - - LOG_INFO "步骤7: 验证文件是否成功移动" - for file in file1.txt file2.txt file3.txt; do - if [ -f "$DEST_DIR/$file" ]; then - LOG_INFO "文件 $file 成功移动到 $DEST_DIR" - else - LOG_ERROR "文件 $file 未成功移动到 $DEST_DIR" - exit 1 - fi - done - - LOG_INFO "步骤8: 清理测试文件" - rm -rf "$TEST_DIR" "$DEST_DIR" - - if [ "$INSTALLED_BEFORE" = "no" ]; then - LOG_INFO "步骤9: 卸载coreutils软件包" - dnf remove -y coreutils - CHECK_RESULT $? 0 0 "卸载coreutils失败" - fi - - LOG_INFO "测试完成" -} - -main "$@" \ No newline at end of file diff --git a/testcases/function_test/pkg_test/coreutils/coreutils/test_coreutils_nproc_all.sh b/testcases/function_test/pkg_test/coreutils/coreutils/test_coreutils_nproc_all.sh deleted file mode 100644 index 2991c5fafe9..00000000000 --- a/testcases/function_test/pkg_test/coreutils/coreutils/test_coreutils_nproc_all.sh +++ /dev/null @@ -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-03-25 -# @License : Mulan PSL v2 -# @Desc : 测试使用--all参数执行nproc命令,打印已安装的处理器的数量 -# ############################################ - -source "$OET_PATH/libs/locallibs/common_lib.sh" - -function run_test() { - LOG_INFO "开始测试nproc命令的--all参数功能" - - # 定义软件包名称 - PACKAGE_NAME="coreutils" - - # 检查yum源中是否存在指定的软件包 - LOG_INFO "检查yum源中是否存在${PACKAGE_NAME}软件包" - dnf list available ${PACKAGE_NAME} &>/dev/null - if [ $? -ne 0 ]; then - LOG_ERROR "yum源中未找到${PACKAGE_NAME}软件包" - exit 255 - fi - - # 检查系统是否已安装coreutils - LOG_INFO "检查系统是否已安装${PACKAGE_NAME}" - rpm -q ${PACKAGE_NAME} &>/dev/null - if [ $? -eq 0 ]; then - LOG_INFO "${PACKAGE_NAME}已安装,标记为已存在" - PACKAGE_INSTALLED="true" - else - LOG_INFO "${PACKAGE_NAME}未安装,将在测试过程中安装" - PACKAGE_INSTALLED="false" - fi - - # 如果未安装,则安装软件包 - if [ "${PACKAGE_INSTALLED}" = "false" ]; then - LOG_INFO "安装${PACKAGE_NAME}软件包" - dnf install -y ${PACKAGE_NAME} &>/dev/null - CHECK_RESULT $? 0 0 "安装${PACKAGE_NAME}失败" - fi - - # 测试nproc命令的--all参数 - LOG_INFO "测试nproc命令的--all参数" - nproc --all &>/dev/null - if [ $? -eq 0 ]; then - LOG_INFO "nproc --all命令执行成功" - # 获取处理器数量 - CPU_COUNT=$(nproc --all) - LOG_INFO "系统处理器数量为:${CPU_COUNT}" - CHECK_RESULT $? 0 0 "获取处理器数量失败" - else - LOG_ERROR "nproc命令不支持--all参数" - exit 255 - fi - - # 环境清理:如果测试前未安装,则卸载软件包 - if [ "${PACKAGE_INSTALLED}" = "false" ]; then - LOG_INFO "卸载${PACKAGE_NAME}软件包" - dnf remove -y ${PACKAGE_NAME} &>/dev/null - CHECK_RESULT $? 0 0 "卸载${PACKAGE_NAME}失败" - LOG_INFO "环境已恢复到测试前状态" - else - LOG_INFO "测试前${PACKAGE_NAME}已安装,保持安装状态" - fi - - LOG_INFO "测试完成" -} - -main "$@" \ No newline at end of file diff --git a/testcases/function_test/pkg_test/coreutils/coreutils/test_coreutils_numfmt_suffix.sh b/testcases/function_test/pkg_test/coreutils/coreutils/test_coreutils_numfmt_suffix.sh deleted file mode 100644 index c1179c91ada..00000000000 --- a/testcases/function_test/pkg_test/coreutils/coreutils/test_coreutils_numfmt_suffix.sh +++ /dev/null @@ -1,107 +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-20 -# @License : Mulan PSL v2 -# @Desc : 测试 numfmt 为输出数字添加后缀,并接受输入数字的可选后缀 -# ############################################ - -source "$OET_PATH/libs/locallibs/common_lib.sh" - -function run_test() { - # 检查软件包是否已经安装 - LOG_INFO "检查numfmt命令是否已经安装" - if command -v numfmt &>/dev/null; then - LOG_INFO "numfmt命令已安装" - ALREADY_INSTALLED=1 - else - LOG_INFO "numfmt命令未安装" - ALREADY_INSTALLED=0 - fi - - # 如果未安装,安装coreutils软件包 - if [ ${ALREADY_INSTALLED} -eq 0 ]; then - LOG_INFO "检查yum源中是否有coreutils软件包" - dnf list available coreutils 2>/dev/null | grep -q coreutils - if [ $? -ne 0 ]; then - LOG_ERROR "yum源中没有coreutils软件包" - exit 255 - fi - - LOG_INFO "安装coreutils软件包" - dnf install -y coreutils - CHECK_RESULT $? 0 0 "安装coreutils失败" - fi - - # 测试1:验证numfmt命令的基本功能 - LOG_INFO "测试1:验证numfmt命令的基本功能,为数字添加标准后缀" - numfmt --to=si 1000 - CHECK_RESULT $? 0 0 "numfmt命令执行失败" - - # 测试2:验证支持输入数字带后缀 - LOG_INFO "测试2:验证numfmt支持输入数字带可选后缀" - numfmt --from=si 1K - CHECK_RESULT $? 0 0 "numfmt处理带后缀输入失败" - - # 测试3:测试完整的转换流程 - LOG_INFO "测试3:测试输入带后缀的数字,输出也带后缀的完整转换" - result=$(numfmt --from=si --to=si 2M 2>/dev/null) - if [ $? -ne 0 ]; then - LOG_ERROR "numfmt转换失败,可能不支持该参数" - exit 255 - fi - echo "转换结果: ${result}" - CHECK_RESULT $? 0 0 "numfmt转换执行失败" - - # 测试4:测试无效参数处理 - LOG_INFO "测试4:测试无效参数处理" - numfmt --invalid-param 2>/dev/null - if [ $? -eq 0 ]; then - LOG_ERROR "无效参数应该导致命令失败" - exit 255 - fi - - # 测试5:测试具体数值转换 - LOG_INFO "测试5:测试具体数值转换:1500转换为带后缀格式" - result=$(numfmt --to=si 1500) - expected="1.5K" - if [ "$result" != "$expected" ]; then - LOG_ERROR "转换结果不正确: 期望${expected}, 实际${result}" - exit 1 - fi - CHECK_RESULT $? 0 0 "数值转换结果验证失败" - - # 测试6:测试从带后缀的输入转换 - LOG_INFO "测试6:测试从带后缀的输入转换:2.5K转换为字节" - result=$(numfmt --from=si "2.5K") - expected="2500" - if [ "$result" != "$expected" ]; then - LOG_ERROR "转换结果不正确: 期望${expected}, 实际${result}" - exit 1 - fi - CHECK_RESULT $? 0 0 "带后缀输入转换验证失败" - - # 清理环境:如果之前未安装,则卸载软件包 - if [ ${ALREADY_INSTALLED} -eq 0 ]; then - LOG_INFO "清理环境:卸载coreutils软件包" - dnf remove -y coreutils - CHECK_RESULT $? 0 0 "卸载coreutils失败" - else - LOG_INFO "保持已安装的coreutils软件包状态" - fi - - LOG_INFO "测试脚本执行完成" -} - -main "$@" \ No newline at end of file diff --git a/testcases/function_test/pkg_test/coreutils/coreutils/test_coreutils_split_d.sh b/testcases/function_test/pkg_test/coreutils/coreutils/test_coreutils_split_d.sh deleted file mode 100644 index e8443f1e580..00000000000 --- a/testcases/function_test/pkg_test/coreutils/coreutils/test_coreutils_split_d.sh +++ /dev/null @@ -1,131 +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-25 -# @License : Mulan PSL v2 -# @Desc : 测试使用数字后缀 -# ############################################ - -source "$OET_PATH/libs/locallibs/common_lib.sh" - -function run_test() { - # 定义日志函数(虽然题目说直接使用,但实际未定义,这里补充定义) - LOG_INFO() { - echo "[INFO] $*" - } - - LOG_ERROR() { - echo "[ERROR] $*" >&2 - } - - # 定义检查结果函数(虽然题目说直接使用,但实际未定义,这里补充定义) - CHECK_RESULT() { - local actual=$1 - local expect=$2 - local exit_code=$3 - local message=$4 - if [ $actual -eq $expect ]; then - LOG_INFO "$message 成功" - return 0 - else - LOG_ERROR "$message 失败" - exit $exit_code - fi - } - - # 定义SSH_CMD函数(虽然题目说直接使用,但实际未定义,这里补充定义) - SSH_CMD() { - local cmd=$1 - local node_ip=$2 - local node_password=$3 - local node_user=$4 - # 这里假设使用sshpass进行密码登录,实际环境可能需要调整 - sshpass -p "$node_password" ssh -o StrictHostKeyChecking=no "$node_user@$node_ip" "$cmd" - } - - # 测试用例描述:测试使用数字后缀 - LOG_INFO "开始测试split命令的数字后缀功能" - - # 检查split命令是否已安装 - LOG_INFO "检查split命令是否已安装" - if command -v split &> /dev/null; then - LOG_INFO "split命令已安装" - already_installed=true - else - LOG_INFO "split命令未安装" - already_installed=false - fi - - # 如果未安装,则尝试安装 - if [ "$already_installed" = false ]; then - LOG_INFO "尝试安装coreutils包(包含split命令)" - - # 检查yum源中是否有coreutils包 - LOG_INFO "检查yum源中是否有coreutils包" - if dnf list available coreutils &> /dev/null; then - LOG_INFO "yum源中存在coreutils包" - else - LOG_ERROR "yum源中不存在coreutils包" - exit 255 - fi - - # 安装coreutils包 - LOG_INFO "安装coreutils包" - dnf install -y coreutils - CHECK_RESULT $? 0 0 "安装coreutils包" - fi - - # 测试split命令的数字后缀参数 - LOG_INFO "测试split命令的数字后缀参数" - # 创建一个测试文件 - LOG_INFO "创建测试文件test_input.txt" - echo "这是一个测试文件,用于测试split命令的数字后缀功能。" > test_input.txt - for i in {1..50}; do - echo "这是第$i行内容。" >> test_input.txt - done - - # 测试-d参数(使用数字后缀) - LOG_INFO "测试split -d参数" - split -d test_input.txt test_output_ - CHECK_RESULT $? 0 0 "执行split -d命令" - - # 检查生成的文件 - LOG_INFO "检查生成的文件是否使用数字后缀" - ls test_output_* | grep -q "test_output_[0-9][0-9]*" - CHECK_RESULT $? 0 0 "检查数字后缀文件" - - # 验证文件内容 - LOG_INFO "验证分割后的文件内容" - cat test_output_* > combined_output.txt - diff test_input.txt combined_output.txt - CHECK_RESULT $? 0 0 "验证文件内容一致性" - - # 清理测试文件 - LOG_INFO "清理测试文件" - rm -f test_input.txt test_output_* combined_output.txt - CHECK_RESULT $? 0 0 "清理测试文件" - - # 如果之前未安装,则卸载软件包 - if [ "$already_installed" = false ]; then - LOG_INFO "卸载coreutils包" - dnf remove -y coreutils - CHECK_RESULT $? 0 0 "卸载coreutils包" - else - LOG_INFO "保持coreutils包安装状态" - fi - - LOG_INFO "测试完成" -} - -main "$@" \ No newline at end of file diff --git a/testcases/function_test/pkg_test/coreutils/coreutils/test_coreutils_uname_m.sh b/testcases/function_test/pkg_test/coreutils/coreutils/test_coreutils_uname_m.sh deleted file mode 100644 index 8deb39c250d..00000000000 --- a/testcases/function_test/pkg_test/coreutils/coreutils/test_coreutils_uname_m.sh +++ /dev/null @@ -1,88 +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-25 -# @License : Mulan PSL v2 -# @Desc : 测试-m选项,预期输出机器硬件名称 -# ############################################ - -source "$OET_PATH/libs/locallibs/common_lib.sh" - -function run_test() { - # 定义软件包名称和命令 - PACKAGE_NAME="coreutils" - COMMAND="uname" - OPTION="-m" - - # 步骤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:检查命令 ${COMMAND} 是否支持参数 ${OPTION}" - if ! ${COMMAND} --help 2>/dev/null | grep -q "\-m"; then - LOG_ERROR "命令 ${COMMAND} 不支持参数 ${OPTION}" - exit 255 - fi - - # 步骤3:检查软件包是否已安装 - LOG_INFO "步骤3:检查软件包 ${PACKAGE_NAME} 是否已安装" - if rpm -q ${PACKAGE_NAME} &>/dev/null; then - INSTALLED="true" - LOG_INFO "软件包 ${PACKAGE_NAME} 已安装,脚本结束后将保持安装状态" - else - INSTALLED="false" - LOG_INFO "软件包 ${PACKAGE_NAME} 未安装,将在测试步骤中安装" - fi - - # 步骤4:如果未安装,则安装软件包 - if [ "${INSTALLED}" = "false" ]; then - LOG_INFO "步骤4:安装软件包 ${PACKAGE_NAME}" - dnf install -y ${PACKAGE_NAME} - CHECK_RESULT $? 0 0 "安装软件包 ${PACKAGE_NAME} 失败" - fi - - # 步骤5:执行测试命令 - LOG_INFO "步骤5:执行测试命令 ${COMMAND} ${OPTION}" - ${COMMAND} ${OPTION} > /tmp/uname_m_output.txt - CHECK_RESULT $? 0 0 "执行命令 ${COMMAND} ${OPTION} 失败" - - # 步骤6:验证输出结果 - LOG_INFO "步骤6:验证输出结果是否为机器硬件名称" - if [ -s /tmp/uname_m_output.txt ]; then - LOG_INFO "命令输出: $(cat /tmp/uname_m_output.txt)" - CHECK_RESULT $? 0 0 "命令输出为空或无效" - else - LOG_ERROR "命令输出为空" - exit 1 - fi - - # 步骤7:清理临时文件 - LOG_INFO "步骤7:清理临时文件" - rm -f /tmp/uname_m_output.txt - - # 步骤8:如果之前未安装,则卸载软件包 - if [ "${INSTALLED}" = "false" ]; then - LOG_INFO "步骤8:卸载软件包 ${PACKAGE_NAME}" - dnf remove -y ${PACKAGE_NAME} - CHECK_RESULT $? 0 0 "卸载软件包 ${PACKAGE_NAME} 失败" - fi - - LOG_INFO "测试脚本执行完毕" -} - -main "$@" \ No newline at end of file