Print this page
12259 CTF shouldn't assume enum size

Split Close
Expand all
Collapse all
          --- old/usr/src/test/util-tests/tests/ctf/check-common.c
          +++ new/usr/src/test/util-tests/tests/ctf/check-common.c
↓ open down ↓ 2 lines elided ↑ open up ↑
   3    3   * Common Development and Distribution License ("CDDL"), version 1.0.
   4    4   * You may only use this file in accordance with the terms of version
   5    5   * 1.0 of the CDDL.
   6    6   *
   7    7   * A full copy of the text of the CDDL should have accompanied this
   8    8   * source.  A copy of the CDDL is also available via the Internet at
   9    9   * http://www.illumos.org/license/CDDL.
  10   10   */
  11   11  
  12   12  /*
  13      - * Copyright 2019, Joyent, Inc.
       13 + * Copyright 2020 Joyent, Inc.
  14   14   */
  15   15  
  16   16  /*
  17   17   * Collection of common utilities for CTF testing.
  18   18   */
  19   19  
  20   20  #include <strings.h>
  21   21  #include <libctf.h>
  22   22  #include "check-common.h"
  23   23  
↓ open down ↓ 706 lines elided ↑ open up ↑
 730  730                          warnx("argument %u has wrong type: found %s, "
 731  731                              "expected %s", i, buf, argv[i]);
 732  732                          ret = B_FALSE;
 733  733                          break;
 734  734                  }
 735  735          }
 736  736  
 737  737          free(args);
 738  738          return (ret);
 739  739  }
      740 +boolean_t
      741 +ctftest_check_size(const char *type, ctf_file_t *fp, size_t size)
      742 +{
      743 +        ctf_id_t base;
 740  744  
      745 +        if ((base = ctftest_lookup_type(fp, type)) == CTF_ERR) {
      746 +                warnx("Failed to look up type %s", type);
      747 +                return (B_FALSE);
      748 +        }
      749 +
      750 +        if (size != ctf_type_size(fp, base)) {
      751 +                warnx("%s has bad size, expected %lu, found %lu",
      752 +                    type, size, ctf_type_size(fp, base));
      753 +                return (B_FALSE);
      754 +        }
      755 +
      756 +        return (B_TRUE);
      757 +}
      758 +
 741  759  typedef struct ctftest_duplicates {
 742  760          ctf_file_t *ctd_fp;
 743  761          char **ctd_names;
 744  762          size_t ctd_len;
 745  763          size_t ctd_curent;
 746  764          boolean_t ctd_ret;
 747  765  } ctftest_duplicates_t;
 748  766  
 749  767  static int
 750  768  ctftest_duplicates_cb(ctf_id_t id, boolean_t root, void *arg)
↓ open down ↓ 75 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX