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 3.5 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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] [-t cpp|python] [-r path]"
  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 " -t Type of MindSpore package to be tested, default is cpp"
  31. echo " -r Path of mindspore package to be tested, default is {PROJECT_PATH}/output"
  32. echo "to be continued ..."
  33. }
  34. checkopts()
  35. {
  36. DEVICE_TARGET_OPT="ascend310"
  37. DEVICE_ID_OPT=0
  38. TASECASE_NAME_OPT=""
  39. TEST_PATH=${PROJECT_PATH}/tests/st/cpp
  40. PACKAGE_PATH=${PROJECT_PATH}/output
  41. PACKAGE_TYPE="cpp"
  42. # Process the options
  43. while getopts 'he:d:n:t:r:' opt
  44. do
  45. case "${opt}" in
  46. h)
  47. usage
  48. exit 0
  49. ;;
  50. e)
  51. DEVICE_TARGET_OPT=$(echo ${OPTARG} | tr '[A-Z]' '[a-z]')
  52. ;;
  53. d)
  54. DEVICE_ID_OPT=$OPTARG
  55. ;;
  56. n)
  57. TASECASE_NAME_OPT=$OPTARG
  58. ;;
  59. t)
  60. if [[ "X$OPTARG" == "Xcpp" || "X$OPTARG" == "Xpython" ]]; then
  61. PACKAGE_TYPE="$OPTARG"
  62. else
  63. echo "Invalid value ${OPTARG} for option -t"
  64. usage
  65. exit 1
  66. fi
  67. ;;
  68. r)
  69. PACKAGE_PATH=$OPTARG
  70. echo "package path set to: ${OPTARG}"
  71. ;;
  72. *)
  73. echo "Undefined option: ${opt}"
  74. usage
  75. exit 1
  76. esac
  77. done
  78. }
  79. checkopts "$@"
  80. cd ${TEST_PATH}
  81. # using installed or compiled whl packages, set env path by pip
  82. if [[ "${PACKAGE_TYPE}" == "python" ]]; then
  83. MINDSPORE_PKG_PATH=`python -m pip show mindspore-ascend | grep Location | awk '{print $2"/mindspore"}' | xargs realpath`
  84. if [[ "X${MINDSPORE_PKG_PATH}" == "X" ]]; then
  85. MINDSPORE_PKG_PATH=${PROJECT_PATH}/build/package/mindspore:
  86. fi
  87. elif [[ "${PACKAGE_TYPE}" == "cpp" ]]; then
  88. # using acl tar package, extract tar package here
  89. rm -rf mindspore_ascend*
  90. PACKAGE_NAME_FULL=$(find "${PACKAGE_PATH}" -name "mindspore_ascend*.tar.gz")
  91. PACKAGE_NAME=${PACKAGE_NAME_FULL##*/}
  92. tar -xzf ${PACKAGE_PATH}/${PACKAGE_NAME}
  93. MINDSPORE_PKG_PATH=$(find "${TEST_PATH}" -maxdepth 1 -name "mindspore_ascend*")
  94. fi
  95. export LD_LIBRARY_PATH=${MINDSPORE_PKG_PATH}:${MINDSPORE_PKG_PATH}/lib:${PROJECT_PATH}/tests/st/cpp:$LD_LIBRARY_PATH
  96. export GLOG_v=2
  97. export GC_COLLECT_IN_CELL=1
  98. export DEVICE_ID=$DEVICE_ID_OPT
  99. if [[ "X$DEVICE_TARGET_OPT" == "Xascend310" ]]; then
  100. export DEVICE_TARGET=Ascend310
  101. elif [[ "X$DEVICE_TARGET_OPT" == "Xascend910" ]]; then
  102. export DEVICE_TARGET=Ascend910
  103. else
  104. export DEVICE_TARGET=$DEVICE_TARGET_OPT
  105. fi
  106. if [[ "X$TASECASE_NAME_OPT" != "X" ]]; then
  107. ./st_tests --gtest_filter=$TASECASE_NAME_OPT
  108. else
  109. ./st_tests
  110. fi
  111. RET=$?
  112. cd -
  113. exit ${RET}