-
Notifications
You must be signed in to change notification settings - Fork 278
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a simple smoke test for a connected USB NIC
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
1 parent
9c62efc
commit 3e1e960
Showing
1 changed file
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |