summaryrefslogtreecommitdiff
path: root/tests/pack
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@github.com>2016-12-14 12:51:40 -0500
committerEdward Thomson <ethomson@github.com>2017-02-28 13:27:50 +0000
commit1c2c0ae2a4d09f5b0de3c4c091c5a93ab34baa46 (patch)
tree436f1573473606ef78b9f6f24f5548fd0c055171 /tests/pack
parente6ed0d2f03625f5d6b60db54fc894902d7ddbc32 (diff)
downloadlibgit2-1c2c0ae2a4d09f5b0de3c4c091c5a93ab34baa46.tar.gz
packbuilder: honor git_object__synchronized_writing
Honor `git_object__synchronized_writing` when creating a packfile and corresponding index.
Diffstat (limited to 'tests/pack')
-rw-r--r--tests/pack/packbuilder.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/pack/packbuilder.c b/tests/pack/packbuilder.c
index 29f3e2d64..9afc178b3 100644
--- a/tests/pack/packbuilder.c
+++ b/tests/pack/packbuilder.c
@@ -23,6 +23,7 @@ void test_pack_packbuilder__initialize(void)
cl_git_pass(git_vector_init(&_commits, 0, NULL));
_commits_is_initialized = 1;
memset(&_stats, 0, sizeof(_stats));
+ p_fsync__cnt = 0;
}
void test_pack_packbuilder__cleanup(void)
@@ -30,6 +31,8 @@ void test_pack_packbuilder__cleanup(void)
git_oid *o;
unsigned int i;
+ cl_git_pass(git_libgit2_opts(GIT_OPT_ENABLE_SYNCHRONIZED_OBJECT_CREATION, 0));
+
if (_commits_is_initialized) {
_commits_is_initialized = 0;
git_vector_foreach(&_commits, i, o) {
@@ -188,6 +191,22 @@ void test_pack_packbuilder__permissions_readwrite(void)
test_write_pack_permission(0666, 0666);
}
+void test_pack_packbuilder__does_not_fsync_by_default(void)
+{
+ seed_packbuilder();
+ git_packbuilder_write(_packbuilder, ".", 0666, NULL, NULL);
+ cl_assert_equal_sz(0, p_fsync__cnt);
+}
+
+void test_pack_packbuilder__fsync_when_asked(void)
+{
+ cl_git_pass(git_libgit2_opts(GIT_OPT_ENABLE_SYNCHRONIZED_OBJECT_CREATION, 1));
+ p_fsync__cnt = 0;
+ seed_packbuilder();
+ git_packbuilder_write(_packbuilder, ".", 0666, NULL, NULL);
+ cl_assert_equal_sz(2, p_fsync__cnt);
+}
+
static int foreach_cb(void *buf, size_t len, void *payload)
{
git_indexer *idx = (git_indexer *) payload;