]> Savannah Git Hosting - gnulib.git/commitdiff
Slightly nicer largefile, year2038 tests
authorPaul Eggert <eggert@cs.ucla.edu>
Mon, 17 Apr 2023 15:44:51 +0000 (08:44 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Mon, 17 Apr 2023 15:47:23 +0000 (08:47 -0700)
* modules/largefile-tests, modules/year2038-tests (Depends-on):
Add assert-h, intprops.
* tests/test-largefile.c, tests/test-year2038.c:
Prefer compile-time to run-time tests.
Don’t assume CHAR_BIT == 8.

ChangeLog
modules/largefile-tests
modules/year2038-tests
tests/test-largefile.c
tests/test-year2038.c

index bd17733008178eaa6a3cb86528c40a4768b51093..3e2682aac6a65f9ee4ca0112fe6bf1d0c9799593 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2023-04-17  Paul Eggert  <eggert@cs.ucla.edu>
+
+       Slightly nicer largefile, year2038 tests
+       * modules/largefile-tests, modules/year2038-tests (Depends-on):
+       Add assert-h, intprops.
+       * tests/test-largefile.c, tests/test-year2038.c:
+       Prefer compile-time to run-time tests.
+       Don’t assume CHAR_BIT == 8.
+
 2023-04-17  Bruno Haible  <bruno@clisp.org>
 
        MODULES.html.sh: Ensure hyperlinked files are displayable.
index 3241cceb5d90178d1356e1d98497d5f6e999deb6..544070259a4d76e093c3986a367abda8db422f47 100644 (file)
@@ -2,6 +2,8 @@ Files:
 tests/test-largefile.c
 
 Depends-on:
+assert-h
+intprops
 sys_types
 sys_stat
 
index ce51559a3ce674ef78d991036eeee50635a9070c..63f00ee7f8ca3b9823f08336a58d8bedec968c5f 100644 (file)
@@ -2,6 +2,8 @@ Files:
 tests/test-year2038.c
 
 Depends-on:
+assert-h
+intprops
 
 configure.ac:
 
index 71ee7e942db2bb5ef54c0906f6b4720ddf7b878f..ce5d8a0e2e28d5fdeb98a2f8b9478e9ffffb8ff4 100644 (file)
 
 #include <sys/types.h>
 #include <sys/stat.h>
+#include "intprops.h"
+
+/* Check the range of off_t.
+   With MSVC, this test succeeds only thanks to the 'sys_types' module.  */
+static_assert (TYPE_MAXIMUM (off_t) >> 31 >> 31 != 0);
+
+/* Check the size of the 'struct stat' field 'st_size'.
+   ,With MSVC, this test succeeds only thanks to the 'sys_stat' module.  */
+static struct stat st;
+static_assert (sizeof st.st_size == sizeof (off_t));
 
 int
 main (void)
 {
-  int result = 0;
-
-  /* Check the size of off_t.
-     With MSVC, this test succeeds only thanks to the 'sys_types' module.  */
-  if (sizeof (off_t) <= 4)
-    result |= 1;
-
-  /* Check the size of the 'struct stat' field 'st_size'.
-     With MSVC, this test succeeds only thanks to the 'sys_stat' module.  */
-  {
-    struct stat st;
-    if (sizeof (st.st_size) <= 4)
-      result |= 2;
-  }
-
-  return result;
+  return 0;
 }
index 58c1058b1324b8285ed4674f43e00592550a5fd6..0facf930ed121355e5ace2924d5f3aa79a721d8f 100644 (file)
 #include <config.h>
 
 #include <sys/types.h>
+#include "intprops.h"
+
+/* Check the range of time_t.  */
+static_assert (TYPE_MAXIMUM (time_t) >> 31 != 0);
 
 int
 main (void)
 {
-  /* Check the size and sign of time_t.  */
-  if (sizeof (time_t) <= 4 && (time_t)-1 < 0)
-    /* time_t is only 32 bits wide and signed.  */
-    return 1;
-
   return 0;
 }