diff options
author | Ton Voon <tonvoon@users.sourceforge.net> | 2007-12-11 12:05:16 +0000 |
---|---|---|
committer | Ton Voon <tonvoon@users.sourceforge.net> | 2007-12-11 12:05:16 +0000 |
commit | ba6b4cab4125b5f07f6e37c8504824850425267f (patch) | |
tree | aa6dd866c3227576b4d489c81ad4caa992b8a4c9 /lib | |
parent | 1fcc40c49b349a1bd0e3e73e40fbd7ae88fc1c37 (diff) | |
download | monitoring-plugins-ba6b4cab4125b5f07f6e37c8504824850425267f.tar.gz |
Fixed test so works on MacOSX (use /bin/sh instead of /bin/grep).
Added extra test for missing command - should drop into STATE_UNKNOWN
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1863 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'lib')
-rw-r--r-- | lib/tests/test_cmd.c | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/lib/tests/test_cmd.c b/lib/tests/test_cmd.c index 4da76a9b..7d0915bd 100644 --- a/lib/tests/test_cmd.c +++ b/lib/tests/test_cmd.c @@ -51,7 +51,7 @@ main (int argc, char **argv) int c; int result = UNSET; - plan_tests(47); + plan_tests(50); diag ("Running plain echo command, set one"); @@ -194,17 +194,32 @@ main (int argc, char **argv) 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 (); } |