repo: Make locking APIs public
Doing anything even somewhat sophisticated requires this; turns out our own `ostree prune` CLI wants this, e.g. https://github.com/ostreedev/ostree/issues/2337 Closes: https://github.com/ostreedev/ostree/issues/2286
This commit is contained in:
1 parent
a7b590f7ae
commit
0f36d8c221
12 files changed
+139
-60
No files matched your search
@@ -134,4 +134,12 @@ w.write(inline_content.slice(10), null)
|
||||
let actual_checksum = w.finish(null)
|
||||
assertEquals(actual_checksum, networks_checksum)
|
||||
|
||||
// Basic locking API sanity test
|
||||
repo.lock_push(OSTree.RepoLockType.SHARED, null);
|
||||
repo.lock_push(OSTree.RepoLockType.SHARED, null);
|
||||
repo.lock_pop(null);
|
||||
repo.lock_pop(null);
|
||||
repo.lock_push(OSTree.RepoLockType.EXCLUSIVE, null);
|
||||
repo.lock_pop(null);
|
||||
|
||||
print("ok test-core");
|
||||
@@ -249,6 +249,30 @@ test_write_regfile_api (Fixture *fixture,
|
||||
g_assert_cmpstr (checksum, ==, "23a2e97d21d960ac7a4e39a8721b1baff7b213e00e5e5641334f50506012fcff");
|
||||
}
|
||||
|
||||
/* Just a sanity check of the C autolocking API */
|
||||
static void
|
||||
test_repo_autolock (Fixture *fixture,
|
||||
gconstpointer test_data)
|
||||
{
|
||||
g_autoptr(GError) error = NULL;
|
||||
g_autoptr(OstreeRepo) repo = ostree_repo_create_at (fixture->tmpdir.fd, ".",
|
||||
OSTREE_REPO_MODE_ARCHIVE,
|
||||
NULL,
|
||||
NULL, &error);
|
||||
g_assert_no_error (error);
|
||||
|
||||
{
|
||||
g_autoptr(OstreeRepoAutoLock) lock = ostree_repo_auto_lock_push (repo, OSTREE_REPO_LOCK_EXCLUSIVE, NULL, &error);
|
||||
g_assert_no_error (error);
|
||||
}
|
||||
|
||||
g_autoptr(OstreeRepoAutoLock) lock1 = ostree_repo_auto_lock_push (repo, OSTREE_REPO_LOCK_SHARED, NULL, &error);
|
||||
g_assert_no_error (error);
|
||||
|
||||
g_autoptr(OstreeRepoAutoLock) lock2 = ostree_repo_auto_lock_push (repo, OSTREE_REPO_LOCK_SHARED, NULL, &error);
|
||||
g_assert_no_error (error);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc,
|
||||
char **argv)
|
||||
@@ -266,6 +290,8 @@ main (int argc,
|
||||
test_repo_get_min_free_space, teardown);
|
||||
g_test_add ("/repo/write_regfile_api", Fixture, NULL, setup,
|
||||
test_write_regfile_api, teardown);
|
||||
g_test_add ("/repo/autolock", Fixture, NULL, setup,
|
||||
test_repo_autolock, teardown);
|
||||
|
||||
return g_test_run ();
|
||||
}
|
||||
Reference in new issue
Block a user