Skip to content
Snippets Groups Projects
Commit 5d674ce1 authored by Ludovico de Nittis's avatar Ludovico de Nittis
Browse files

Test that --generate-locales is in the bwrap arguments when expected

parent c81e6824
No related branches found
No related tags found
No related merge requests found
......@@ -375,6 +375,7 @@ static gboolean opt_version = FALSE;
static gboolean opt_version_only = FALSE;
static gboolean opt_test = FALSE;
static PvTerminal opt_terminal = PV_TERMINAL_AUTO;
static char *opt_write_bwrap = NULL;
static gboolean
opt_host_ld_preload_cb (const gchar *option_name,
......@@ -680,6 +681,10 @@ static GOptionEntry options[] =
"If using --runtime, don't use the host graphics stack. "
"This is likely to result in software rendering or a crash.",
NULL },
{ "write-bwrap-arguments", '\0',
G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_FILENAME, &opt_write_bwrap,
"Write the final bwrap arguments, as null terminated strings, to the "
"given file path.", "PATH" },
{ "test", '\0',
G_OPTION_FLAG_NONE, G_OPTION_ARG_NONE, &opt_test,
"Smoke test pressure-vessel-wrap and exit.", NULL },
......@@ -1403,6 +1408,24 @@ main (int argc,
flatpak_bwrap_finish (bwrap);
if (opt_write_bwrap != NULL)
{
FILE *file = fopen (opt_write_bwrap, "w");
if (file == NULL)
{
g_warning ("An error occurred trying to write the bwrap arguments: %s",
g_strerror (errno));
/* This is not a fatal error, try to continue */
}
else
{
for (i = 0; i < bwrap->argv->len; i++)
fprintf (file, "%s%c", (gchar *)g_ptr_array_index (bwrap->argv, i), '\0');
fclose (file);
}
}
if (opt_only_prepare)
ret = 0;
else
......
......@@ -424,10 +424,13 @@ class TestContainers(BaseTest):
)
os.makedirs(artifacts, exist_ok=True)
bwrap_temp_file = tempfile.NamedTemporaryFile()
argv = [
self.pv_wrap,
'--runtime', runtime,
'--verbose',
'--write-bwrap-arguments', bwrap_temp_file.name
]
var = os.path.join(self.containers_dir, 'var')
......@@ -511,6 +514,14 @@ class TestContainers(BaseTest):
)
self.assertEqual(completed.returncode, 0)
bwrap_arguments = bwrap_temp_file.read().decode().split("\0")
if locales:
self.assertIn("--generate-locales", bwrap_arguments)
else:
self.assertNotIn("--generate-locales", bwrap_arguments)
bwrap_temp_file.close()
if copy:
members = set(os.listdir(temp))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment