summaryrefslogtreecommitdiffstats
path: root/lib/tests
diff options
context:
space:
mode:
Diffstat (limited to 'lib/tests')
-rw-r--r--lib/tests/test_cmd.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/lib/tests/test_cmd.c b/lib/tests/test_cmd.c
index 4da76a9..7d0915b 100644
--- a/lib/tests/test_cmd.c
+++ b/lib/tests/test_cmd.c
@@ -51,7 +51,7 @@ main (int argc, char **argv)
51 int c; 51 int c;
52 int result = UNSET; 52 int result = UNSET;
53 53
54 plan_tests(47); 54 plan_tests(50);
55 55
56 diag ("Running plain echo command, set one"); 56 diag ("Running plain echo command, set one");
57 57
@@ -194,17 +194,32 @@ main (int argc, char **argv)
194 result = UNSET; 194 result = UNSET;
195 195
196 command = (char *)malloc(COMMAND_LINE); 196 command = (char *)malloc(COMMAND_LINE);
197 strcpy(command, "/bin/grep pattern non-existant-file"); 197 strcpy(command, "/bin/sh non-existant-file");
198 result = cmd_run (command, &chld_out, &chld_err, 0); 198 result = cmd_run (command, &chld_out, &chld_err, 0);
199 199
200 ok (chld_out.lines == 0, 200 ok (chld_out.lines == 0,
201 "Grep returns no stdout when file is missing..."); 201 "/bin/sh returns no stdout when file is missing...");
202 ok (chld_err.lines == 1, 202 ok (chld_err.lines == 1,
203 "...but does give an error line"); 203 "...but does give an error line");
204 ok (strstr(chld_err.line[0],"non-existant-file") != NULL, "And missing filename is in error message"); 204 ok (strstr(chld_err.line[0],"non-existant-file") != NULL, "And missing filename is in error message");
205 ok (result == 2, "Get return code 2 from grep"); 205 ok (result == 127, "Get return code 127 from /bin/sh");
206 206
207 207
208 /* ensure everything is empty again */
209 memset (&chld_out, 0, sizeof (output));
210 memset (&chld_err, 0, sizeof (output));
211 result = UNSET;
212
213 command = (char *)malloc(COMMAND_LINE);
214 strcpy(command, "/bin/non-existant-command");
215 result = cmd_run (command, &chld_out, &chld_err, 0);
216
217 ok (chld_out.lines == 0,
218 "/bin/non-existant-command returns no stdout...");
219 ok (chld_err.lines == 0,
220 "...and no stderr output either");
221 ok (result == 3, "Get return code 3 = UNKNOWN when command does not exist");
222
208 223
209 return exit_status (); 224 return exit_status ();
210} 225}