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.
  */
 
 /*
  * Collection of common utilities for CTF testing.
  */

@@ -735,11 +735,29 @@
         }
 
         free(args);
         return (ret);
 }
+boolean_t
+ctftest_check_size(const char *type, ctf_file_t *fp, size_t size)
+{
+        ctf_id_t base;
 
+        if ((base = ctftest_lookup_type(fp, type)) == CTF_ERR) {
+                warnx("Failed to look up type %s", type);
+                return (B_FALSE);
+        }
+
+        if (size != ctf_type_size(fp, base)) {
+                warnx("%s has bad size, expected %lu, found %lu",
+                    type, size, ctf_type_size(fp, base));
+                return (B_FALSE);
+        }
+
+        return (B_TRUE);
+}
+
 typedef struct ctftest_duplicates {
         ctf_file_t *ctd_fp;
         char **ctd_names;
         size_t ctd_len;
         size_t ctd_curent;