Guard more lstat() asserts with GITTEST_FLAKY_STAT

This commit is contained in:
Timo Röhling 2022-08-31 13:35:41 +02:00
parent c1cb74662d
commit 4ad282f2ad
3 changed files with 147 additions and 1 deletions

View File

@ -0,0 +1,136 @@
From: =?utf-8?q?Timo_R=C3=B6hling?= <roehling@debian.org>
Date: Wed, 31 Aug 2022 13:35:12 +0200
Subject: Ignore test failures because of stat()
---
tests/libgit2/repo/init.c | 14 ++++++++------
tests/libgit2/repo/template.c | 19 +++++++++++--------
tests/util/copy.c | 9 ++++++---
tests/util/mkdir.c | 9 ++++++---
4 files changed, 31 insertions(+), 20 deletions(-)
diff --git a/tests/libgit2/repo/init.c b/tests/libgit2/repo/init.c
index 7cf6742..aec1ec6 100644
--- a/tests/libgit2/repo/init.c
+++ b/tests/libgit2/repo/init.c
@@ -424,12 +424,14 @@ void test_repo_init__extended_1(void)
cl_assert(!git_repository_is_empty(g_repo));
cl_git_pass(git_fs_path_lstat(git_repository_path(g_repo), &st));
- cl_assert(S_ISDIR(st.st_mode));
- if (cl_is_chmod_supported())
- cl_assert((S_ISGID & st.st_mode) == S_ISGID);
- else
- cl_assert((S_ISGID & st.st_mode) == 0);
-
+ if (!cl_is_env_set("GITTEST_FLAKY_STAT"))
+ {
+ cl_assert(S_ISDIR(st.st_mode));
+ if (cl_is_chmod_supported())
+ cl_assert((S_ISGID & st.st_mode) == S_ISGID);
+ else
+ cl_assert((S_ISGID & st.st_mode) == 0);
+ }
cl_git_pass(git_reference_lookup(&ref, g_repo, "HEAD"));
cl_assert(git_reference_type(ref) == GIT_REFERENCE_SYMBOLIC);
cl_assert_equal_s("refs/heads/development", git_reference_symbolic_target(ref));
diff --git a/tests/libgit2/repo/template.c b/tests/libgit2/repo/template.c
index e8fe266..f771f4e 100644
--- a/tests/libgit2/repo/template.c
+++ b/tests/libgit2/repo/template.c
@@ -72,8 +72,8 @@ static void assert_hooks_match(
CLEAR_FOR_CORE_FILEMODE(expected_mode);
CLEAR_FOR_CORE_FILEMODE(st.st_mode);
}
-
- cl_assert_equal_i_fmt(expected_mode, st.st_mode, "%07o");
+ if (!cl_is_env_set("GITTEST_FLAKY_STAT"))
+ cl_assert_equal_i_fmt(expected_mode, st.st_mode, "%07o");
}
git_str_dispose(&expected);
@@ -97,14 +97,17 @@ static void assert_mode_seems_okay(
expect_setgid = false;
}
- if (S_ISGID != 0)
- cl_assert_equal_b(expect_setgid, (st.st_mode & S_ISGID) != 0);
+ if (!cl_is_env_set("GITTEST_FLAKY_STAT"))
+ {
+ if (S_ISGID != 0)
+ cl_assert_equal_b(expect_setgid, (st.st_mode & S_ISGID) != 0);
- cl_assert_equal_b(
- GIT_PERMS_IS_EXEC(expect_mode), GIT_PERMS_IS_EXEC(st.st_mode));
+ cl_assert_equal_b(
+ GIT_PERMS_IS_EXEC(expect_mode), GIT_PERMS_IS_EXEC(st.st_mode));
- cl_assert_equal_i_fmt(
- GIT_MODE_TYPE(expect_mode), GIT_MODE_TYPE(st.st_mode), "%07o");
+ cl_assert_equal_i_fmt(
+ GIT_MODE_TYPE(expect_mode), GIT_MODE_TYPE(st.st_mode), "%07o");
+ }
}
static void setup_repo(const char *name, git_repository_init_options *opts)
diff --git a/tests/util/copy.c b/tests/util/copy.c
index 2613730..b908634 100644
--- a/tests/util/copy.c
+++ b/tests/util/copy.c
@@ -12,7 +12,8 @@ void test_copy__file(void)
cl_git_pass(git_futils_cp("copy_me", "copy_me_two", 0664));
cl_git_pass(git_fs_path_lstat("copy_me_two", &st));
- cl_assert(S_ISREG(st.st_mode));
+ if (!cl_is_env_set("GITTEST_FLAKY_STAT"))
+ cl_assert(S_ISREG(st.st_mode));
if (!cl_is_env_set("GITTEST_FLAKY_STAT"))
cl_assert_equal_sz(strlen(content), (size_t)st.st_size);
@@ -39,7 +40,8 @@ void test_copy__file_in_dir(void)
0664));
cl_git_pass(git_fs_path_lstat("an_dir/second_dir/and_more/copy_me_two", &st));
- cl_assert(S_ISREG(st.st_mode));
+ if (!cl_is_env_set("GITTEST_FLAKY_STAT"))
+ cl_assert(S_ISREG(st.st_mode));
if (!cl_is_env_set("GITTEST_FLAKY_STAT"))
cl_assert_equal_sz(strlen(content), (size_t)st.st_size);
@@ -103,7 +105,8 @@ void test_copy__tree(void)
memset(&st, 0, sizeof(struct stat));
cl_git_pass(git_fs_path_lstat("t1/c/f3", &st));
- cl_assert(S_ISREG(st.st_mode));
+ if (!cl_is_env_set("GITTEST_FLAKY_STAT"))
+ cl_assert(S_ISREG(st.st_mode));
if (!cl_is_env_set("GITTEST_FLAKY_STAT"))
cl_assert_equal_sz(strlen(content), (size_t)st.st_size);
diff --git a/tests/util/mkdir.c b/tests/util/mkdir.c
index 8658eec..61dd084 100644
--- a/tests/util/mkdir.c
+++ b/tests/util/mkdir.c
@@ -276,16 +276,19 @@ void test_mkdir__mkdir_path_inside_unwriteable_parent(void)
cl_git_pass(git_futils_mkdir("r", 0777, 0));
cl_git_pass(git_futils_mkdir_relative("mode/is/important", "r", 0777, GIT_MKDIR_PATH, NULL));
cl_git_pass(git_fs_path_lstat("r/mode", &st));
- check_mode(0755, st.st_mode);
+ if (!cl_is_env_set("GITTEST_FLAKY_STAT"))
+ check_mode(0755, st.st_mode);
cl_must_pass(p_chmod("r/mode", 0111));
cl_git_pass(git_fs_path_lstat("r/mode", &st));
- check_mode(0111, st.st_mode);
+ if (!cl_is_env_set("GITTEST_FLAKY_STAT"))
+ check_mode(0111, st.st_mode);
cl_git_pass(
git_futils_mkdir_relative("mode/is/okay/inside", "r", 0777, GIT_MKDIR_PATH, NULL));
cl_git_pass(git_fs_path_lstat("r/mode/is/okay/inside", &st));
- check_mode(0755, st.st_mode);
+ if (!cl_is_env_set("GITTEST_FLAKY_STAT"))
+ check_mode(0755, st.st_mode);
cl_must_pass(p_chmod("r/mode", 0777));
}

View File

@ -1,5 +1,14 @@
Skip tests that needs an active internet connection From: Utkarsh Gupta <utkarsh@debian.org>
Date: Sun, 28 Aug 2022 17:12:49 +0200
Subject: disable-online-tests
Skip tests that needs an active internet connection
---
tests/libgit2/CMakeLists.txt | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/tests/libgit2/CMakeLists.txt b/tests/libgit2/CMakeLists.txt
index 27f421a..213076f 100644
--- a/tests/libgit2/CMakeLists.txt --- a/tests/libgit2/CMakeLists.txt
+++ b/tests/libgit2/CMakeLists.txt +++ b/tests/libgit2/CMakeLists.txt
@@ -66,10 +66,12 @@ endif() @@ -66,10 +66,12 @@ endif()

View File

@ -1,3 +1,4 @@
disable-online-tests.patch disable-online-tests.patch
fix-unit-tests.patch fix-unit-tests.patch
handle-bashism.patch handle-bashism.patch
disable-flaky-stat-tests.patch