diff options
author | Edward Thomson <ethomson@github.com> | 2017-02-28 12:29:29 +0000 |
---|---|---|
committer | Edward Thomson <ethomson@github.com> | 2017-03-02 09:11:33 +0000 |
commit | 1c04a96b25da048221f31ecee0227d960dc00489 (patch) | |
tree | 14774879d60dec45b5610cb7ed1bae927ef2016f /tests/pack/packbuilder.c | |
parent | 3ac05d11493d0573dbf725a19403dbf5e8d93b50 (diff) | |
download | libgit2-ethomson/fsync.tar.gz |
Honor `core.fsyncObjectFiles`ethomson/fsync
Diffstat (limited to 'tests/pack/packbuilder.c')
-rw-r--r-- | tests/pack/packbuilder.c | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/tests/pack/packbuilder.c b/tests/pack/packbuilder.c index 5cdd9a8d2..1d7becef7 100644 --- a/tests/pack/packbuilder.c +++ b/tests/pack/packbuilder.c @@ -198,22 +198,31 @@ void test_pack_packbuilder__does_not_fsync_by_default(void) cl_assert_equal_sz(0, p_fsync__cnt); } -void test_pack_packbuilder__fsync_when_asked(void) -{ - /* We fsync the packfile and index. On non-Windows, we also fsync - * the parent directories. - */ +/* We fsync the packfile and index. On non-Windows, we also fsync + * the parent directories. + */ #ifdef GIT_WIN32 - int expected = 2; +static int expected_fsyncs = 2; #else - int expected = 4; +static int expected_fsyncs = 4; #endif +void test_pack_packbuilder__fsync_global_setting(void) +{ cl_git_pass(git_libgit2_opts(GIT_OPT_ENABLE_SYNCHRONOUS_OBJECT_CREATION, 1)); p_fsync__cnt = 0; seed_packbuilder(); git_packbuilder_write(_packbuilder, ".", 0666, NULL, NULL); - cl_assert_equal_sz(expected, p_fsync__cnt); + cl_assert_equal_sz(expected_fsyncs, p_fsync__cnt); +} + +void test_pack_packbuilder__fsync_repo_setting(void) +{ + cl_repo_set_bool(_repo, "core.fsyncObjectFiles", true); + p_fsync__cnt = 0; + seed_packbuilder(); + git_packbuilder_write(_packbuilder, ".", 0666, NULL, NULL); + cl_assert_equal_sz(expected_fsyncs, p_fsync__cnt); } static int foreach_cb(void *buf, size_t len, void *payload) |