summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Martín Nieto <cmn@dwim.me>2015-10-29 20:31:25 +0100
committerCarlos Martín Nieto <cmn@dwim.me>2015-10-30 19:49:34 +0100
commita2f96479abfe17357f666a80d9d0163dd8014fa1 (patch)
tree296ba2f4e2e63c1157ed880114463771774ffea6
parentd571a54e603c9bf46c7836124fded8c160b1eb5a (diff)
downloadlibgit2-a2f96479abfe17357f666a80d9d0163dd8014fa1.tar.gz
config: add failing test for an external modification
We currently use the timestamp in order to decide whether a config file has changed since we last read it. This scheme falls down if the file is written twice within the same second, as we fail to detect the file change after the first read in that second.
-rw-r--r--tests/config/stress.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/config/stress.c b/tests/config/stress.c
index 503f44f03..6e960425c 100644
--- a/tests/config/stress.c
+++ b/tests/config/stress.c
@@ -107,3 +107,23 @@ void test_config_stress__complex(void)
git_config_free(config);
}
+
+void test_config_stress__quick_write(void)
+{
+ git_config *config_w, *config_r;
+ const char *path = "./config-quick-write";
+ const char *key = "quick.write";
+ int32_t i;
+
+ /* Create an external writer for one instance with the other one */
+ cl_git_pass(git_config_open_ondisk(&config_w, path));
+ cl_git_pass(git_config_open_ondisk(&config_r, path));
+
+ /* Write and read in the same second (repeat to increase the chance of it happening) */
+ for (i = 0; i < 10; i++) {
+ int32_t val;
+ cl_git_pass(git_config_set_int32(config_w, key, i));
+ cl_git_pass(git_config_get_int32(&val, config_r, key));
+ cl_assert_equal_i(i, val);
+ }
+}