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-enum.c
          +++ new/usr/src/test/util-tests/tests/ctf/check-enum.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   * Check that we properly handle enums.
  18   18   */
  19   19  
  20   20  #include "check-common.h"
  21   21  
  22   22  static check_symbol_t check_syms[] = {
  23   23          { "ff6", "enum ff6" },
↓ open down ↓ 70 lines elided ↑ open up ↑
  94   94          { NULL }
  95   95  };
  96   96  
  97   97  static check_enum_test_t enums[] = {
  98   98          { "enum ff6", check_enum_ff6 },
  99   99          { "enum ff10", check_enum_ff10 },
 100  100          { "enum chrono", check_enum_chrono },
 101  101          { NULL }
 102  102  };
 103  103  
      104 +static check_size_test_t size_enums[] = {
      105 +        { "enum char_enum", 1 },
      106 +        { "enum short_enum", 2 },
      107 +        { "enum int_enum", 4 },
      108 +        { "enum ll_enum", 8 },
      109 +        { NULL }
      110 +};
      111 +
 104  112  int
 105  113  main(int argc, char *argv[])
 106  114  {
 107  115          int i, ret = 0;
 108  116  
 109  117          if (argc < 2) {
 110  118                  errx(EXIT_FAILURE, "missing test files");
 111  119          }
 112  120  
 113  121          for (i = 1; i < argc; i++) {
↓ open down ↓ 14 lines elided ↑ open up ↑
 128  136                                  ret = EXIT_FAILURE;
 129  137                          }
 130  138                  }
 131  139  
 132  140                  for (d = 0; enums[d].cet_type != NULL; d++) {
 133  141                          if (!ctftest_check_enum(enums[d].cet_type, fp,
 134  142                              enums[d].cet_tests)) {
 135  143                                  ret = EXIT_FAILURE;
 136  144                          }
 137  145                  }
      146 +
      147 +                for (d = 0; size_enums[d].cst_name != NULL; d++) {
      148 +                        if (!ctftest_check_size(size_enums[d].cst_name,
      149 +                            fp, size_enums[d].cst_size)) {
      150 +                                ret = EXIT_FAILURE;
      151 +                        }
      152 +                }
      153 +
 138  154                  ctf_close(fp);
 139  155          }
 140  156  
 141  157          return (ret);
 142  158  
 143  159  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX