From 0a58383ed8df6aa00c2d6b28302233f0185fdc5b Mon Sep 17 00:00:00 2001 From: Ariadne Conill Date: Mon, 21 Sep 2020 08:55:20 -0600 Subject: [PATCH] tests: ethtool: add tests for basic link settings, wol and autoneg --- tests/linux/Kyuafile | 1 + tests/linux/ethtool_test | 84 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+) create mode 100755 tests/linux/ethtool_test diff --git a/tests/linux/Kyuafile b/tests/linux/Kyuafile index 050c55d..4e1c304 100644 --- a/tests/linux/Kyuafile +++ b/tests/linux/Kyuafile @@ -11,3 +11,4 @@ atf_test_program{name='ppp_test'} atf_test_program{name='tunnel_test'} atf_test_program{name='gre_test'} atf_test_program{name='wireguard_test'} +atf_test_program{name='ethtool_test'} diff --git a/tests/linux/ethtool_test b/tests/linux/ethtool_test new file mode 100755 index 0000000..584eaad --- /dev/null +++ b/tests/linux/ethtool_test @@ -0,0 +1,84 @@ +#!/usr/bin/env atf-sh + +. $(atf_get_srcdir)/../test_env.sh +EXECUTOR="$(atf_get_srcdir)/../../executor-scripts/linux/ethtool" + +tests_init \ + pre_up_msglvl \ + pre_up_ethernet_port \ + up_speed \ + up_duplex \ + up_wol \ + up_wol_sopass \ + up_autoneg_simple \ + up_autoneg_mask + +pre_up_msglvl_body() { + export IFACE="eth0" PHASE="pre-up" IF_ETHTOOL_MSGLVL="debug on" MOCK="echo" + atf_check -s exit:0 \ + -o match:'ethtool --change eth0' \ + -o match:'msglvl debug on' \ + ${EXECUTOR} +} + +pre_up_ethernet_port_body() { + export IFACE="eth0" PHASE="pre-up" IF_ETHTOOL_ETHERNET_PORT="4" MOCK="echo" + atf_check -s exit:0 \ + -o match:'ethtool --change eth0' \ + -o match:'port 4' \ + ${EXECUTOR} +} + +up_speed_body() { + export IFACE="eth0" PHASE="up" IF_ETHTOOL_LINK_SPEED="1000" MOCK="echo" + atf_check -s exit:0 \ + -o match:'ethtool --change eth0' \ + -o match:'speed 1000' \ + ${EXECUTOR} +} + +up_duplex_body() { + export IFACE="eth0" PHASE="up" IF_ETHTOOL_LINK_DUPLEX="full" MOCK="echo" + atf_check -s exit:0 \ + -o match:'ethtool --change eth0' \ + -o match:'duplex full' \ + ${EXECUTOR} +} + +up_wol_body() { + export IFACE="eth0" PHASE="up" IF_ETHTOOL_ETHERNET_WOL="g" MOCK="echo" + atf_check -s exit:0 \ + -o match:'ethtool --change eth0' \ + -o match:'wol g' \ + ${EXECUTOR} +} + +up_wol_sopass_body() { + export IFACE="eth0" PHASE="up" IF_ETHTOOL_ETHERNET_WOL="s abc123" MOCK="echo" + atf_check -s exit:0 \ + -o match:'ethtool --change eth0' \ + -o match:'wol s sopass abc123' \ + ${EXECUTOR} +} + +up_autoneg_simple_body() { + export IFACE="eth0" PHASE="up" IF_ETHTOOL_ETHERNET_AUTONEG="on" MOCK="echo" + atf_check -s exit:0 \ + -o match:'ethtool --change eth0' \ + -o match:'autoneg on' \ + ${EXECUTOR} + + export IFACE="eth0" PHASE="up" IF_ETHTOOL_ETHERNET_AUTONEG="off" MOCK="echo" + atf_check -s exit:0 \ + -o match:'ethtool --change eth0' \ + -o match:'autoneg off' \ + ${EXECUTOR} +} + +up_autoneg_mask_body() { + export IFACE="eth0" PHASE="up" IF_ETHTOOL_ETHERNET_AUTONEG="1000/full" MOCK="echo" + atf_check -s exit:0 \ + -o match:'ethtool --change eth0' \ + -o match:'autoneg on advertise 1000/full' \ + ${EXECUTOR} +}