diff --git a/tests/kernel/usb_nic.pm b/tests/kernel/usb_nic.pm new file mode 100644 index 000000000000..aaf12149f157 --- /dev/null +++ b/tests/kernel/usb_nic.pm @@ -0,0 +1,46 @@ +# SUSE's openQA tests +# +# Copyright SUSE LLC +# SPDX-License-Identifier: FSFAP + +# Package: usb_nic +# Summary: Simple smoke test for testing USB NIC connected to system +# Maintainer: LSG QE Kernel + +use base 'opensusebasetest'; +use strict; +use warnings; +use testapi; +use serial_terminal 'select_serial_terminal'; +use utils; +use Utils::Logging 'export_logs_basic'; + +sub run { + my ($self) = @_; + + select_serial_terminal; + + zypper_call('in -t package ethtool'); + + my $ping_peer = get_var('USB_ETH_PING_PEER', 'openqa.oqa.prg2.suse.org'); + my $interface = script_output 'basename $(readlink /sys/class/net/* | grep usb )'; + + assert_script_run "echo \"BOOTPROTO='dhcp'\" > /etc/sysconfig/network/ifcfg-$interface"; + assert_script_run "echo \"STARTMODE='auto'\" >> /etc/sysconfig/network/ifcfg-$interface"; + + assert_script_run "ifup $interface"; + + # wait until interface is up + while (1) { + sleep(3); + last if script_output "ip -4 addr show $interface | grep -oP \'(?<=inet\\s)\\d+(\\.\\d+){3}\'" ne ""; + } + + assert_script_run("ping -I $interface -c 4 $ping_peer"); +} + +sub test_flags { + return {fatal => 0}; +} + +1;