Print this page
rm code review
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 ↓ 707 lines elided ↑ open up ↑
 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  740  
      741 +boolean_t
      742 +ctftest_check_size(const char *type, ctf_file_t *fp, size_t size)
      743 +{
      744 +        ctf_id_t base;
      745 +
      746 +        if ((base = ctftest_lookup_type(fp, type)) == CTF_ERR) {
      747 +                warnx("Failed to look up type %s", type);
      748 +                return (B_FALSE);
      749 +        }
      750 +
      751 +        if (size != ctf_type_size(fp, base)) {
      752 +                warnx("%s has bad size, expected %lu, found %lu",
      753 +                    type, size, ctf_type_size(fp, base));
      754 +                return (B_FALSE);
      755 +        }
      756 +
      757 +        return (B_TRUE);
      758 +}
      759 +
 741  760  typedef struct ctftest_duplicates {
 742  761          ctf_file_t *ctd_fp;
 743  762          char **ctd_names;
 744  763          size_t ctd_len;
 745  764          size_t ctd_curent;
 746  765          boolean_t ctd_ret;
 747  766  } ctftest_duplicates_t;
 748  767  
 749  768  static int
 750  769  ctftest_duplicates_cb(ctf_id_t id, boolean_t root, void *arg)
↓ open down ↓ 75 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX