mirror of
https://git.proxmox.com/git/libgit2
synced 2025-08-07 19:03:19 +00:00
Tests: close file handles before asserting
Avoids getting ERROR_SHARING_VIOLATION on win32 and killing the entire clar run.
This commit is contained in:
parent
5c27da1f48
commit
c35881420d
@ -24,13 +24,17 @@ static void test_file_contents(const char *path, const char *expectedcontents)
|
|||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
char buffer[1024] = {0};
|
char buffer[1024] = {0};
|
||||||
|
size_t expectedlen, actuallen;
|
||||||
|
|
||||||
fd = p_open(path, O_RDONLY);
|
fd = p_open(path, O_RDONLY);
|
||||||
cl_assert(fd >= 0);
|
cl_assert(fd >= 0);
|
||||||
|
|
||||||
cl_assert_equal_i(p_read(fd, buffer, 1024), strlen(expectedcontents));
|
expectedlen = strlen(expectedcontents);
|
||||||
cl_assert_equal_s(expectedcontents, buffer);
|
actuallen = p_read(fd, buffer, 1024);
|
||||||
cl_git_pass(p_close(fd));
|
cl_git_pass(p_close(fd));
|
||||||
|
|
||||||
|
cl_assert_equal_i(actuallen, expectedlen);
|
||||||
|
cl_assert_equal_s(buffer, expectedcontents);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user