Commit 1569f8f1 authored by Colin Watson's avatar Colin Watson
Browse files

More (void *) 0 as variadic sentinel

* tests/basic.c (test_basic_status, test_basic_args,
test_basic_pipeline, test_basic_wait_all, test_basic_setenv,
test_basic_unsetenv, test_basic_clearenv, test_basic_chdir,
test_basic_fchdir, test_basic_pre_exec, test_basic_sequence): Use
(void *) rather than NULL as a sentinel for variadic functions.
* tests/common.c (temp_dir_teardown): Likewise.
* tests/exec.c (test_exec_process): Likewise.
* tests/inspect.c (test_inspect_command, test_inspect_pipeline):
Likewise.
* tests/pump.c (fail_unless_files_equal,
test_pump_connect_attaches_correctly, test_pump_tee): Likewise.
* tests/redirect.c (test_redirect_files, test_redirect_outfile):
Likewise.
parent e6ff06b8
......@@ -41,9 +41,9 @@ START_TEST (test_basic_status)
{
pipeline *p;
p = pipeline_new_command_args ("true", NULL);
p = pipeline_new_command_args ("true", (void *) 0);
fail_unless (pipeline_run (p) == 0, "true did not return 0");
p = pipeline_new_command_args ("false", NULL);
p = pipeline_new_command_args ("false", (void *) 0);
fail_if (pipeline_run (p) == 0, "false returned 0");
}
END_TEST
......@@ -53,7 +53,7 @@ START_TEST (test_basic_args)
pipeline *p;
const char *line;
p = pipeline_new_command_args ("echo", "foo", NULL);
p = pipeline_new_command_args ("echo", "foo", (void *) 0);
pipeline_want_out (p, -1);
fail_unless (pipecmd_get_nargs (pipeline_get_command (p, 0)) == 2,
"Number of arguments != 2");
......@@ -65,7 +65,7 @@ START_TEST (test_basic_args)
fail_unless (pipeline_wait (p) == 0, "'echo foo' did not return 0");
pipeline_free (p);
p = pipeline_new_command_args ("echo", "foo", "bar", NULL);
p = pipeline_new_command_args ("echo", "foo", "bar", (void *) 0);
pipeline_want_out (p, -1);
fail_unless (pipecmd_get_nargs (pipeline_get_command (p, 0)) == 3,
"Number of arguments != 3");
......@@ -86,8 +86,8 @@ START_TEST (test_basic_pipeline)
const char *line;
p = pipeline_new ();
pipeline_command_args (p, "echo", "foo", NULL);
pipeline_command_args (p, "sed", "-e", "s/foo/bar/", NULL);
pipeline_command_args (p, "echo", "foo", (void *) 0);
pipeline_command_args (p, "sed", "-e", "s/foo/bar/", (void *) 0);
pipeline_want_out (p, -1);
pipeline_start (p);
line = pipeline_readline (p);
......@@ -108,9 +108,9 @@ START_TEST (test_basic_wait_all)
int n_statuses;
p = pipeline_new ();
pipeline_command_args (p, SHELL, "-c", "exit 2", NULL);
pipeline_command_args (p, SHELL, "-c", "exit 3", NULL);
pipeline_command_args (p, "true", NULL);
pipeline_command_args (p, SHELL, "-c", "exit 2", (void *) 0);
pipeline_command_args (p, SHELL, "-c", "exit 3", (void *) 0);
pipeline_command_args (p, "true", (void *) 0);
pipeline_start (p);
fail_unless (pipeline_wait_all (p, &statuses, &n_statuses) == 127);
fail_unless (n_statuses == 3);
......@@ -126,7 +126,7 @@ START_TEST (test_basic_setenv)
{
pipeline *p;
p = pipeline_new_command_args (SHELL, "-c", "exit $TEST1", NULL);
p = pipeline_new_command_args (SHELL, "-c", "exit $TEST1", (void *) 0);
pipecmd_setenv (pipeline_get_command (p, 0), "TEST1", "10");
fail_unless (pipeline_run (p) == 10, "TEST1 not set properly");
}
......@@ -139,7 +139,7 @@ START_TEST (test_basic_unsetenv)
setenv ("TEST2", "foo", 1);
p = pipeline_new_command_args (SHELL, "-c", "echo $TEST2", NULL);
p = pipeline_new_command_args (SHELL, "-c", "echo $TEST2", (void *) 0);
pipeline_want_out (p, -1);
pipeline_start (p);
line = pipeline_readline (p);
......@@ -149,7 +149,7 @@ START_TEST (test_basic_unsetenv)
pipeline_wait (p);
pipeline_free (p);
p = pipeline_new_command_args (SHELL, "-c", "echo $TEST2", NULL);
p = pipeline_new_command_args (SHELL, "-c", "echo $TEST2", (void *) 0);
pipecmd_unsetenv (pipeline_get_command (p, 0), "TEST2");
pipeline_want_out (p, -1);
pipeline_start (p);
......@@ -170,7 +170,7 @@ START_TEST (test_basic_clearenv)
setenv ("TEST3", "foo", 1);
p = pipeline_new_command_args (SHELL, "-c", "echo $TEST3; echo $TEST4",
NULL);
(void *) 0);
pipeline_want_out (p, -1);
pipeline_start (p);
line1 = pipeline_readline (p);
......@@ -240,7 +240,7 @@ START_TEST (test_basic_chdir)
char *line, *end;
char *child_base, *expected_base;
p = pipeline_new_command_args ("pwd", NULL);
p = pipeline_new_command_args ("pwd", (void *) 0);
pipecmd_chdir (pipeline_get_command (p, 0), temp_dir);
pipeline_want_out (p, -1);
pipeline_start (p);
......@@ -271,7 +271,7 @@ START_TEST (test_basic_fchdir)
char *line, *end;
char *child_base, *expected_base;
p = pipeline_new_command_args ("pwd", NULL);
p = pipeline_new_command_args ("pwd", (void *) 0);
temp_dir_fd = open (temp_dir, O_RDONLY | O_DIRECTORY);
fail_unless (temp_dir_fd >= 0);
pipecmd_fchdir (pipeline_get_command (p, 0), temp_dir_fd);
......@@ -309,7 +309,7 @@ START_TEST (test_basic_pre_exec)
{
pipeline *p;
p = pipeline_new_command_args (SHELL, "-c", "exit $TEST1", NULL);
p = pipeline_new_command_args (SHELL, "-c", "exit $TEST1", (void *) 0);
pipecmd_pre_exec (pipeline_get_command (p, 0), pre_exec, NULL, NULL);
fail_unless (pipeline_run (p) == 10, "TEST1 not set properly");
}
......@@ -322,12 +322,12 @@ START_TEST (test_basic_sequence)
const char *line;
p = pipeline_new ();
cmd1 = pipecmd_new_args ("echo", "foo", NULL);
cmd2 = pipecmd_new_args ("echo", "bar", NULL);
cmd3 = pipecmd_new_args ("echo", "baz", NULL);
seq = pipecmd_new_sequence ("echo*3", cmd1, cmd2, cmd3, NULL);
cmd1 = pipecmd_new_args ("echo", "foo", (void *) 0);
cmd2 = pipecmd_new_args ("echo", "bar", (void *) 0);
cmd3 = pipecmd_new_args ("echo", "baz", (void *) 0);
seq = pipecmd_new_sequence ("echo*3", cmd1, cmd2, cmd3, (void *) 0);
pipeline_command (p, seq);
pipeline_command_args (p, "xargs", NULL);
pipeline_command_args (p, "xargs", (void *) 0);
pipeline_want_out (p, -1);
pipeline_start (p);
line = pipeline_readline (p);
......
......@@ -42,7 +42,8 @@ void temp_dir_setup (void)
void temp_dir_teardown (void)
{
pipeline_run (pipeline_new_command_args ("rm", "-rf", temp_dir, NULL));
pipeline_run (pipeline_new_command_args ("rm", "-rf", temp_dir,
(void *) 0));
free (temp_dir);
temp_dir = NULL;
}
......@@ -48,7 +48,7 @@ START_TEST (test_exec_process)
if (i < 2) {
char *arg;
cmd = pipecmd_new_args (SHELL, "-c", NULL);
cmd = pipecmd_new_args (SHELL, "-c", (void *) 0);
arg = xasprintf ("exit %d", i);
pipecmd_arg (cmd, arg);
free (arg);
......
......@@ -47,7 +47,7 @@ START_TEST (test_inspect_command)
free (str);
pipecmd_free (cmd);
cmd = pipecmd_new_args ("foo", "bar", "baz quux", NULL);
cmd = pipecmd_new_args ("foo", "bar", "baz quux", (void *) 0);
str = pipecmd_tostring (cmd);
/* TODO: not ideal representation of commands with metacharacters */
fail_unless (!strcmp (str, "foo bar baz quux"));
......@@ -62,8 +62,8 @@ START_TEST (test_inspect_pipeline)
char *str;
p = pipeline_new ();
pipeline_command_args (p, "foo", "bar", NULL);
pipeline_command_args (p, "grep", "baz", "quux", NULL);
pipeline_command_args (p, "foo", "bar", (void *) 0);
pipeline_command_args (p, "grep", "baz", "quux", (void *) 0);
fail_unless (pipeline_get_ncommands (p) == 2);
pipecmd_setenv (pipeline_get_command (p, 1), "KEY", "value");
str = pipeline_tostring (p);
......
......@@ -40,7 +40,7 @@ const char *program_name = "pump";
static void fail_unless_files_equal (const char *left, const char *right)
{
pipeline *diff = pipeline_new_command_args
("diff", "-u", left, right, NULL);
("diff", "-u", left, right, (void *) 0);
int ret = pipeline_run (diff);
fail_unless (ret == 0);
}
......@@ -51,7 +51,7 @@ START_TEST (test_pump_connect_attaches_correctly)
pipeline *two = pipeline_new ();
pipeline *three = pipeline_new ();
pipeline_connect (one, two, three, NULL);
pipeline_connect (one, two, three, (void *) 0);
fail_unless (one->redirect_out == REDIRECT_FD);
fail_unless (one->want_out < 0);
fail_unless (one->want_outfile == NULL);
......@@ -91,15 +91,15 @@ START_TEST (test_pump_tee)
pipeline_command (source,
pipecmd_new_function ("source", tee_source,
NULL, NULL));
sink_process = pipeline_new_command_args ("cat", NULL);
sink_process = pipeline_new_command_args ("cat", (void *) 0);
process_outfile = xasprintf ("%s/process", temp_dir);
pipeline_want_outfile (sink_process, process_outfile);
sink_function = pipeline_new ();
pipeline_command (sink_function, pipecmd_new_passthrough ());
function_outfile = xasprintf ("%s/function", temp_dir);
pipeline_want_outfile (sink_function, function_outfile);
pipeline_connect (source, sink_process, sink_function, NULL);
pipeline_pump (source, sink_process, sink_function, NULL);
pipeline_connect (source, sink_process, sink_function, (void *) 0);
pipeline_pump (source, sink_process, sink_function, (void *) 0);
fail_unless (pipeline_wait (source) == 0, "source did not return 0");
fail_unless (pipeline_wait (sink_process) == 0,
"process sink did not return 0");
......
......@@ -53,7 +53,7 @@ START_TEST (test_redirect_files)
fprintf (fh, "test data\n");
fflush (fh);
p = pipeline_new_command_args ("sed", "-e", "s/$/ out/", NULL);
p = pipeline_new_command_args ("sed", "-e", "s/$/ out/", (void *) 0);
pipeline_want_infile (p, template);
pipeline_want_out (p, -1);
pipeline_start (p);
......@@ -76,7 +76,7 @@ START_TEST (test_redirect_outfile)
FILE *fh;
char line[5];
p = pipeline_new_command_args ("echo", "test", NULL);
p = pipeline_new_command_args ("echo", "test", (void *) 0);
outfile = xasprintf ("%s/test", temp_dir);
pipeline_want_outfile (p, outfile);
fail_unless (pipeline_run (p) == 0);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment