2 * Copyright (C) 2010 Colin Watson.
4 * This file is part of libpipeline.
6 * libpipeline is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or (at
9 * your option) any later version.
11 * libpipeline is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with libpipeline; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
26 /* Include private definitions so that we can inspect arguments. */
27 #include "pipeline-private.h"
29 START_TEST (test_argstr_trivial)
33 cmd = pipecmd_new_argstr ("/bin/simple");
34 fail_unless (!strcmp (cmd->name, "/bin/simple"));
35 fail_unless (cmd->u.process.argc == 1);
36 fail_unless (!strcmp (cmd->u.process.argv[0], "simple"));
41 START_TEST (test_argstr_torture)
45 cmd = pipecmd_new_argstr
46 ("x' \\' \\$\\'\\\"\" \\'\\$\\\"\\\\ \" \\\"");
47 fail_unless (!strcmp (cmd->name, "x \\"));
48 fail_unless (cmd->u.process.argc == 3);
49 fail_unless (!strcmp (cmd->u.process.argv[0], "x \\"));
50 fail_unless (!strcmp (cmd->u.process.argv[1], "$'\" \\'$\"\\ "));
51 fail_unless (!strcmp (cmd->u.process.argv[2], "\""));
56 START_TEST (test_argstr_exec)
60 cmd = pipecmd_new_argstr ("exec /bin/foo bar");
61 fail_unless (!strcmp (cmd->name, "/bin/foo"));
62 fail_unless (cmd->u.process.argc == 2);
63 fail_unless (!strcmp (cmd->u.process.argv[0], "foo"));
64 fail_unless (!strcmp (cmd->u.process.argv[1], "bar"));
68 Suite *argstr_suite (void)
70 Suite *s = suite_create ("Argstr");
72 TEST_CASE (s, argstr, trivial);
73 TEST_CASE (s, argstr, torture);
74 TEST_CASE (s, argstr, exec);