SF.net SVN: nagiosplug: [1863] nagiosplug/trunk/lib/tests/test_cmd.c

[email protected]
Newsgroups gmane.network.nagios.plugins.cvs
Message-ID <[email protected]>
Revision: 1863
          http://nagiosplug.svn.sourceforge.net/nagiosplug/?rev=1863&view=rev
Author:   tonvoon
Date:     2007-12-11 04:05:16 -0800 (Tue, 11 Dec 2007)

Log Message:
-----------
Fixed test so works on MacOSX (use /bin/sh instead of /bin/grep).
Added extra test for missing command - should drop into STATE_UNKNOWN

Modified Paths:
--------------
    nagiosplug/trunk/lib/tests/test_cmd.c

Modified: nagiosplug/trunk/lib/tests/test_cmd.c
===================================================================
--- nagiosplug/trunk/lib/tests/test_cmd.c	2007-12-11 10:58:21 UTC (rev 1862)
+++ nagiosplug/trunk/lib/tests/test_cmd.c	2007-12-11 12:05:16 UTC (rev 1863)
@@ -51,7 +51,7 @@
 	int c;
 	int result = UNSET;
 
-	plan_tests(47);
+	plan_tests(50);
 
 	diag ("Running plain echo command, set one");
 
@@ -194,17 +194,32 @@
 	result = UNSET;
 
 	command = (char *)malloc(COMMAND_LINE);
-	strcpy(command, "/bin/grep pattern non-existant-file");
+	strcpy(command, "/bin/sh non-existant-file");
 	result = cmd_run (command, &chld_out, &chld_err, 0);
 
 	ok (chld_out.lines == 0,
-			"Grep returns no stdout when file is missing...");
+			"/bin/sh returns no stdout when file is missing...");
 	ok (chld_err.lines == 1,
 			"...but does give an error line");
 	ok (strstr(chld_err.line[0],"non-existant-file") != NULL, "And missing filename is in error message");
-	ok (result == 2, "Get return code 2 from grep");
+	ok (result == 127, "Get return code 127 from /bin/sh");
 
 
+	/* ensure everything is empty again */
+	memset (&chld_out, 0, sizeof (output));
+	memset (&chld_err, 0, sizeof (output));
+	result = UNSET;
 
+	command = (char *)malloc(COMMAND_LINE);
+	strcpy(command, "/bin/non-existant-command");
+	result = cmd_run (command, &chld_out, &chld_err, 0);
+
+	ok (chld_out.lines == 0,
+			"/bin/non-existant-command returns no stdout...");
+	ok (chld_err.lines == 0,
+			"...and no stderr output either");
+	ok (result == 3, "Get return code 3 = UNKNOWN when command does not exist");
+
+
 	return exit_status ();
 }


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.

-------------------------------------------------------------------------
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.