From 61f31ec82e98d0ee889a29f7082a21c25383060c Mon Sep 17 00:00:00 2001 From: Vladimir <8758939+fan-xindong@user.noreply.gitee.com> Date: Sun, 28 May 2023 03:23:00 +0000 Subject: [PATCH 1/2] add ethtool/testcase/test_ethtool.sh. Signed-off-by: Vladimir <8758939+fan-xindong@user.noreply.gitee.com> --- ethtool/testcase/test_ethtool.sh | 49 ++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 ethtool/testcase/test_ethtool.sh diff --git a/ethtool/testcase/test_ethtool.sh b/ethtool/testcase/test_ethtool.sh new file mode 100644 index 0000000..15228bd --- /dev/null +++ b/ethtool/testcase/test_ethtool.sh @@ -0,0 +1,49 @@ +#!/bin/bash +############################################################################### +# @用例ID: 20230527-105345-854289012 +# @用例名称: test_ethtool +# @用例级别: 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" + # @预置条件: 查看ethtool是否安装 + command -v ethtool &> /dev/null + assert_true [ $? -eq 0 ] + + return 0 +} + +do_test() { + msg "this is do_test" + + # @测试步骤:1: 获取网卡名称 + interface=$(ip link show | awk -F': ' 'NR==1{print $2}') + + # @测试步骤:2: 测试网卡链接状态 + # @预期结果:2: 成功测试 + ethtool $interface | grep -q "Link detected: yes" + assert_true [ $? -eq 0 ] + + return 0 +} + +tc_teardown() { + msg "this is tc_teardown" + rm -rfv "$g_tmpdir" || return 1 + return 0 +} + +############################################################################### +tst_main "$@" +############################################################################### -- Gitee From 4ec0af8058eec3a64b5a24590cb437998685963d Mon Sep 17 00:00:00 2001 From: Vladimir <8758939+fan-xindong@user.noreply.gitee.com> Date: Sun, 28 May 2023 05:22:11 +0000 Subject: [PATCH 2/2] update ethtool/testcase/test_ethtool.sh. Signed-off-by: Vladimir <8758939+fan-xindong@user.noreply.gitee.com> --- ethtool/testcase/test_ethtool.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ethtool/testcase/test_ethtool.sh b/ethtool/testcase/test_ethtool.sh index 15228bd..0b4f523 100644 --- a/ethtool/testcase/test_ethtool.sh +++ b/ethtool/testcase/test_ethtool.sh @@ -32,7 +32,7 @@ do_test() { # @测试步骤:2: 测试网卡链接状态 # @预期结果:2: 成功测试 - ethtool $interface | grep -q "Link detected: yes" + ethtool $interface | grep -q "Link detected:" assert_true [ $? -eq 0 ] return 0 -- Gitee