diff --git a/filesystem/testcase/filesystem.sh b/filesystem/testcase/filesystem.sh new file mode 100755 index 0000000000000000000000000000000000000000..ea059f3d144a46fd8c6715d7e856ce31259a2586 --- /dev/null +++ b/filesystem/testcase/filesystem.sh @@ -0,0 +1,62 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20230528-135249-061746142 +# @用例名称: filesystem +# @用例级别: 3 +# @用例标签: +# @用例类型: 功能 +############################################################################### +[ -z "$TST_TS_TOPDIR" ] && { + TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" + export TST_TS_TOPDIR +} +source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1 +############################################################################### + +g_tmpdir="$(mktemp -d)" + +tc_setup() { + msg "this is tc_setup" + + # @预置条件: 系统正常运行,且已安装 `filesystem` 包 + assert_true yum install -y filesystem + + return 0 +} + +do_test() { + msg "this is do_test" + + # @测试步骤:1 创建临时目录 + # @预期结果:1 确保临时目录能够成功创建 + assert_true mkdir /tmp/testdir + + # @测试步骤:2 复制文件到目标目录 + # @预期结果:2 确保文件能够成功复制到目标目录 + assert_true cp file.txt /tmp/testdir/ + + # @测试步骤:3 移动文件到目标目录 + # @预期结果:3 确保文件能够成功移动到目标目录 + assert_true mv file.txt /tmp/testdir/ + + # @测试步骤:4 删除目标目录 + # @预期结果:4 确保目标目录能够成功删除 + assert_true rm -rf /tmp/testdir + + # @测试步骤:5 检查文件是否存在 + # @预期结果:5 确保文件在目标目录中不存在 + assert_false [ -f /tmp/testdir/file.txt ] + + return 0 +} + + +tc_teardown() { + msg "this is tc_teardown" + rm -rfv "$g_tmpdir" || return 1 + return 0 +} + +############################################################################### +tst_main "$@" +###############################################################################