Skip to content

Commit

Permalink
Add a simple smoke test for a connected USB NIC
Browse files Browse the repository at this point in the history
We assume the system has a network interface connected via USB, and will
bring it up, configure it and do a simple ping test to a host.

USB_ETH_PING_PEER the host to ping, defaults to openqa.oqa.prg2.suse.org
  • Loading branch information
Michael Moese authored and frankenmichl committed Feb 2, 2024
1 parent 9c62efc commit 3e1e960
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions tests/kernel/usb_nic.pm
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>

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;

0 comments on commit 3e1e960

Please sign in to comment.