[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: execute: Add tests
From: |
Bruno Haible |
Subject: |
Re: execute: Add tests |
Date: |
Sat, 12 Dec 2020 03:59:28 +0100 |
User-agent: |
KMail/5.1.3 (Linux/4.4.0-193-generic; KDE/5.18.0; x86_64; ; ) |
> + struct stat st;
> + return
> +#if defined _WIN32 && ! defined __CYGWIN__
> + _fstat (fd, &st) >= 0
> +#else
> + fstat (fd, &st) >= 0
> +#endif
Oops, this doesn't work. On Windows, '_fstat' expects a 'struct _stat';
'struct stat' (on mingw) is a different type.
This patch fixes it.
2020-12-11 Bruno Haible <bruno@clisp.org>
execute-tests: Fix compilation error with MSVC.
* tests/test-execute-child.c (is_device): With _fstat, use
'struct _stat', not 'struct stat'.
diff --git a/tests/test-execute-child.c b/tests/test-execute-child.c
index 16ccff7..2310f77 100644
--- a/tests/test-execute-child.c
+++ b/tests/test-execute-child.c
@@ -29,14 +29,13 @@
static int
is_device (int fd)
{
- struct stat st;
- return
#if defined _WIN32 && ! defined __CYGWIN__
- _fstat (fd, &st) >= 0
+ struct _stat st;
+ return _fstat (fd, &st) >= 0 && !((st.st_mode & S_IFMT) == S_IFREG);
#else
- fstat (fd, &st) >= 0
+ struct stat st;
+ return fstat (fd, &st) >= 0 && !S_ISREG (st.st_mode);
#endif
- && !S_ISREG (st.st_mode);
}
/* Now include the other header files. */