summaryrefslogtreecommitdiff
path: root/tests/test-repo.c
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2021-04-14 20:43:53 -0400
committerDan Nicholson <dbn@endlessos.org>2021-06-05 09:00:21 -0600
commit0f36d8c2219decbb5794ff19b5259d15d3d8d791 (patch)
treeabc76349274ce0ca70a26964427bcbd56fa3e57f /tests/test-repo.c
parenta7b590f7aec9fa8e07c92bfcc306cf695544c94e (diff)
downloadostree-0f36d8c2219decbb5794ff19b5259d15d3d8d791.tar.gz
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
Diffstat (limited to 'tests/test-repo.c')
-rw-r--r--tests/test-repo.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/test-repo.c b/tests/test-repo.c
index 9337ac3b..b388f5bf 100644
--- a/tests/test-repo.c
+++ b/tests/test-repo.c
@@ -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 ();
}