]> git.gsnw.org Git - fping.git/commitdiff
Adding separate exit codes for success or failure, and printing the number of reachab...
authordeepak0004 <deepak14036@iiitd.ac.in>
Sat, 27 Oct 2018 17:28:01 +0000 (22:58 +0530)
committerdeepak0004 <deepak14036@iiitd.ac.in>
Sat, 27 Oct 2018 17:28:01 +0000 (22:58 +0530)
ci/test-10-option-u-x.pl
src/fping.c

index 49b91200fea1a0a2277e7f6d9d22564d8d5df1f0..35a5bc4a33bced7672fbc2edbf117faf5ad72eda 100755 (executable)
@@ -27,14 +27,14 @@ $cmd->stderr_is_eq("");
 {
 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->stdout_is_eq("Number of reachable hosts: 1\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->exit_is_num(1);
 $cmd->stdout_is_eq("<2 hosts are reachable\n");
 $cmd->stderr_is_eq("");
 }
index 89642155fdf24559863c2f5dc7ad998bda8012be..c1572554c52a6af58f48d7b45495cf13b64a3661 100644 (file)
@@ -1334,11 +1334,12 @@ void finish()
 
     if (reachable_flag) {
         if ((num_hosts-num_unreachable >= reachable)) {
-            printf(">=%d hosts are reachable\n", reachable);
+            printf("Number of reachable hosts: %d\n", num_hosts-num_unreachable);
+            exit(0);
         } else {
             printf("<%d hosts are reachable\n", reachable);
+            exit(1);
         }
-        exit(0);
     }
 
     if (num_noaddress)