Print this page
12259 CTF shouldn't assume enum size

@@ -8,11 +8,11 @@
  * source.  A copy of the CDDL is also available via the Internet at
  * http://www.illumos.org/license/CDDL.
  */
 
 /*
- * Copyright 2019, Joyent, Inc.
+ * Copyright 2020 Joyent, Inc.
  */
 
 /*
  * Check that we properly handle enums.
  */

@@ -99,10 +99,18 @@
         { "enum ff10", check_enum_ff10 },
         { "enum chrono", check_enum_chrono },
         { NULL }
 };
 
+static check_size_test_t size_enums[] = {
+        { "enum char_enum", 1 },
+        { "enum short_enum", 2 },
+        { "enum int_enum", 4 },
+        { "enum ll_enum", 8 },
+        { NULL }
+};
+
 int
 main(int argc, char *argv[])
 {
         int i, ret = 0;
 

@@ -133,10 +141,18 @@
                         if (!ctftest_check_enum(enums[d].cet_type, fp,
                             enums[d].cet_tests)) {
                                 ret = EXIT_FAILURE;
                         }
                 }
+
+                for (d = 0; size_enums[d].cst_name != NULL; d++) {
+                        if (!ctftest_check_size(size_enums[d].cst_name,
+                            fp, size_enums[d].cst_size)) {
+                                ret = EXIT_FAILURE;
+                        }
+                }
+
                 ctf_close(fp);
         }
 
         return (ret);