From: Bruno Haible <bruno@clisp.org>
Date: Mon, 30 Aug 2021 00:36:31 +0000 (+0200)
Subject: supersede: Fix test failure under QEMU user-mode for Linux/mips.
X-Git-Tag: v1.0~2624
X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=ac97e574f58eecc76190d046b7c1f72d2f6f4734;p=gnulib.git

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/ChangeLog b/ChangeLog
index 7933058e8f..df3f0481f6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+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.
+
 2021-08-29  Bruno Haible  <bruno@clisp.org>
 
 	spawn-pipe: Fix test failure when running under QEMU user-mode.
diff --git a/tests/test-supersede-fopen.h b/tests/test-supersede-fopen.h
index 1cf231bd93..62d5e0e407 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 c05effa56b..0814eea0da 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
           }