bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

supersede: Fix test failure under QEMU user-mode for Linux/mips


From: Bruno Haible
Subject: supersede: Fix test failure under QEMU user-mode for Linux/mips
Date: Mon, 30 Aug 2021 02:39:33 +0200

On Linux/mips, the 'supersede' test fails here:

              ASSERT (memcmp (&orig_dev, &statbuf.st_dev, sizeof (dev_t)) == 0);

The reason is that
  sizeof (orig_dev)       = 8
  sizeof (statbuf.st_dev) = 4
  sizeof (dev_t)          = 8

This patch works around it.


2021-08-29  Bruno Haible  <bruno@clisp.org>

        supersede: Fix test failure under QEMU user-mode for Linux/mips.
        * tests/test-supersede-open.h (test_open_supersede): Copy statbuf.st_dev
        into a local variable of type dev_t.
        * tests/test-supersede-fopen.h (test_fopen_supersede): Likewise.

diff --git a/tests/test-supersede-fopen.h b/tests/test-supersede-fopen.h
index 1cf231bd9..62d5e0e40 100644
--- a/tests/test-supersede-fopen.h
+++ b/tests/test-supersede-fopen.h
@@ -92,7 +92,9 @@ test_fopen_supersede (bool supersede_if_exists, bool 
supersede_if_does_not_exist
         /* Verify that the file now has a different inode number, on the same
            device.  */
 #if !(defined _WIN32 && !defined __CYGWIN__)
-        ASSERT (memcmp (&orig_dev, &statbuf.st_dev, sizeof (dev_t)) == 0);
+        /* Note: On Linux/mips, statbuf.st_dev is smaller than a dev_t!  */
+        dev_t new_dev = statbuf.st_dev;
+        ASSERT (memcmp (&orig_dev, &new_dev, sizeof (dev_t)) == 0);
         ASSERT (memcmp (&orig_ino, &statbuf.st_ino, sizeof (ino_t)) != 0);
 #endif
       }
@@ -162,7 +164,9 @@ test_fopen_supersede (bool supersede_if_exists, bool 
supersede_if_does_not_exist
             /* Verify that the file now has a different inode number, on the
                same device.  */
 #if !(defined _WIN32 && !defined __CYGWIN__)
-            ASSERT (memcmp (&orig_dev, &statbuf.st_dev, sizeof (dev_t)) == 0);
+            /* Note: On Linux/mips, statbuf.st_dev is smaller than a dev_t!  */
+            dev_t new_dev = statbuf.st_dev;
+            ASSERT (memcmp (&orig_dev, &new_dev, sizeof (dev_t)) == 0);
             ASSERT (memcmp (&orig_ino, &statbuf.st_ino, sizeof (ino_t)) != 0);
 #endif
           }
diff --git a/tests/test-supersede-open.h b/tests/test-supersede-open.h
index c05effa56..0814eea0d 100644
--- a/tests/test-supersede-open.h
+++ b/tests/test-supersede-open.h
@@ -90,7 +90,9 @@ test_open_supersede (bool supersede_if_exists, bool 
supersede_if_does_not_exist)
         /* Verify that the file now has a different inode number, on the same
            device.  */
 #if !(defined _WIN32 && !defined __CYGWIN__)
-        ASSERT (memcmp (&orig_dev, &statbuf.st_dev, sizeof (dev_t)) == 0);
+        /* Note: On Linux/mips, statbuf.st_dev is smaller than a dev_t!  */
+        dev_t new_dev = statbuf.st_dev;
+        ASSERT (memcmp (&orig_dev, &new_dev, sizeof (dev_t)) == 0);
         ASSERT (memcmp (&orig_ino, &statbuf.st_ino, sizeof (ino_t)) != 0);
 #endif
       }
@@ -159,7 +161,9 @@ test_open_supersede (bool supersede_if_exists, bool 
supersede_if_does_not_exist)
             /* Verify that the file now has a different inode number, on the
                same device.  */
 #if !(defined _WIN32 && !defined __CYGWIN__)
-            ASSERT (memcmp (&orig_dev, &statbuf.st_dev, sizeof (dev_t)) == 0);
+            /* Note: On Linux/mips, statbuf.st_dev is smaller than a dev_t!  */
+            dev_t new_dev = statbuf.st_dev;
+            ASSERT (memcmp (&orig_dev, &new_dev, sizeof (dev_t)) == 0);
             ASSERT (memcmp (&orig_ino, &statbuf.st_ino, sizeof (ino_t)) != 0);
 #endif
           }






reply via email to

[Prev in Thread] Current Thread [Next in Thread]