Skip to content

Commit 6816b5a

Browse files
committed
Tests performance and robustness fixes.
1 parent 81fb0fc commit 6816b5a

File tree

4 files changed

+60
-38
lines changed

4 files changed

+60
-38
lines changed

ci/prepare-linux.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
sudo setcap cap_net_raw,cap_net_admin+ep src/fping
44

5-
if [[ ! $PATH =~ fping/src ]]; then
6-
PATH=/home/dws/checkouts/fping/src:$PATH
5+
if [ -d "$PWD/src" ]; then
6+
if [[ ":$PATH:" != *":$PWD/src:"* ]]; then
7+
PATH="$PWD/src:$PATH"
8+
fi
79
fi

ci/test-05-options-c-e.pl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,12 @@
9292
ff02::1 : xmt/rcv/%loss = 1/1/0%, min/avg/max = \d\.\d+/\d\.\d+/\d\.\d+\n});
9393
}
9494

95-
# fping --icmp-timestamp -c n 127.0.0.1
95+
# fping --icmp-timestamp -c 2 127.0.0.1
9696
SKIP: {
9797
if($^O eq 'darwin') {
9898
skip 'On macOS, this test is unreliable', 3;
9999
}
100-
my $cmd = Test::Command->new(cmd => "fping -4 --icmp-timestamp -c 2 127.0.0.1");
100+
my $cmd = Test::Command->new(cmd => "fping -4 -p 100 --icmp-timestamp -c 2 127.0.0.1");
101101
$cmd->exit_is_num(0);
102102
$cmd->stdout_like(qr{127\.0\.0\.1 : \[0\], 20 bytes, \d\.\d+ ms \(\d\.\d+ avg, 0% loss\), timestamps: Originate=\d+ Receive=\d+ Transmit=\d+ Localreceive=\d+
103103
127\.0\.0\.1 : \[1\], 20 bytes, \d\.\d+ ms \(\d\.\d+ avg, 0% loss\), timestamps: Originate=\d+ Receive=\d+ Transmit=\d+ Localreceive=\d+
@@ -225,7 +225,7 @@
225225
if($ENV{SKIP_IPV6}) {
226226
skip 'Skip IPv6 tests', 3;
227227
}
228-
my $cmd = Test::Command->new(cmd => "fping --check-source ff02::1");
228+
my $cmd = Test::Command->new(cmd => "fping -r1 -t100 --check-source ff02::1");
229229
$cmd->exit_is_num(1);
230230
$cmd->stdout_is_eq("ff02::1 is unreachable\n");
231231
$cmd->stderr_is_eq("");
@@ -236,7 +236,7 @@
236236
if($ENV{SKIP_IPV6}) {
237237
skip 'Skip IPv6 tests', 3;
238238
}
239-
my $cmd = Test::Command->new(cmd => "fping -c1 --check-source 127.0.0.1 ff02::1");
239+
my $cmd = Test::Command->new(cmd => "fping -c1 -t100 --check-source 127.0.0.1 ff02::1");
240240
$cmd->exit_is_num(1);
241241
$cmd->stdout_like(qr{127\.0\.0\.1 : \[0\], 64 bytes, \d\.\d+ ms \(\d\.\d+ avg, 0% loss\)
242242
ff02::1 : \[0\], timed out \(NaN avg, 100% loss\)
@@ -252,7 +252,7 @@
252252
if($ENV{SKIP_IPV6}) {
253253
skip 'Skip IPv6 tests', 3;
254254
}
255-
my $cmd = Test::Command->new(cmd => "fping -C1 --check-source 127.0.0.1 ff02::1");
255+
my $cmd = Test::Command->new(cmd => "fping -C1 -t100 --check-source 127.0.0.1 ff02::1");
256256
$cmd->exit_is_num(1);
257257
$cmd->stdout_like(qr{127\.0\.0\.1 : \[0\], 64 bytes, \d\.\d+ ms \(\d\.\d+ avg, 0% loss\)
258258
ff02::1 : \[0\], timed out \(NaN avg, 100% loss\)
@@ -267,7 +267,7 @@
267267
{
268268
my $cmd = Test::Command->new(cmd => "fping -d 127.0.0.1");
269269
$cmd->exit_is_num(0);
270-
$cmd->stdout_is_eq("localhost is alive\n");
270+
$cmd->stdout_like(qr/^localhost(\.localdomain)? is alive\n$/);
271271
$cmd->stderr_is_eq("");
272272
}
273273

ci/test-07-options-i-m.pl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,15 @@
5656

5757
# fping -l
5858
{
59-
my $cmd = Test::Command->new(cmd => '(sleep 2; pkill fping)& fping -p 900 -l 127.0.0.1');
59+
my $cmd = Test::Command->new(cmd => '(sleep 0.5; pkill fping)& fping -p 100 -l 127.0.0.1');
6060
$cmd->stdout_like(qr{127\.0\.0\.1 : \[0\], 64 bytes, \d\.\d+ ms \(\d\.\d+ avg, 0% loss\)
6161
127\.0\.0\.1 : \[1\], 64 bytes, \d\.\d+ ms \(\d\.\d+ avg, 0% loss\)
6262
});
6363
}
6464

6565
# fping -l --print-tos --print-ttl
6666
{
67-
my $cmd = Test::Command->new(cmd => '(sleep 2; pkill fping)& fping -p 900 --print-ttl --print-tos -l 127.0.0.1');
67+
my $cmd = Test::Command->new(cmd => '(sleep 0.5; pkill fping)& fping -p 100 --print-ttl --print-tos -l 127.0.0.1');
6868
$cmd->stdout_like(qr{127\.0\.0\.1 : \[0\], 64 bytes, \d\.\d+ ms \(\d\.\d+ avg, 0% loss\) \(TOS \d+\) \(TTL \d+\)
6969
127\.0\.0\.1 : \[1\], 64 bytes, \d\.\d+ ms \(\d\.\d+ avg, 0% loss\) \(TOS \d+\) \(TTL \d+\)
7070
});
@@ -83,7 +83,7 @@
8383

8484
# fping -l with SIGQUIT
8585
{
86-
my $cmd = Test::Command->new(cmd => '(sleep 2; pkill -QUIT fping; sleep 2; pkill fping)& fping -p 900 -l 127.0.0.1');
86+
my $cmd = Test::Command->new(cmd => '(sleep 0.5; pkill -QUIT fping; sleep 0.5; pkill fping)& fping -p 100 -l 127.0.0.1');
8787
$cmd->stdout_like(qr{127\.0\.0\.1 : \[0\], 64 bytes, \d\.\d+ ms \(\d\.\d+ avg, 0% loss\)
8888
127\.0\.0\.1 : \[1\], 64 bytes, \d\.\d+ ms \(\d\.\d+ avg, 0% loss\)
8989
127\.0\.0\.1 : \[2\], 64 bytes, \d\.\d+ ms \(\d\.\d+ avg, 0% loss\)
@@ -100,7 +100,7 @@
100100
if($^O eq 'darwin') {
101101
skip 'On macOS, this test is unreliable', 2;
102102
}
103-
my $cmd = Test::Command->new(cmd => '(sleep 2; pkill fping)& fping -p 850 -l -Q 1 127.0.0.1');
103+
my $cmd = Test::Command->new(cmd => '(sleep 1.5; pkill fping)& fping -p 100 -l -Q 0.5 127.0.0.1');
104104
$cmd->stdout_is_eq("");
105105
$cmd->stderr_like(qr{\[\d\d:\d\d:\d\d\]
106106
127\.0\.0\.1 : xmt/rcv/%loss = \d/\d/\d%, min/avg/max = \d\.\d+/\d\.\d+/\d\.\d+
@@ -111,7 +111,7 @@
111111

112112
# fping -l -t
113113
{
114-
my $cmd = Test::Command->new(cmd => '(sleep 2; pkill fping)& fping -p 900 -t 1500 -l 127.0.0.1');
114+
my $cmd = Test::Command->new(cmd => '(sleep 0.5; pkill fping)& fping -p 100 -t 1500 -l 127.0.0.1');
115115
$cmd->stdout_like(qr{127\.0\.0\.1 : \[0\], 64 bytes, \d\.\d+ ms \(\d\.\d+ avg, 0% loss\)
116116
127\.0\.0\.1 : \[1\], 64 bytes, \d\.\d+ ms \(\d\.\d+ avg, 0% loss\)
117117
});

ci/test-08-options-n-q.pl

Lines changed: 45 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,10 @@
9797
}
9898

9999
# fping -Q
100-
{
100+
SKIP: {
101+
if($^O eq 'darwin') {
102+
skip 'On macOS, -Q tests are unreliable', 3;
103+
}
101104
my $cmd = Test::Command->new(cmd => "fping -Q 1 -p 400 -c 4 127.0.0.1");
102105
$cmd->exit_is_num(0);
103106
$cmd->stdout_is_eq("");
@@ -107,22 +110,26 @@
107110
});
108111
}
109112

110-
# fping -Q (longer test to show two time stamps and reset statistics)
111-
{
112-
my $cmd = Test::Command->new(cmd => "fping -Q 1 -p 550 -c 5 127.0.0.1");
113+
# fping -Q (fractional time)
114+
SKIP: {
115+
if($^O eq 'darwin') {
116+
skip 'On macOS, -Q tests are unreliable', 3;
117+
}
118+
my $cmd = Test::Command->new(cmd => "fping -Q0.5 -p 200 -c 4 127.0.0.1");
113119
$cmd->exit_is_num(0);
114120
$cmd->stdout_is_eq("");
115121
$cmd->stderr_like(qr{\[\d+:\d+:\d+\]
116-
127\.0\.0\.1 : xmt/rcv/%loss = 2/2/0%, min/avg/max = \d\.\d+/\d\.\d+/\d\.\d+
117-
\[\d+:\d+:\d+\]
118-
127\.0\.0\.1 : xmt/rcv/%loss = 2/2/0%, min/avg/max = \d\.\d+/\d\.\d+/\d\.\d+
119-
127\.0\.0\.1 : xmt/rcv/%loss = 5/5/0%, min/avg/max = \d\.\d+/\d\.\d+/\d\.\d+
122+
127\.0\.0\.1 : xmt/rcv/%loss = 3/3/0%, min/avg/max = \d\.\d+/\d\.\d+/\d\.\d+
123+
127\.0\.0\.1 : xmt/rcv/%loss = 4/4/0%, min/avg/max = \d\.\d+/\d\.\d+/\d\.\d+
120124
});
121125
}
122126

123-
# fping -Q n ignores non-number characters after the number, except for keywords
124-
{
125-
my $cmd = Test::Command->new(cmd => "fping -Q 1whatever -p 550 -c 5 127.0.0.1");
127+
# fping -Q (longer test to show two time stamps and reset statistics)
128+
SKIP: {
129+
if($^O eq 'darwin') {
130+
skip 'On macOS, -Q tests are unreliable', 3;
131+
}
132+
my $cmd = Test::Command->new(cmd => "fping -Q 1 -p 550 -c 5 127.0.0.1");
126133
$cmd->exit_is_num(0);
127134
$cmd->stdout_is_eq("");
128135
$cmd->stderr_like(qr{\[\d+:\d+:\d+\]
@@ -134,8 +141,11 @@
134141
}
135142

136143
# fping -Q n ignores unknown keywords
137-
{
138-
my $cmd = Test::Command->new(cmd => "fping -Q 1,not_a_keyword -p 550 -c 5 127.0.0.1");
144+
SKIP: {
145+
if($^O eq 'darwin') {
146+
skip 'On macOS, -Q tests are unreliable', 3;
147+
}
148+
my $cmd = Test::Command->new(cmd => "fping -Q 0.5,not_a_keyword -p 300 -c 5 127.0.0.1");
139149
$cmd->exit_is_num(0);
140150
$cmd->stdout_is_eq("");
141151
$cmd->stderr_like(qr{\[\d+:\d+:\d+\]
@@ -147,8 +157,11 @@
147157
}
148158

149159
# fping -Q n,cumulative
150-
{
151-
my $cmd = Test::Command->new(cmd => "fping -Q 1,cumulative -p 550 -c 5 127.0.0.1");
160+
SKIP: {
161+
if($^O eq 'darwin') {
162+
skip 'On macOS, -Q tests are unreliable', 3;
163+
}
164+
my $cmd = Test::Command->new(cmd => "fping -Q 0.5,cumulative -p 300 -c 5 127.0.0.1");
152165
$cmd->exit_is_num(0);
153166
$cmd->stdout_is_eq("");
154167
$cmd->stderr_like(qr{\[\d+:\d+:\d+\]
@@ -160,28 +173,35 @@
160173
}
161174

162175
# fping -Q -o
163-
{
164-
my $cmd = Test::Command->new(cmd => "fping -c4 -Q1 -p550 -o 8.8.8.7");
176+
SKIP: {
177+
if($^O eq 'darwin') {
178+
skip 'On macOS, -Q tests are unreliable', 3;
179+
}
180+
my $cmd = Test::Command->new(cmd => "fping -c4 -Q0.5 -p300 -o 8.8.8.7");
165181
$cmd->exit_is_num(1);
166182
$cmd->stdout_is_eq("");
167183
$cmd->stderr_like(qr{\[\d+:\d+:\d+\]
168-
8\.8\.8\.7 : xmt/rcv/%loss = 1/0/100%, outage\(ms\) = 55\d
184+
8\.8\.8\.7 : xmt/rcv/%loss = 1/0/100%, outage\(ms\) = 30\d
169185
\[\d+:\d+:\d+\]
170-
8\.8\.8\.7 : xmt/rcv/%loss = 2/0/100%, outage\(ms\) = 110\d
171-
8\.8\.8\.7 : xmt/rcv/%loss = 4/0/100%, outage\(ms\) = 220\d
186+
8\.8\.8\.7 : xmt/rcv/%loss = 2/0/100%, outage\(ms\) = 60\d
187+
8\.8\.8\.7 : xmt/rcv/%loss = 4/0/100%, outage\(ms\) = 120\d
172188
});
173189
}
174190

175191
# fping -Q n,cumulative -o
176-
{
177-
my $cmd = Test::Command->new(cmd => "fping -c4 -Q1,cumulative -p550 -o 8.8.8.7");
192+
SKIP: {
193+
if($^O eq 'darwin') {
194+
skip 'On macOS, -Q tests are unreliable', 3;
195+
}
196+
my $cmd = Test::Command->new(cmd => "fping -c4 -Q0.5,cumulative -p300 -o 8.8.8.7");
178197
$cmd->exit_is_num(1);
179198
$cmd->stdout_is_eq("");
180199
$cmd->stderr_like(qr{\[\d+:\d+:\d+\]
181-
8\.8\.8\.7 : xmt/rcv/%loss = 1/0/100%, outage\(ms\) = 55\d
200+
8\.8\.8\.7 : xmt/rcv/%loss = 1/0/100%, outage\(ms\) = 30\d
182201
\[\d+:\d+:\d+\]
183-
8\.8\.8\.7 : xmt/rcv/%loss = 3/0/100%, outage\(ms\) = 165\d
184-
8\.8\.8\.7 : xmt/rcv/%loss = 4/0/100%, outage\(ms\) = 220\d
202+
8\.8\.8\.7 : xmt/rcv/%loss = 3/0/100%, outage\(ms\) = 90\d
203+
8\.8\.8\.7 : xmt/rcv/%loss = 4/0/100%, outage\(ms\) = 120\d
185204
});
186205
}
187206

207+

0 commit comments

Comments
 (0)