Print this page
10816 ctf_dwarf_convert_type() relies on un-initialized id
10817 ctfconvert -i option is mis-handled
10818 Improve ctfconvert error messages
10819 ctfconvert should handle empty dies
10820 ctfconvert -i never converts
10821 bad free in ctf_dwarf_init_die
10815 shouldn't build gcore.c as part of kmdb
Reviewed by: Robert Mustacchi <rm@joyent.com>
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>

Split Close
Expand all
Collapse all
          --- old/usr/src/test/util-tests/tests/ctf/ctftest.ksh
          +++ new/usr/src/test/util-tests/tests/ctf/ctftest.ksh
↓ open down ↓ 18 lines elided ↑ open up ↑
  19   19  # Run all of the various CTF tests
  20   20  #
  21   21  
  22   22  unalias -a
  23   23  #set -o xtrace
  24   24  
  25   25  if [[ -z "$TMPDIR" ]]; then
  26   26          TMPDIR="/tmp"
  27   27  fi
  28   28  
       29 +
  29   30  ctf_arg0=$(basename $0)
  30   31  ctf_root=$(cd $(dirname $0) && echo $PWD)
  31   32  ctf_tests=
  32      -ctf_compiler="gcc"
       33 +ctf_cc="gcc"
       34 +ctf_cxx="g++"
       35 +ctf_as="as"
  33   36  ctf_convert="ctfconvert"
  34   37  ctf_merge="ctfmerge"
  35   38  ctf_debugflags="-gdwarf-2 "
  36   39  ctf_mach32="-m32"
  37   40  ctf_mach64="-m64"
  38      -ctf_32cflags="$ctf_mach32 $ctf_debugflags"
  39      -ctf_64cflags="$ctf_mach64 $ctf_debugflags"
  40   41  ctf_temp="$TMPDIR/ctftest.$$.o"
  41   42  ctf_makefile="Makefile.ctftest"
  42   43  ctf_nerrs=0
  43   44  
  44   45  usage()
  45   46  {
  46   47          typeset msg="$*"
  47   48          [[ -z "$msg" ]] || echo "$msg" >&2
  48   49          cat <<USAGE >&2
  49      -Usage: $ctf_arg0  [-c compiler] [-g flags] [-m ctfmerge] [-t ctfconvert]
       50 +Usage: $ctf_arg0 [-a as] [-c cc] [-C CC] [-g flags] [-m ctfmerge] [-t ctfconvert]
  50   51  
  51   52          Runs the CTF test suite
  52   53  
  53      -        -c compiler             Use the specified compiler, defaults to 'gcc'
  54      -                                on path.
       54 +        -a assembler            Use the specified assembler, defaults to 'as'
       55 +        -c compiler             Use the specified C compiler, defaults to 'gcc'
       56 +        -C compiler             Use the specified C++ compiler, defaults to 'g++'
  55   57          -g flags                Use flags to generate debug info. Defaults to
  56   58                                  "-gdwarf-2".
  57   59          -m ctfmerge             Use the specified ctfmerge, defaults to
  58      -                                'ctfmerge' on path.
       60 +                                'ctfmerge'
  59   61          -t ctfconvert           Use the specified ctfconvert, defaults to
  60      -                                'ctfconvert' on path.
       62 +                                'ctfconvert'
  61   63  USAGE
  62   64          exit 2
  63   65  }
  64   66  
  65   67  
  66   68  test_fail()
  67   69  {
  68   70          typeset msg="$*"
  69   71          [[ -z "$msg" ]] && msg="failed"
  70   72          echo "TEST FAILED: $msg" >&2
↓ open down ↓ 2 lines elided ↑ open up ↑
  73   75  
  74   76  fatal()
  75   77  {
  76   78          typeset msg="$*"
  77   79          [[ -z "$msg" ]] && msg="failed"
  78   80          echo "$ctf_arg0: $msg" >&2
  79   81          rm -f "$ctf_tmp32" "$ctf_temp64"
  80   82          exit 1
  81   83  }
  82   84  
  83      -check_env()
  84      -{
  85      -        if which "$1" 2>/dev/null >/dev/null; then
  86      -                return
  87      -        fi
  88      -
  89      -        [[ -f "$1" ]] || fatal "failed to find tool $1"
  90      -}
  91      -
  92   85  announce()
  93   86  {
  94   87          cat << EOF
  95   88  Beginning CTF tests with the following settings:
  96      -COMPILER:       $(which $ctf_compiler)
  97      -CTFCONVERT:     $(which $ctf_convert)
  98      -CTFMERGE:       $(which $ctf_merge)
       89 +cc:             $(which $ctf_cc)
       90 +CC:             $(which $ctf_cxx)
       91 +as:             $(which $ctf_as)
       92 +ctfconvert:     $(which $ctf_convert)
       93 +ctfmerge:       $(which $ctf_merge)
  99   94  32-bit CFLAGS:  $ctf_32cflags
 100   95  64-bit CFLAGS:  $ctf_64cflags
 101   96  
 102   97  EOF
 103   98  }
 104   99  
 105  100  run_one()
 106  101  {
 107  102          typeset source=$1 checker=$2 flags=$3
 108  103  
 109      -        if ! "$ctf_compiler" $flags -o "$ctf_temp" -c "$source"; then
      104 +        if ! "$ctf_cc" $flags -o "$ctf_temp" -c "$source"; then
 110  105                  test_fail "failed to compile $source with flags: $flags"
 111  106                  return
 112  107          fi
 113  108  
 114  109          if ! "$ctf_convert" "$ctf_temp"; then
 115  110                  test_fail "failed to convert CTF in $source"
 116  111                  return
 117  112          fi
 118  113  
 119  114          if ! "$checker" "$ctf_temp"; then
↓ open down ↓ 19 lines elided ↑ open up ↑
 139  134          flags32=$3
 140  135          check64=$4
 141  136          flags64=$5
 142  137  
 143  138          if ! mkdir $outdir; then
 144  139                  fatal "failed to make temporary directory '$outdir'"
 145  140          fi
 146  141  
 147  142          if ! make -C $dir -f Makefile.ctftest \
 148  143              BUILDDIR="$outdir" \
 149      -            CC="$ctf_compiler" \
      144 +            CC="$ctf_cc" \
 150  145              CFLAGS32="$ctf_mach32" \
 151  146              CFLAGS64="$ctf_mach64" \
 152  147              DEBUGFLAGS="$ctf_debugflags" \
 153  148              CTFCONVERT="$ctf_convert" \
 154  149              CTFMERGE="$ctf_merge" \
 155  150              build 1>/dev/null; then
 156  151                  rm -rf $outdir
 157  152                  test_fail "failed to build $dir"
 158  153                  return
 159  154          fi
↓ open down ↓ 43 lines elided ↑ open up ↑
 203  198                          run_dir $d "$ctf_root/$check" "$ctf_32cflags" \
 204  199                              "$ctf_root/$check" "$ctf_64cflags"
 205  200                  elif [[ -f "$ctf_root/$check-32" && \
 206  201                      -f "$ctf_root/$check-64" ]]; then
 207  202                          run_dir $d "$ctf_root/$check-32" "$ctf_32cflags" \
 208  203                              "$ctf_root/$check-64" "$ctf_64cflags"
 209  204                  else
 210  205                          test_fail "missing checker for $t"
 211  206                  fi
 212  207          done
      208 +
      209 +        outdir="$TMPDIR/ctftest.$$"
      210 +
      211 +        for f in $(find "$ctf_root" -maxdepth 1 -type f -name 'ctftest-*'); do
      212 +                if ! mkdir $outdir; then
      213 +                        fatal "failed to make temporary directory '$outdir'"
      214 +                fi
      215 +
      216 +                echo "Running $f in $outdir"
      217 +
      218 +                (cd $outdir && $f)
      219 +
      220 +                if [[ $? -ne 0 ]]; then
      221 +                        test_fail "$f failed"
      222 +                else
      223 +                        echo "TEST PASSED: $f"
      224 +                fi
      225 +
      226 +                rm -rf $outdir
      227 +        done
 213  228  }
 214  229  
 215      -while getopts ":c:g:m:t:" c $@; do
      230 +while getopts ":a:C:c:g:m:t:" c $@; do
 216  231          case "$c" in
      232 +        a)
      233 +                ctf_as=$OPTARG
      234 +                ;;
      235 +        C)
      236 +                ctf_cxx=$OPTARG
      237 +                ;;
 217  238          c)
 218      -                ctf_compiler=$OPTARG
      239 +                ctf_cc=$OPTARG
 219  240                  ;;
 220  241          g)
 221  242                  ctf_debugflags=$OPTARG
 222  243                  ;;
 223  244          m)
 224  245                  ctf_merge=$OPTARG
 225  246                  ;;
 226  247          t)
 227  248                  ctf_convert=$OPTARG
 228  249                  ;;
↓ open down ↓ 2 lines elided ↑ open up ↑
 231  252                  ;;
 232  253          *)
 233  254                  usage "invalid option -- $OPTARG"
 234  255                  ;;
 235  256          esac
 236  257  done
 237  258  
 238  259  ctf_32cflags="$ctf_mach32 $ctf_debugflags"
 239  260  ctf_64cflags="$ctf_mach64 $ctf_debugflags"
 240  261  
 241      -check_env "$ctf_compiler"
 242      -check_env "$ctf_convert"
 243      -check_env "$ctf_merge"
      262 +export ctf_as ctf_cc ctf_cxx ctf_debugflags ctf_merge ctf_convert
      263 +
 244  264  announce
 245  265  
 246  266  run_tests
 247  267  
 248  268  if [[ $ctf_nerrs -ne 0 ]]; then
 249  269          if [[ $ctf_nerrs -eq 1 ]]; then
 250  270                  printf "\n%s: %u test failed\n" "$ctf_arg0" "$ctf_nerrs"
 251  271          else
 252  272                  printf "\n%s: %u tests failed\n" "$ctf_arg0" "$ctf_nerrs"
 253  273          fi
      274 +        exit 1
 254  275  else
 255  276          printf "\n%s: All tests passed successfully\n" "$ctf_arg0"
 256  277          exit 0
 257  278  fi
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX