Update libglnx

Update libglnx, which is mostly port the repo stagedir code
to the new tmpdir API.  This turned out to require some
libglnx changes to support de-allocating the tmpdir ref while
still maintaining the on-disk dir.

Update submodule: libglnx

Closes: #1172
Approved by: jlebon
This commit is contained in:
Colin Walters authored and Atomic Bot committed 2017-09-18 17:09:34 +00:00
1 parent b39a61b493
commit d0b0578cc1
6 files changed
+62 -98

No files matched your search

+7 -13
View File
@@ -39,7 +39,7 @@
typedef struct
{
OstreeRepo *parent_repo; /* owned */
int working_dfd; /* owned */
GLnxTmpDir tmpdir; /* owned */
GFile *working_dir; /* owned */
} Fixture;
@@ -47,20 +47,17 @@ static void
setup (Fixture *fixture,
gconstpointer test_data)
{
g_autofree gchar *tmp_name = NULL;
g_autoptr(GError) error = NULL;
tmp_name = g_strdup ("test-repo-finder-config-XXXXXX");
glnx_mkdtempat_open_in_system (tmp_name, 0700, &fixture->working_dfd, &error);
(void)glnx_mkdtemp ("test-repo-finder-config-XXXXXX", 0700, &fixture->tmpdir, &error);
g_assert_no_error (error);
g_test_message ("Using temporary directory: %s", tmp_name);
g_test_message ("Using temporary directory: %s", fixture->tmpdir.path);
glnx_shutil_mkdir_p_at (fixture->working_dfd, "repo", 0700, NULL, &error);
glnx_shutil_mkdir_p_at (fixture->tmpdir.fd, "repo", 0700, NULL, &error);
g_assert_no_error (error);
g_autoptr(GFile) tmp_dir = g_file_new_for_path (g_get_tmp_dir ());
fixture->working_dir = g_file_get_child (tmp_dir, tmp_name);
fixture->working_dir = g_file_new_for_path (fixture->tmpdir.path);
fixture->parent_repo = ot_test_setup_repo (NULL, &error);
g_assert_no_error (error);
@@ -73,10 +70,7 @@ teardown (Fixture *fixture,
g_autoptr(GError) error = NULL;
/* Recursively remove the temporary directory. */
glnx_shutil_rm_rf_at (fixture->working_dfd, ".", NULL, NULL);
close (fixture->working_dfd);
fixture->working_dfd = -1;
(void)glnx_tmpdir_delete (&fixture->tmpdir, NULL, NULL);
/* The repo also needs its source files to be removed. This is the inverse
* of setup_test_repository() in libtest.sh. */
@@ -177,7 +171,7 @@ assert_create_remote (Fixture *fixture,
g_autoptr(GError) error = NULL;
const gchar *repo_name = (collection_id != NULL) ? collection_id : "no-collection";
glnx_shutil_mkdir_p_at (fixture->working_dfd, repo_name, 0700, NULL, &error);
glnx_shutil_mkdir_p_at (fixture->tmpdir.fd, repo_name, 0700, NULL, &error);
g_assert_no_error (error);
g_autoptr(GFile) repo_path = g_file_get_child (fixture->working_dir, repo_name);
+8 -14
View File
@@ -40,30 +40,27 @@
typedef struct
{
OstreeRepo *parent_repo;
int working_dfd; /* owned */
GFile *working_dir; /* owned */
GLnxTmpDir tmpdir; /* owned */
GFile *working_dir; /* Points at tmpdir */
} Fixture;
static void
setup (Fixture *fixture,
gconstpointer test_data)
{
g_autofree gchar *tmp_name = NULL;
g_autoptr(GError) error = NULL;
tmp_name = g_strdup ("test-repo-finder-mount-XXXXXX");
glnx_mkdtempat_open_in_system (tmp_name, 0700, &fixture->working_dfd, &error);
(void)glnx_mkdtemp ("test-repo-finder-mount-XXXXXX", 0700, &fixture->tmpdir, &error);
g_assert_no_error (error);
g_test_message ("Using temporary directory: %s", tmp_name);
g_test_message ("Using temporary directory: %s", fixture->tmpdir.path);
glnx_shutil_mkdir_p_at (fixture->working_dfd, "repo", 0700, NULL, &error);
glnx_shutil_mkdir_p_at (fixture->tmpdir.fd, "repo", 0700, NULL, &error);
if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_EXISTS))
g_clear_error (&error);
g_assert_no_error (error);
g_autoptr(GFile) tmp_dir = g_file_new_for_path (g_get_tmp_dir ());
fixture->working_dir = g_file_get_child (tmp_dir, tmp_name);
fixture->working_dir = g_file_new_for_path (fixture->tmpdir.path);
fixture->parent_repo = ot_test_setup_repo (NULL, &error);
g_assert_no_error (error);
@@ -76,10 +73,7 @@ teardown (Fixture *fixture,
g_autoptr(GError) error = NULL;
/* Recursively remove the temporary directory. */
glnx_shutil_rm_rf_at (fixture->working_dfd, ".", NULL, NULL);
close (fixture->working_dfd);
fixture->working_dfd = -1;
(void)glnx_tmpdir_delete (&fixture->tmpdir, NULL, NULL);
/* The repo also needs its source files to be removed. This is the inverse
* of setup_test_repository() in libtest.sh. */
@@ -167,7 +161,7 @@ assert_create_repos_dir (Fixture *fixture,
g_autoptr(GError) error = NULL;
g_autofree gchar *path = g_build_filename (mount_root_name, ".ostree", "repos", NULL);
glnx_shutil_mkdir_p_at_open (fixture->working_dfd, path, 0700, &repos_dfd, NULL, &error);
glnx_shutil_mkdir_p_at_open (fixture->tmpdir.fd, path, 0700, &repos_dfd, NULL, &error);
if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_EXISTS))
g_clear_error (&error);
g_assert_no_error (error);