Print this page
10823 should ignore DW_TAG_subprogram with DW_AT_declaration tags
10824 GCC7-derived CTF can double qualifiers on arrays
10825 ctfdump -c drops last type
10826 ctfdump -c goes off the rails with a missing parent
Reviewed by: Robert Mustacchi <rm@joyent.com>
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
Reviewed by: Jason King <jason.king@joyent.com>
Approved by: Jerry Jelinek <jerry.jelinek@joyent.com>

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 (c) 2019, Joyent, Inc.
       13 + * Copyright 2019, 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 ↓ 217 lines elided ↑ open up ↑
 241  241          cb.csc_ret = B_TRUE;
 242  242          cb.csc_tests = tests;
 243  243          if (ctf_object_iter(fp, ctftest_check_symbol_cb, &cb) != 0)
 244  244                  return (B_FALSE);
 245  245          return (cb.csc_ret);
 246  246  }
 247  247  
 248  248  
 249  249  boolean_t
 250  250  ctftest_check_descent(const char *symbol, ctf_file_t *fp,
 251      -    const check_descent_t *tests)
      251 +    const check_descent_t *tests, boolean_t quiet)
 252  252  {
 253  253          ctf_id_t base;
 254  254          uint_t layer = 0;
 255  255  
 256  256          /*
 257  257           * First, find the initial type of the symbol.
 258  258           */
 259  259          base = ctftest_lookup_symbol(fp, symbol);
 260  260          if (base == CTF_ERR) {
 261  261                  warnx("failed to lookup type for symbol %s", symbol);
 262  262                  return (B_FALSE);
 263  263          }
 264  264  
 265  265          while (tests->cd_tname != NULL) {
 266  266                  ctf_id_t tid;
 267  267                  int kind;
 268  268                  ctf_arinfo_t ari;
 269  269  
 270  270                  if (base == CTF_ERR) {
 271      -                        warnx("encountered non-reference type at layer %u "
 272      -                            "while still expecting type %s for symbol %s",
 273      -                            layer, tests->cd_tname, symbol);
      271 +                        if (!quiet) {
      272 +                                warnx("encountered non-reference type at layer "
      273 +                                    "%u while still expecting type %s for "
      274 +                                    "symbol %s", layer,
      275 +                                    tests->cd_tname, symbol);
      276 +                        }
 274  277                          return (B_FALSE);
 275  278                  }
 276  279  
 277  280                  tid = ctftest_lookup_type(fp, tests->cd_tname);
 278  281                  if (tid == CTF_ERR) {
 279      -                        warnx("failed to lookup type %s", tests->cd_tname);
      282 +                        if (!quiet) {
      283 +                                warnx("failed to lookup type %s",
      284 +                                    tests->cd_tname);
      285 +                        }
 280  286                          return (B_FALSE);
 281  287                  }
 282  288  
 283  289                  if (tid != base) {
 284      -                        warnx("type mismatch at layer %u: found id %u, but "
 285      -                            "expecting type id %u for type %s, symbol %s",
 286      -                            layer, base, tid, tests->cd_tname, symbol);
      290 +                        if (!quiet) {
      291 +                                warnx("type mismatch at layer %u: found id %u, "
      292 +                                    "but expecting type id %u for type %s, "
      293 +                                    "symbol %s", layer, base, tid,
      294 +                                    tests->cd_tname, symbol);
      295 +                        }
 287  296                          return (B_FALSE);
 288  297                  }
 289  298  
 290  299                  kind = ctf_type_kind(fp, base);
 291  300                  if (kind != tests->cd_kind) {
 292      -                        warnx("type kind mismatch at layer %u: found kind %u, "
 293      -                            "but expected kind %u for %s, symbol %s", layer,
 294      -                            kind, tests->cd_kind, tests->cd_tname, symbol);
      301 +                        if (!quiet) {
      302 +                                warnx("type kind mismatch at layer %u: found "
      303 +                                    "kind %u, but expected kind %u for %s, "
      304 +                                    "symbol %s", layer, kind, tests->cd_kind,
      305 +                                    tests->cd_tname, symbol);
      306 +                        }
 295  307                          return (B_FALSE);
 296  308                  }
 297  309  
 298  310                  switch (kind) {
 299  311                  case CTF_K_ARRAY:
 300  312                          if (ctf_array_info(fp, base, &ari) == CTF_ERR) {
 301      -                                warnx("failed to lookup array info at layer "
 302      -                                    "%u for type %s, symbol %s: %s", base,
 303      -                                    tests->cd_tname, symbol,
 304      -                                    ctf_errmsg(ctf_errno(fp)));
      313 +                                if (!quiet) {
      314 +                                        warnx("failed to lookup array info at "
      315 +                                            "layer %u for type %s, symbol "
      316 +                                            "%s: %s", base, tests->cd_tname,
      317 +                                            symbol, ctf_errmsg(ctf_errno(fp)));
      318 +                                }
 305  319                                  return (B_FALSE);
 306  320                          }
 307  321  
 308  322                          if (tests->cd_nents != ari.ctr_nelems) {
 309      -                                warnx("array element mismatch at layer %u "
 310      -                                    "for type %s, symbol %s: found %u, "
 311      -                                    "expected %u", layer, tests->cd_tname,
 312      -                                    symbol, ari.ctr_nelems, tests->cd_nents);
      323 +                                if (!quiet) {
      324 +                                        warnx("array element mismatch at layer "
      325 +                                            "%u for type %s, symbol %s: found "
      326 +                                            "%u, expected %u", layer,
      327 +                                            tests->cd_tname, symbol,
      328 +                                            ari.ctr_nelems, tests->cd_nents);
      329 +                                }
 313  330                                  return (B_FALSE);
 314  331                          }
 315  332  
 316  333                          tid = ctftest_lookup_type(fp, tests->cd_contents);
 317  334                          if (tid == CTF_ERR) {
 318      -                                warnx("failed to look up type %s",
 319      -                                    tests->cd_contents);
      335 +                                if (!quiet) {
      336 +                                        warnx("failed to look up type %s",
      337 +                                            tests->cd_contents);
      338 +                                }
 320  339                                  return (B_FALSE);
 321  340                          }
 322  341  
 323  342                          if (ari.ctr_contents != tid) {
 324      -                                warnx("array contents mismatch at layer %u "
 325      -                                    "for type %s, symbol %s: found %u, "
 326      -                                    "expected %s/%u", layer, tests->cd_tname,
 327      -                                    symbol, ari.ctr_contents,
 328      -                                    tests->cd_contents, tid);
 329      -
      343 +                                if (!quiet) {
      344 +                                        warnx("array contents mismatch at "
      345 +                                            "layer %u for type %s, symbol %s: "
      346 +                                            "found %u, expected %s/%u", layer,
      347 +                                            tests->cd_tname, symbol,
      348 +                                            ari.ctr_contents,
      349 +                                            tests->cd_contents, tid);
      350 +                                }
 330  351                                  return (B_FALSE);
 331  352                          }
 332  353                          base = ari.ctr_contents;
 333  354                          break;
 334  355                  default:
 335  356                          base = ctf_type_reference(fp, base);
 336  357                          break;
 337  358                  }
 338  359  
 339  360                  tests++;
 340  361                  layer++;
 341  362          }
 342  363  
 343  364          if (base != CTF_ERR) {
 344      -                warnx("found additional type %u in chain, but expected no more",
 345      -                    base);
      365 +                if (!quiet) {
      366 +                        warnx("found additional type %u in chain, "
      367 +                            "but expected no more", base);
      368 +                }
 346  369                  return (B_FALSE);
 347  370          }
 348  371  
 349  372          return (B_TRUE);
 350  373  }
 351  374  
 352  375  int
 353  376  ctftest_check_enum_count(const char *name, int value, void *arg)
 354  377  {
 355  378          uint_t *u = arg;
↓ open down ↓ 447 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX