Skip to content
Snippets Groups Projects
Commit fc9dcead authored by Jeremy Whiting's avatar Jeremy Whiting
Browse files

Add --test command line argument to pressure-vessel-wrap.

When --test is used check for bubble wrap executable and return
0 if found, 1 otherwise.
parent 39a6a026
Branches
Tags
No related merge requests found
...@@ -1650,6 +1650,7 @@ static char *opt_runtime = NULL; ...@@ -1650,6 +1650,7 @@ static char *opt_runtime = NULL;
static Tristate opt_share_home = TRISTATE_MAYBE; static Tristate opt_share_home = TRISTATE_MAYBE;
static gboolean opt_verbose = FALSE; static gboolean opt_verbose = FALSE;
static gboolean opt_version = FALSE; static gboolean opt_version = FALSE;
static gboolean opt_test = FALSE;
static PvTerminal opt_terminal = PV_TERMINAL_AUTO; static PvTerminal opt_terminal = PV_TERMINAL_AUTO;
static gboolean static gboolean
...@@ -1899,6 +1900,9 @@ static GOptionEntry options[] = ...@@ -1899,6 +1900,9 @@ static GOptionEntry options[] =
{ "version", '\0', { "version", '\0',
G_OPTION_FLAG_NONE, G_OPTION_ARG_NONE, &opt_version, G_OPTION_FLAG_NONE, G_OPTION_ARG_NONE, &opt_version,
"Print version number and exit.", NULL }, "Print version number and exit.", NULL },
{ "test", '\0',
G_OPTION_FLAG_NONE, G_OPTION_ARG_NONE, &opt_test,
"Smoke test pressure-vessel-wrap and exit.", NULL },
{ NULL } { NULL }
}; };
...@@ -2057,7 +2061,7 @@ main (int argc, ...@@ -2057,7 +2061,7 @@ main (int argc,
goto out; goto out;
} }
if (argc < 2) if (argc < 2 && !opt_test)
{ {
g_printerr ("%s: An executable to run is required\n", g_printerr ("%s: An executable to run is required\n",
g_get_prgname ()); g_get_prgname ());
...@@ -2079,7 +2083,7 @@ main (int argc, ...@@ -2079,7 +2083,7 @@ main (int argc,
goto out; goto out;
} }
if (strcmp (argv[1], "--") == 0) if (argc > 1 && strcmp (argv[1], "--") == 0)
{ {
argv++; argv++;
argc--; argc--;
...@@ -2242,7 +2246,7 @@ main (int argc, ...@@ -2242,7 +2246,7 @@ main (int argc,
pv_bwrap_wrap_interactive (wrapped_command, opt_shell); pv_bwrap_wrap_interactive (wrapped_command, opt_shell);
} }
if (argv[1][0] == '-') if (argc > 1 && argv[1][0] == '-')
{ {
/* Make sure wrapped_command is something we can validly pass to env(1) */ /* Make sure wrapped_command is something we can validly pass to env(1) */
if (strchr (argv[1], '=') != NULL) if (strchr (argv[1], '=') != NULL)
...@@ -2261,6 +2265,20 @@ main (int argc, ...@@ -2261,6 +2265,20 @@ main (int argc,
g_debug ("Checking for bwrap..."); g_debug ("Checking for bwrap...");
bwrap_executable = check_bwrap (tools_dir); bwrap_executable = check_bwrap (tools_dir);
if (opt_test)
{
if (bwrap_executable == NULL)
{
ret = 1;
goto out;
}
else
{
ret = 0;
goto out;
}
}
if (bwrap_executable == NULL) if (bwrap_executable == NULL)
{ {
if (opt_host_fallback) if (opt_host_fallback)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment