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 19, 2024
1 parent 5bea16f commit c0db7f1
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions tests/kernel/usb_nic.pm
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,25 @@ 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";
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 c0db7f1

Please sign in to comment.