]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: check size detections by meson
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 31 May 2023 23:20:04 +0000 (08:20 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 22 Jun 2023 06:24:57 +0000 (15:24 +0900)
src/test/test-sizeof.c

index 5dd8a04bbd7ea2b855162c0ac8a981ab52c38031..18378b0450083dee6ab1597459640efd0daeeab8 100644 (file)
@@ -3,8 +3,9 @@
 #include <sched.h>
 #include <stdio.h>
 #include <string.h>
-#include <sys/types.h>
+#include <sys/resource.h>
 #include <sys/socket.h>
+#include <sys/types.h>
 
 #define __STDC_WANT_IEC_60559_TYPES_EXT__
 #include <float.h>
@@ -28,6 +29,18 @@ DISABLE_WARNING_TYPE_LIMITS;
                (t)-1 < (t)0 ? ", signed" : ", unsigned",                \
                alignof(t))
 
+#define check_no_sign(t, size)                  \
+        do {                                    \
+                info_no_sign(t);                \
+                assert_se(sizeof(t) == size);   \
+        } while (false)
+
+#define check(t, size)                          \
+        do {                                    \
+                info(t);                        \
+                assert_se(sizeof(t) == size);   \
+        } while (false)
+
 enum Enum {
         enum_value,
 };
@@ -44,6 +57,12 @@ enum BigEnum2 {
 int main(void) {
         int (*function_pointer)(void);
 
+        check_no_sign(dev_t, SIZEOF_DEV_T);
+        check_no_sign(ino_t, SIZEOF_INO_T);
+        check_no_sign(rlim_t, SIZEOF_RLIM_T);
+        check(time_t, SIZEOF_TIME_T);
+        check(typeof(((struct timex *)0)->freq), SIZEOF_TIMEX_MEMBER);
+
         info_no_sign(typeof(function_pointer));
         info_no_sign(void*);
         info(char*);
@@ -76,7 +95,6 @@ int main(void) {
 
         info(size_t);
         info(ssize_t);
-        info(time_t);
         info(usec_t);
 #ifdef __GLIBC__
         info(__time_t);