1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
|
From: =?utf-8?q?Timo_R=C3=B6hling?= <roehling@debian.org>
Date: Wed, 31 Aug 2022 15:24:06 +0200
Subject: Ignore test failures because of stat()
Forwarded: not-needed
---
tests/libgit2/repo/init.c | 14 ++++++++------
tests/libgit2/repo/template.c | 19 +++++++++++--------
tests/util/copy.c | 12 ++++++++----
tests/util/mkdir.c | 2 ++
4 files changed, 29 insertions(+), 18 deletions(-)
diff --git a/tests/libgit2/repo/init.c b/tests/libgit2/repo/init.c
index 446ab73..8cf7320 100644
--- a/tests/libgit2/repo/init.c
+++ b/tests/libgit2/repo/init.c
@@ -443,12 +443,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..1b74f0d 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);
@@ -111,7 +114,8 @@ void test_copy__tree(void)
#ifndef GIT_WIN32
memset(&st, 0, sizeof(struct stat));
cl_git_pass(git_fs_path_lstat("t1/c/d/l1", &st));
- cl_assert(S_ISLNK(st.st_mode));
+ if (!cl_is_env_set("GITTEST_FLAKY_STAT"))
+ cl_assert(S_ISLNK(st.st_mode));
#endif
cl_git_pass(git_futils_rmdir_r("t1", NULL, GIT_RMDIR_REMOVE_FILES));
diff --git a/tests/util/mkdir.c b/tests/util/mkdir.c
index 8658eec..1c944e7 100644
--- a/tests/util/mkdir.c
+++ b/tests/util/mkdir.c
@@ -160,6 +160,8 @@ static void check_mode_at_line(
expected &= 0600;
actual &= 0600;
}
+ if (cl_is_env_set("GITTEST_FLAKY_STAT"))
+ return;
clar__assert_equal(
file, func, line, "expected_mode != actual_mode", 1,
|