You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

runtest.sh 2.5 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. #!/bin/bash
  2. # Copyright 2019 Huawei Technologies Co., Ltd
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. # ============================================================================
  16. set -e
  17. BASEPATH=$(cd "$(dirname $0)"; pwd)
  18. PROJECT_PATH=${BASEPATH}/../../..
  19. # print usage message
  20. usage()
  21. {
  22. echo "Usage:"
  23. echo "sh runtests.sh [-e ascend310|ascend910] [-n testcase_name] [-d n]"
  24. echo ""
  25. echo "Options:"
  26. echo " -h Print usage"
  27. echo " -e Device target, default is ascend310"
  28. echo " -d Device ID, default is 0"
  29. echo " -n Run single tesecase, default off"
  30. echo "to be continued ..."
  31. }
  32. checkopts()
  33. {
  34. DEVICE_TARGET_OPT="ascend310"
  35. DEVICE_ID_OPT=0
  36. TASECASE_NAME_OPT=""
  37. # Process the options
  38. while getopts 'he:d:n:' opt
  39. do
  40. case "${opt}" in
  41. h)
  42. usage
  43. exit 0
  44. ;;
  45. e)
  46. DEVICE_TARGET_OPT=$(echo ${OPTARG} | tr '[A-Z]' '[a-z]')
  47. ;;
  48. d)
  49. DEVICE_ID_OPT=$OPTARG
  50. ;;
  51. n)
  52. TASECASE_NAME_OPT=$OPTARG
  53. ;;
  54. *)
  55. echo "Undefined option: ${opt}"
  56. usage
  57. exit 1
  58. esac
  59. done
  60. }
  61. checkopts "$@"
  62. cd ${PROJECT_PATH}/tests/st/cpp
  63. MINDSPORE_PKG_PATH=`python -m pip show mindspore-ascend | grep Location | awk '{print $2"/mindspore"}' | xargs realpath`
  64. if [[ "X${MINDSPORE_PKG_PATH}" == "X" ]]; then
  65. MINDSPORE_PKG_PATH=${PROJECT_PATH}/build/package/mindspore:
  66. fi
  67. export LD_LIBRARY_PATH=${MINDSPORE_PKG_PATH}:${MINDSPORE_PKG_PATH}/lib:${PROJECT_PATH}/tests/st/cpp:$LD_LIBRARY_PATH
  68. export GLOG_v=2
  69. export GC_COLLECT_IN_CELL=1
  70. export DEVICE_ID=$DEVICE_ID_OPT
  71. if [[ "X$DEVICE_TARGET_OPT" == "Xascend310" ]]; then
  72. export DEVICE_TARGET=Ascend310
  73. elif [[ "X$DEVICE_TARGET_OPT" == "Xascend910" ]]; then
  74. export DEVICE_TARGET=Ascend910
  75. else
  76. export DEVICE_TARGET=$DEVICE_TARGET_OPT
  77. fi
  78. if [[ "X$TASECASE_NAME_OPT" != "X" ]]; then
  79. ./st_tests --gtest_filter=$TASECASE_NAME_OPT
  80. else
  81. ./st_tests
  82. fi
  83. RET=$?
  84. cd -
  85. exit ${RET}