Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Signed-off-by: qyb <qiuyingbo@gmail.com>

generate fakenetstat script in testrunner.pl

Signed-off-by: qyb <qiuyingbo@gmail.com>
  • Loading branch information
qyb committed Jul 2, 2022
1 parent 790b3b6 commit 9922163
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions cassandane/testrunner.pl
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@
},
);

#run test_wsl() before sudo to cyrus
test_wsl();

become_cyrus();

eval
Expand Down Expand Up @@ -352,3 +355,29 @@ sub _listitem {
$item =~ s/\..*// if ($do_list == 1);
return $item;
}

sub _trim {
my $s = shift;
if (!$s) {
return "";
} else {
$s =~ s/^\s+|\s+$//g;
return $s;
}
}

sub test_wsl {
# In WSL system, it will generate `fakenetstat` script
my $wsl = _trim(`systemd-detect-virt`);
if ($wsl eq "wsl") {
my $netstat_exe = _trim(`which netstat.exe`);
if ($netstat_exe) {
open my $fh, '>', './utils/fakenetstat'
or die "Cannot generate fakenetstat for WSL";
print $fh $netstat_exe.
" -an | sed -e 's/LISTENING/LISTEN/' -e 's/ TCP/tcp 0 0/'\n";
close $fh;
chmod(0755, './utils/fakenetstat');
}
}
}

0 comments on commit 9922163

Please sign in to comment.