Skip to content

Commit

Permalink
Improvements to usb_nic.pm
Browse files Browse the repository at this point in the history
- Check for USB network interfaces before doing anything else
- try pinging each neighbour of interface instead of the default gateway

Co-authored-by: Martin Doucha <[email protected]>
  • Loading branch information
frankenmichl and mdoucha committed Apr 23, 2024
1 parent d684d88 commit ef078d6
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions tests/kernel/usb_nic.pm
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,31 @@ sub run {

select_serial_terminal;

my $interface = script_output 'basename $(readlink /sys/class/net/* | grep usb )';
my $usb_net_devs = script_output('readlink /sys/class/net/* | grep usb', proceed_on_failure => 1);
die "no USB network interfaces found" unless $usb_net_devs ne "";

my $interface = script_output "basename $usb_net_devs";

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 -o debug", 60);

my $route = script_output "ip route show default";
my @ping_peer = $route =~ /default via (\S+)/;
assert_script_run "ping -I $interface -c 4 @ping_peer";
sleep 30;
my $inet = script_output("ip addr show dev $interface | awk \'/inet / {split(\$0,a); print a[2]}\'", proceed_on_failure => 1);
die "no IP address configured" unless $inet ne "";

record_info("IP address(es)", "$inet");

my $neigh = script_output("ip neigh show dev $interface");
my $peer_count = 0;

while ($neigh =~ m/^(\S+)/mg) {
return unless script_run "ping -I $interface -c 4 $1";
$peer_count++;
}

record_info("Ping failed", "None of $peer_count peers responded to ping", result => 'fail');
}

sub test_flags {
Expand Down

0 comments on commit ef078d6

Please sign in to comment.