summaryrefslogtreecommitdiff
path: root/tests/util/copy.c
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@github.com>2022-04-06 10:22:29 -0400
committerEdward Thomson <ethomson@github.com>2022-04-06 15:15:26 -0400
commite7fce1b5e5a2854a3464df9626f0383b08c70ca0 (patch)
tree15a317df4ed46030a869791ef795910010fd2963 /tests/util/copy.c
parent4e85b4fccc75696f2ecdd5b07429b574fc6e4650 (diff)
downloadlibgit2-e7fce1b5e5a2854a3464df9626f0383b08c70ca0.tar.gz
tests: support flaky stat
The 32-bit ARM QEMU builds are flaky when running `lstat`. Disable those testing `lstat`'s `st_size` temporarily.
Diffstat (limited to 'tests/util/copy.c')
-rw-r--r--tests/util/copy.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/tests/util/copy.c b/tests/util/copy.c
index 9b9f6bafc..2613730ba 100644
--- a/tests/util/copy.c
+++ b/tests/util/copy.c
@@ -4,7 +4,7 @@
void test_copy__file(void)
{
- struct stat st;
+ struct stat st = {0};
const char *content = "This is some stuff to copy\n";
cl_git_mkfile("copy_me", content);
@@ -13,7 +13,9 @@ void test_copy__file(void)
cl_git_pass(git_fs_path_lstat("copy_me_two", &st));
cl_assert(S_ISREG(st.st_mode));
- cl_assert(strlen(content) == (size_t)st.st_size);
+
+ if (!cl_is_env_set("GITTEST_FLAKY_STAT"))
+ cl_assert_equal_sz(strlen(content), (size_t)st.st_size);
cl_git_pass(p_unlink("copy_me_two"));
cl_git_pass(p_unlink("copy_me"));
@@ -21,7 +23,7 @@ void test_copy__file(void)
void test_copy__file_in_dir(void)
{
- struct stat st;
+ struct stat st = {0};
const char *content = "This is some other stuff to copy\n";
cl_git_pass(git_futils_mkdir("an_dir/in_a_dir", 0775, GIT_MKDIR_PATH));
@@ -38,7 +40,9 @@ void test_copy__file_in_dir(void)
cl_git_pass(git_fs_path_lstat("an_dir/second_dir/and_more/copy_me_two", &st));
cl_assert(S_ISREG(st.st_mode));
- cl_assert(strlen(content) == (size_t)st.st_size);
+
+ if (!cl_is_env_set("GITTEST_FLAKY_STAT"))
+ cl_assert_equal_sz(strlen(content), (size_t)st.st_size);
cl_git_pass(git_futils_rmdir_r("an_dir", NULL, GIT_RMDIR_REMOVE_FILES));
cl_assert(!git_fs_path_isdir("an_dir"));
@@ -97,11 +101,15 @@ void test_copy__tree(void)
cl_assert(git_fs_path_isfile("t1/c/d/f4"));
cl_assert(!git_fs_path_isfile("t1/c/d/.f5"));
+ memset(&st, 0, sizeof(struct stat));
cl_git_pass(git_fs_path_lstat("t1/c/f3", &st));
cl_assert(S_ISREG(st.st_mode));
- cl_assert(strlen(content) == (size_t)st.st_size);
+
+ if (!cl_is_env_set("GITTEST_FLAKY_STAT"))
+ cl_assert_equal_sz(strlen(content), (size_t)st.st_size);
#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));
#endif
@@ -127,6 +135,7 @@ void test_copy__tree(void)
cl_assert(git_fs_path_isfile("t2/c/d/.f5"));
#ifndef GIT_WIN32
+ memset(&st, 0, sizeof(struct stat));
cl_git_fail(git_fs_path_lstat("t2/c/d/l1", &st));
#endif