Print this page
OS-7095 Want risc-v disassembler

Split Close
Expand all
Collapse all
          --- old/usr/src/test/util-tests/tests/dis/distest.ksh
          +++ new/usr/src/test/util-tests/tests/dis/distest.ksh
↓ open down ↓ 3 lines elided ↑ open up ↑
   4    4  # Common Development and Distribution License ("CDDL"), version 1.0.
   5    5  # You may only use this file in accordance with the terms of version
   6    6  # 1.0 of the CDDL.
   7    7  #
   8    8  # A full copy of the text of the CDDL should have accompanied this
   9    9  # source.  A copy of the CDDL is also available via the Internet at
  10   10  # http://www.illumos.org/license/CDDL.
  11   11  #
  12   12  
  13   13  #
  14      -# Copyright 2016 Joyent, Inc.
       14 +# Copyright 2018 Joyent, Inc.
  15   15  #
  16   16  
  17   17  #
  18   18  # libdis test driver
  19   19  #
  20   20  # Tests are arranged by architecture. By default we'll run all of the
  21   21  # dis tests on our current architecture only. If the -p option is passed
  22   22  # to point to other correctly built gas instances, then we'll run those
  23   23  # tests, verifying that the cross-dis works.
  24   24  #
↓ open down ↓ 46 lines elided ↑ open up ↑
  71   71          cat <<USAGE >&2
  72   72  Usage: $dt_arg0  [-n] [ -p platform=pathtoas ]... [ test ]...
  73   73  
  74   74          Runs all dis for the current platform or only specified tests if listed.
  75   75  
  76   76          -n                      Don't run default platform tests
  77   77          -p platform=pathtoas    Run tests for platform using assembler. Should
  78   78                                  either be an absolute path or a command on the
  79   79                                  path.
  80   80  USAGE
       81 +        exit 2
  81   82  }
  82   83  
  83   84  #
  84   85  # By default, tests only run for the current platform. In other words,
  85   86  # running on an x86 system only assumes that the tests in the i386
  86   87  # directory should be run. If the -p option is specified, then other
  87   88  # platforms will be run.
  88   89  #
  89   90  # Right now, we only support running this on x86 natively; however, you
  90   91  # can run tests for other platforms with the -p option.
↓ open down ↓ 98 lines elided ↑ open up ↑
 189  190          rm -rf $dir || fatal "failed to remove directory $dir"
 190  191  }
 191  192  
 192  193  #
 193  194  # Run a single test. This may result in two actual tests (one 32-bit and one
 194  195  # 64-bit) being run.
 195  196  #
 196  197  run_single_file()
 197  198  {
 198  199          typeset sfile base cmpfile prefix arch gas p flags
      200 +        typeset asflags32 asflags64
 199  201          sfile=$1
 200  202  
 201  203          base=${sfile##*/}
 202  204          cmpfile=${sfile%.*}.out
 203  205          prefix=${base%%.*}
 204  206          arch=${sfile%/*}
 205  207          arch=${arch##*/}
 206  208          [[ -f $cmpfile ]] || fatal "missing output file $cmpfile"
 207  209          gas=${dt_platforms[$arch]}
 208  210          [[ -n $gas ]] || fatal "encountered test $sfile, but missing assembler"
 209  211  
      212 +        case "$arch" in
      213 +        "risc-v")
      214 +                asflags32="-march=rv32g"
      215 +                asflags64="-march=rv64g"
      216 +                ;;
      217 +        "risc-v-c")
      218 +                asflags32="-march=rv32gc"
      219 +                asflags64="-march=rv64gc"
      220 +                ;;
      221 +        *)
      222 +                asflags32="-32"
      223 +                asflags64="-64"
      224 +                ;;
      225 +        esac
      226 +
 210  227          case "$prefix" in
 211  228          32)
 212      -                test_one "-32" $sfile $cmpfile
      229 +                test_one $asflags32 $sfile $cmpfile
 213  230                  ;;
 214  231          64)
 215      -                test_one "-64" $sfile $cmpfile
      232 +                test_one $asflags64 $sfile $cmpfile
 216  233                  ;;
 217  234          tst)
 218      -                test_one "-32" $sfile $cmpfile "(32-bit)"
 219      -                test_one "-64" $sfile $cmpfile "(64-bit)"
      235 +                test_one $asflags32 $sfile $cmpfile "(32-bit)"
      236 +                test_one $asflags64 $sfile $cmpfile "(64-bit)"
 220  237                  ;;
 221  238          esac
 222  239  }
 223  240  
 224  241  #
 225  242  # Iterate over all the test directories and run the specified tests
 226  243  #
 227  244  run_tests()
 228  245  {
 229  246          typeset t
↓ open down ↓ 33 lines elided ↑ open up ↑
 263  280  cd $(dirname $0) || fatal "failed to cd to test root"
 264  281  dt_root=$PWD
 265  282  cd $dt_origwd || fatal "failed to return to original dir"
 266  283  
 267  284  while getopts ":np:" c $@; do
 268  285          case "$c" in
 269  286          n)
 270  287                  dt_nodefault="y"
 271  288                  ;;
 272  289          p)
      290 +                OLDIFS=$IFS
 273  291                  IFS="="
 274  292                  set -A split $OPTARG
 275      -                IFS=" "
      293 +                IFS=$OLDIFS
 276  294                  [[ ${#split[@]} -eq 2 ]] || usage "malformed -p option: $OPTARG"
 277  295                  dt_platforms[${split[0]}]=${split[1]}
 278  296                  ;;
 279  297          :)
 280  298                  usage "option requires an argument -- $OPTARG"
 281  299                  ;;
 282  300          *)
 283  301                  usage "invalid option -- $OPTARG"
 284  302                  ;;
 285  303          esac
↓ open down ↓ 13 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX