gboolean
ot_test_run_libtest (const char *cmd, GError **error)
{
- gboolean ret = FALSE;
const char *srcdir = g_getenv ("G_TEST_SRCDIR");
- int estatus;
g_autoptr(GPtrArray) argv = g_ptr_array_new ();
g_autoptr(GString) cmdstr = g_string_new ("");
g_ptr_array_add (argv, cmdstr->str);
g_ptr_array_add (argv, NULL);
+ int estatus;
if (!g_spawn_sync (NULL, (char**)argv->pdata, NULL, G_SPAWN_SEARCH_PATH,
NULL, NULL, NULL, NULL, &estatus, error))
- goto out;
-
+ return FALSE;
if (!g_spawn_check_exit_status (estatus, error))
- goto out;
+ return FALSE;
- ret = TRUE;
- out:
- return ret;
+ return TRUE;
}
OstreeRepo *
ot_test_setup_repo (GCancellable *cancellable,
GError **error)
{
- gboolean ret = FALSE;
- g_autoptr(GFile) repo_path = g_file_new_for_path ("repo");
- glnx_unref_object OstreeRepo* ret_repo = NULL;
-
if (!ot_test_run_libtest ("setup_test_repository archive", error))
- goto out;
-
- ret_repo = ostree_repo_new (repo_path);
+ return NULL;
+ g_autoptr(GFile) repo_path = g_file_new_for_path ("repo");
+ g_autoptr(OstreeRepo) ret_repo = ostree_repo_new (repo_path);
if (!ostree_repo_open (ret_repo, cancellable, error))
- goto out;
+ return NULL;
- ret = TRUE;
- out:
- if (ret)
- return g_steal_pointer (&ret_repo);
- return NULL;
+ return g_steal_pointer (&ret_repo);
}
OstreeSysroot *
ot_test_setup_sysroot (GCancellable *cancellable,
GError **error)
{
- gboolean ret = FALSE;
- g_autoptr(GFile) sysroot_path = g_file_new_for_path ("sysroot");
- glnx_unref_object OstreeSysroot *ret_sysroot = NULL;
- struct statfs stbuf;
-
if (!ot_test_run_libtest ("setup_os_repository \"archive\" \"syslinux\"", error))
- goto out;
+ return FALSE;
+ struct statfs stbuf;
{ g_autoptr(GString) buf = g_string_new ("mutable-deployments");
if (statfs ("/", &stbuf) < 0)
return glnx_null_throw_errno (error);
g_setenv ("OSTREE_SYSROOT_DEBUG", buf->str, TRUE);
}
- ret_sysroot = ostree_sysroot_new (sysroot_path);
-
- ret = TRUE;
- out:
- if (ret)
- return g_steal_pointer (&ret_sysroot);
- return NULL;
+ g_autoptr(GFile) sysroot_path = g_file_new_for_path ("sysroot");
+ return ostree_sysroot_new (sysroot_path);
}
OstreeRepoCommitModifier *modifier,
GError **error)
{
- gboolean ret = FALSE;
- glnx_unref_object GFile *root = NULL;
- g_autofree char *commit_checksum = NULL;
- glnx_unref_object OstreeMutableTree *mtree = ostree_mutable_tree_new ();
+ g_autoptr(OstreeMutableTree) mtree = ostree_mutable_tree_new ();
if (!ostree_repo_prepare_transaction (repo, NULL, NULL, error))
- goto out;
+ return FALSE;
if (!ostree_repo_import_archive_to_mtree (repo, opts, a, mtree, modifier,
NULL, error))
- goto out;
+ return FALSE;
+ g_autoptr(GFile) root = NULL;
if (!ostree_repo_write_mtree (repo, mtree, &root, NULL, error))
- goto out;
+ return FALSE;
+ g_autofree char *commit_checksum = NULL;
if (!ostree_repo_write_commit (repo, NULL, "", "", NULL,
OSTREE_REPO_FILE (root),
&commit_checksum, NULL, error))
- goto out;
+ return FALSE;
ostree_repo_transaction_set_ref (repo, NULL, ref, commit_checksum);
if (!ostree_repo_commit_transaction (repo, NULL, NULL, error))
- goto out;
+ return FALSE;
- ret = TRUE;
-out:
- return ret;
+ return TRUE;
}
static void
GError *error = NULL;
g_autoptr(OtAutoArchiveRead) a = archive_read_new ();
OstreeRepoImportArchiveOptions opts = { 0 };
- OstreeRepoCommitModifier *modifier = NULL;
+ g_autoptr(OstreeRepoCommitModifier) modifier = NULL;
char buf[7] = { 0 };
if (skip_if_no_xattr (td))
g_assert_cmpstr (buf, ==, "mydata");
out:
- if (modifier)
- ostree_repo_commit_modifier_unref (modifier);
g_assert_no_error (error);
}
g_autoptr(OtAutoArchiveRead) a = archive_read_new ();
OstreeRepoImportArchiveOptions opts = { 0 };
glnx_unref_object OstreeSePolicy *sepol = NULL;
- OstreeRepoCommitModifier *modifier = NULL;
+ g_autoptr(OstreeRepoCommitModifier) modifier = NULL;
char buf[64] = { 0 };
if (skip_if_no_xattr (td))
g_assert_cmpstr (buf, ==, "system_u:object_r:etc_t:s0");
out:
- if (modifier)
- ostree_repo_commit_modifier_unref (modifier);
g_assert_no_error (error);
}