From 6fbdf424b43b229fd9ea639cfcf3f2f0f667cdde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Wed, 4 Oct 2017 15:17:09 +0200 Subject: [PATCH 1/2] test-copy: fix operation when test-copy is too small Fixes #6981. --- src/test/test-copy.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/test/test-copy.c b/src/test/test-copy.c index ed6725611d..187baa2d53 100644 --- a/src/test/test-copy.c +++ b/src/test/test-copy.c @@ -220,6 +220,14 @@ static void test_copy_bytes_regular_file(const char *src, bool try_reflink, uint else assert_se(IN_SET(r, 0, 1)); + assert_se(fstat(fd, &buf) == 0); + assert_se(fstat(fd2, &buf2) == 0); + assert_se((uint64_t) buf2.st_size == MIN((uint64_t) buf.st_size, max_bytes)); + + if (max_bytes < (uint64_t) -1) + /* Make sure the file is now higher than max_bytes */ + assert_se(ftruncate(fd2, max_bytes + 1) == 0); + assert_se(lseek(fd2, 0, SEEK_SET) == 0); r = copy_bytes(fd2, fd3, max_bytes, try_reflink ? COPY_REFLINK : 0); @@ -233,12 +241,12 @@ static void test_copy_bytes_regular_file(const char *src, bool try_reflink, uint * are copying is exactly max_bytes bytes. */ assert_se(r == 1); - assert_se(fstat(fd, &buf) == 0); - assert_se(fstat(fd2, &buf2) == 0); assert_se(fstat(fd3, &buf3) == 0); - assert_se((uint64_t) buf2.st_size == MIN((uint64_t) buf.st_size, max_bytes)); - assert_se(buf3.st_size == buf2.st_size); + if (max_bytes == (uint64_t) -1) + assert_se(buf3.st_size == buf2.st_size); + else + assert_se((uint64_t) buf3.st_size == max_bytes); unlink(fn2); unlink(fn3); From 98d9319960571ee7c7f0bed80ee276eb5ddbbbbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Wed, 4 Oct 2017 15:22:07 +0200 Subject: [PATCH 2/2] test-sizeof: add pid_t and gid_t C.f. #6975. --- src/test/test-sizeof.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/test/test-sizeof.c b/src/test/test-sizeof.c index 269adfd18f..bfc421e4ba 100644 --- a/src/test/test-sizeof.c +++ b/src/test/test-sizeof.c @@ -60,6 +60,8 @@ int main(void) { info(time_t); info(usec_t); info(__time_t); + info(pid_t); + info(gid_t); info(enum Enum); info(enum BigEnum);