]> git.gsnw.org Git - fping.git/commitdiff
Adding travis ci tests for more coverage and rectifying a mistake
authordeepak0004 <deepak14036@iiitd.ac.in>
Wed, 17 Oct 2018 21:42:13 +0000 (03:12 +0530)
committerdeepak0004 <deepak14036@iiitd.ac.in>
Wed, 17 Oct 2018 21:42:13 +0000 (03:12 +0530)
ci/test-10-option-u-x.pl [moved from ci/test-10-option-u-v.pl with 54% similarity]
src/fping.c

similarity index 54%
rename from ci/test-10-option-u-v.pl
rename to ci/test-10-option-u-x.pl
index 3e9bcf6b1f7bcfc2fab3ab88b66ec6c5b66b1409..49b91200fea1a0a2277e7f6d9d22564d8d5df1f0 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/perl -w
 
-use Test::Command tests => 6;
+use Test::Command tests => 12;
 
 #  -u         show targets that are unreachable
 #  -v         show version
@@ -22,3 +22,19 @@ fping: comments to david\@schweikert\.ch
 });
 $cmd->stderr_is_eq("");
 }
+
+# fping -x
+{
+my $cmd = Test::Command->new(cmd => "fping -x 1 8.8.0.0 127.0.0.1");
+$cmd->exit_is_num(0);
+$cmd->stdout_is_eq(">=1 hosts are reachable\n");
+$cmd->stderr_is_eq("");
+}
+
+# fping -x
+{
+my $cmd = Test::Command->new(cmd => "fping -x 2 8.8.0.0 127.0.0.1");
+$cmd->exit_is_num(0);
+$cmd->stdout_is_eq("<2 hosts are reachable\n");
+$cmd->stderr_is_eq("");
+}
index 8f6aeaa27e2b78be05d0359b79e0e7af7e2a1277..9101ee2c29ffa8244ba457b606320945c38d3e24 100644 (file)
@@ -1195,7 +1195,7 @@ void main_loop()
                     h->ev_type = EV_TYPE_PING;
                     h->ev_time.tv_sec = last_send_time.tv_sec;
                     h->ev_time.tv_usec = last_send_time.tv_usec;
-                       timeval_add(&h->ev_time, perhost_interval);
+                     timeval_add(&h->ev_time, perhost_interval);
                     ev_enqueue(h);
                 }
                 /* Count mode: schedule timeout after last ping */
@@ -1281,13 +1281,6 @@ void main_loop()
                 timeval_add(&next_report_time, report_interval);
         }
     }
-    if (reachable_flag) {
-        if ((num_hosts-num_unreachable >= reachable)) {
-            printf(">=%d hosts are reachable\n", reachable);
-        } else {
-            printf("<%d hosts are reachable\n", reachable);
-        }
-    }
 }
 
 /************************************************************
@@ -1329,6 +1322,14 @@ void finish()
         }
     }
 
+    if (reachable_flag) {
+        if ((num_hosts-num_unreachable >= reachable)) {
+            printf(">=%d hosts are reachable\n", reachable);
+        } else {
+            printf("<%d hosts are reachable\n", reachable);
+        }
+    }
+
     if (count_flag || loop_flag)
         print_per_system_stats();
 #if defined(DEBUG) || defined(_DEBUG)
@@ -1904,7 +1905,7 @@ int decode_icmp_ipv4(
     }
 
     *id = ntohs(icp->icmp_id);
-    *seq = ntohs(icp->icmp_seq);    
+    *seq = ntohs(icp->icmp_seq);
 
     return 1;
 }