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

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #!/bin/bash
  2. # Copyright 2020 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. set -e
  16. SCRIPT_BASEDIR=$(realpath "$(dirname "$0")")
  17. PROJECT_DIR=$(realpath "$SCRIPT_BASEDIR/../../")
  18. CRC32_SCRIPT_PATH="$PROJECT_DIR/build/scripts/crc32.sh"
  19. CRC32_OUTPUT_DIR="$PROJECT_DIR/mindinsight/datavisual/utils/"
  20. UT_PATH="$PROJECT_DIR/tests/ut"
  21. IS_BUILD_CRC=""
  22. build_crc32() {
  23. echo "Start to check crc32."
  24. if [ -d "$CRC32_OUTPUT_DIR" ]; then
  25. cd "$CRC32_OUTPUT_DIR" || exit
  26. result=$(find . -maxdepth 1 -name "crc32*.so")
  27. if [ -z "$result" ]; then
  28. echo "Start to build crc32."
  29. IS_BUILD_CRC="true"
  30. bash "$CRC32_SCRIPT_PATH"
  31. fi
  32. fi
  33. }
  34. clean_crc32() {
  35. echo "Start to clean crc32."
  36. if [ -n "$IS_BUILD_CRC" ]; then
  37. rm -f "$CRC32_OUTPUT_DIR"/crc32*.so
  38. fi
  39. }
  40. before_run_test() {
  41. echo "Before run tests."
  42. export PYTHONPATH=$PROJECT_DIR:$PYTHONPATH
  43. build_crc32
  44. }
  45. after_run_test() {
  46. echo "After run tests."
  47. clean_crc32
  48. echo "End to run test."
  49. }
  50. run_test() {
  51. echo "Start to run test."
  52. cd "$PROJECT_DIR" || exit
  53. pytest "$UT_PATH"
  54. echo "Test all use cases success."
  55. }
  56. before_run_test
  57. run_test
  58. after_run_test