]> Savannah Git Hosting - gnulib.git/commitdiff
Fix some test failures on Android ≥ 11.
authorBruno Haible <bruno@clisp.org>
Tue, 10 Jan 2023 15:23:18 +0000 (16:23 +0100)
committerBruno Haible <bruno@clisp.org>
Tue, 10 Jan 2023 15:23:18 +0000 (16:23 +0100)
* 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.

ChangeLog
tests/test-fclose.c
tests/test-fdopen.c
tests/test-fflush.c
tests/test-fgetc.c
tests/test-fputc.c
tests/test-fread.c
tests/test-fseeko4.c
tests/test-ftello4.c
tests/test-fwrite.c

index f67f1755bc7daf51558a6ea5fd106970fef0bd5c..ab4a8f3a9fe5a16063093b7517ef96b291716b62 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+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.
index 5eda8fa672fde70c2c0486597912d2f341d7835f..5df500634e3f34fc1eefb2b53608217735d43873 100644 (file)
@@ -75,6 +75,7 @@ main (int argc, char **argv)
 
   /* 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);
@@ -83,6 +84,7 @@ main (int argc, char **argv)
     ASSERT (fclose (fp) == EOF);
     ASSERT (errno == EBADF);
   }
+  #endif
 
   /* Test that fclose() sets errno if the stream was constructed with
      an invalid file descriptor.  */
index 113bde0c8326ea921cbc625fd3710d70d5794a85..cf28f8e7e518c8a25ccb8b5896d72f1f32c86414 100644 (file)
@@ -33,9 +33,14 @@ main (void)
      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"))
index c996b18c2547d4b2baf600b98a2f552dff47438d..f43d9788eb90f560cf2a444f603a2d50d0f74962 100644 (file)
@@ -148,6 +148,7 @@ main (void)
 
   /* 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);
@@ -158,6 +159,7 @@ main (void)
     ASSERT (errno == EBADF);
     fclose (fp);
   }
+  #endif
 
   /* Test that fflush() sets errno if the stream was constructed with
      an invalid file descriptor.  */
index 59ab4098d45517a35f8f6017c5b3389398d247cb..c8c65f58aab4c2bfdec2c6d750f2dbd1e91296c5 100644 (file)
@@ -54,6 +54,7 @@ main (int argc, char **argv)
 
   /* 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);
@@ -64,6 +65,7 @@ main (int argc, char **argv)
     ASSERT (ferror (fp));
     fclose (fp);
   }
+  #endif
 
   /* Test that fgetc() sets errno if the stream was constructed with
      an invalid file descriptor.  */
index 2f0f1a33a9505249a370ddb26dcaf8c193a4db3c..3a9e7c38ac7ac0dddfbdc6446546ce1e6096d873 100644 (file)
@@ -45,6 +45,7 @@ main (int argc, char **argv)
 
   /* 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);
@@ -56,6 +57,7 @@ main (int argc, char **argv)
     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.  */
index 54e9d631ae6438339ccc94a214d92b9d1ee74dc8..d6d16ec3d91a01ef7a98395b8bf8a721fc94db63 100644 (file)
@@ -54,6 +54,7 @@ main (int argc, char **argv)
 
   /* 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];
@@ -65,6 +66,7 @@ main (int argc, char **argv)
     ASSERT (ferror (fp));
     fclose (fp);
   }
+  #endif
 
   /* Test that fread() sets errno if the stream was constructed with
      an invalid file descriptor.  */
index f509702b3eecb5e9aaf238c1fded458ae362cc90..ad90a2c99035af9c247952c09ede29502dc172b3 100644 (file)
@@ -33,6 +33,7 @@ main (int argc, char **argv)
   {
     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);
@@ -41,6 +42,7 @@ main (int argc, char **argv)
     errno = 0;
     ASSERT (fseeko (fp, 0, SEEK_SET) == -1);
     ASSERT (errno == EBADF);
+    #endif
     fclose (fp);
   }
 
index b1ff8268f65c6f4972b18725fe2752b417b25e99..590c17b67818074d30e110c1bd5b1f990d1cf773 100644 (file)
@@ -33,11 +33,13 @@ main (int argc, char **argv)
   {
     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);
   }
 
index 07f8b73e038b994e0c10ea394507356554eb2778..503e849b4778e01aa940d9d31dcb5bdb0a2f4faf 100644 (file)
@@ -45,6 +45,7 @@ main (int argc, char **argv)
 
   /* 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";
@@ -57,6 +58,7 @@ main (int argc, char **argv)
     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.  */