+2023-01-10 Bruno Haible <bruno@clisp.org>
+
+ Fix some test failures on Android ≥ 11.
+ * tests/test-fclose.c (main): On Android, avoid triggering the
+ file-descriptor sanitizer (fdsan).
+ * tests/test-fdopen.c (main): Likewise.
+ * tests/test-fflush.c (main): Likewise.
+ * tests/test-fgetc.c (main): Likewise.
+ * tests/test-fputc.c (main): Likewise.
+ * tests/test-fread.c (main): Likewise.
+ * tests/test-fseeko4.c (main): Likewise.
+ * tests/test-ftello4.c (main): Likewise.
+ * tests/test-fwrite.c (main): Likewise.
+
2023-01-10 Bruno Haible <bruno@clisp.org>
utimens: Fix warning on Android.
/* Test that fclose() sets errno if someone else closes the stream
fd behind the back of stdio. */
+ #if !defined __ANDROID__ /* fdsan */
{
FILE *fp = fdopen (fd, "w+");
ASSERT (fp != NULL);
ASSERT (fclose (fp) == EOF);
ASSERT (errno == EBADF);
}
+ #endif
/* Test that fclose() sets errno if the stream was constructed with
an invalid file descriptor. */
failure, since the behavior is not well-defined on invalid file
descriptors, so try fdopen 1000 times and if that's not enough to
fail due to EMFILE, so be it. */
+ #if defined __ANDROID__ /* fdsan */
+ #define COUNT 1
+ #else
+ #define COUNT 1000
+ #endif
int i;
- for (i = 0; i < 1000; i++)
+ for (i = 0; i < COUNT; i++)
{
errno = 0;
if (! fdopen (STDOUT_FILENO, "w"))
/* Test that fflush() sets errno if someone else closes the stream
fd behind the back of stdio. */
+ #if !defined __ANDROID__ /* fdsan */
{
FILE *fp = fopen ("test-fflush.txt", "w");
ASSERT (fp != NULL);
ASSERT (errno == EBADF);
fclose (fp);
}
+ #endif
/* Test that fflush() sets errno if the stream was constructed with
an invalid file descriptor. */
/* Test that fgetc() sets errno if someone else closes the stream
fd behind the back of stdio. */
+ #if !defined __ANDROID__ /* fdsan */
{
FILE *fp = fopen (filename, "r");
ASSERT (fp != NULL);
ASSERT (ferror (fp));
fclose (fp);
}
+ #endif
/* Test that fgetc() sets errno if the stream was constructed with
an invalid file descriptor. */
/* Test that fputc() on an unbuffered stream sets errno if someone else
closes the stream fd behind the back of stdio. */
+ #if !defined __ANDROID__ /* fdsan */
{
FILE *fp = fopen (filename, "w");
ASSERT (fp != NULL);
ASSERT (ferror (fp));
fclose (fp);
}
+ #endif
/* Test that fputc() on an unbuffered stream sets errno if the stream
was constructed with an invalid file descriptor. */
/* Test that fread() sets errno if someone else closes the stream
fd behind the back of stdio. */
+ #if !defined __ANDROID__ /* fdsan */
{
FILE *fp = fopen (filename, "r");
char buf[5];
ASSERT (ferror (fp));
fclose (fp);
}
+ #endif
/* Test that fread() sets errno if the stream was constructed with
an invalid file descriptor. */
{
FILE *fp = fopen (filename, "r");
ASSERT (fp != NULL);
+ #if !defined __ANDROID__ /* fdsan */
setvbuf (fp, NULL, _IONBF, 0);
ASSERT (ftell (fp) == 0);
ASSERT (fseeko (fp, 0, SEEK_END) == 0);
errno = 0;
ASSERT (fseeko (fp, 0, SEEK_SET) == -1);
ASSERT (errno == EBADF);
+ #endif
fclose (fp);
}
{
FILE *fp = fopen (filename, "r");
ASSERT (fp != NULL);
+ #if !defined __ANDROID__ /* fdsan */
setvbuf (fp, NULL, _IONBF, 0);
ASSERT (close (fileno (fp)) == 0);
errno = 0;
ASSERT (ftello (fp) == (off_t)-1);
ASSERT (errno == EBADF);
+ #endif
fclose (fp);
}
/* Test that fwrite() on an unbuffered stream sets errno if someone else
closes the stream fd behind the back of stdio. */
+ #if !defined __ANDROID__ /* fdsan */
{
FILE *fp = fopen (filename, "w");
char buf[5] = "world";
ASSERT (ferror (fp));
fclose (fp);
}
+ #endif
/* Test that fwrite() on an unbuffered stream sets errno if the stream
was constructed with an invalid file descriptor. */