2
0

chrome_tests.sh 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. #!/bin/bash
  2. # Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
  3. #
  4. # Use of this source code is governed by a BSD-style license
  5. # that can be found in the LICENSE file in the root of the source
  6. # tree. An additional intellectual property rights grant can be found
  7. # in the file PATENTS. All contributing project authors may
  8. # be found in the AUTHORS file in the root of the source tree.
  9. # Set up some paths and re-direct the arguments to chrome_tests.py
  10. export THISDIR=`dirname $0`
  11. ARGV_COPY="$@"
  12. # We need to set CHROME_VALGRIND iff using Memcheck:
  13. # tools/valgrind/chrome_tests.sh --tool memcheck
  14. # or
  15. # tools/valgrind/chrome_tests.sh --tool=memcheck
  16. tool="memcheck" # Default to memcheck.
  17. while (( "$#" ))
  18. do
  19. if [[ "$1" == "--tool" ]]
  20. then
  21. tool="$2"
  22. shift
  23. elif [[ "$1" =~ --tool=(.*) ]]
  24. then
  25. tool="${BASH_REMATCH[1]}"
  26. fi
  27. shift
  28. done
  29. NEEDS_VALGRIND=0
  30. NEEDS_DRMEMORY=0
  31. case "$tool" in
  32. "memcheck")
  33. NEEDS_VALGRIND=1
  34. ;;
  35. "drmemory" | "drmemory_light" | "drmemory_full" | "drmemory_pattern")
  36. NEEDS_DRMEMORY=1
  37. ;;
  38. esac
  39. if [ "$NEEDS_VALGRIND" == "1" ]
  40. then
  41. export CHROME_VALGRIND=`sh $THISDIR/locate_valgrind.sh`
  42. if [ "$CHROME_VALGRIND" = "" ]
  43. then
  44. # locate_valgrind.sh failed
  45. exit 1
  46. fi
  47. echo "Using valgrind binaries from ${CHROME_VALGRIND}"
  48. PATH="${CHROME_VALGRIND}/bin:$PATH"
  49. # We need to set these variables to override default lib paths hard-coded into
  50. # Valgrind binary.
  51. export VALGRIND_LIB="$CHROME_VALGRIND/lib/valgrind"
  52. export VALGRIND_LIB_INNER="$CHROME_VALGRIND/lib/valgrind"
  53. # Clean up some /tmp directories that might be stale due to interrupted
  54. # chrome_tests.py execution.
  55. # FYI:
  56. # -mtime +1 <- only print files modified more than 24h ago,
  57. # -print0/-0 are needed to handle possible newlines in the filenames.
  58. echo "Cleanup /tmp from Valgrind stuff"
  59. find /tmp -maxdepth 1 \(\
  60. -name "vgdb-pipe-*" -or -name "vg_logs_*" -or -name "valgrind.*" \
  61. \) -mtime +1 -print0 | xargs -0 rm -rf
  62. fi
  63. if [ "$NEEDS_DRMEMORY" == "1" ]
  64. then
  65. if [ -z "$DRMEMORY_COMMAND" ]
  66. then
  67. DRMEMORY_PATH="$THISDIR/../../third_party/drmemory"
  68. DRMEMORY_SFX="$DRMEMORY_PATH/drmemory-windows-sfx.exe"
  69. if [ ! -f "$DRMEMORY_SFX" ]
  70. then
  71. echo "Can't find Dr. Memory executables."
  72. echo "See http://www.chromium.org/developers/how-tos/using-valgrind/dr-memory"
  73. echo "for the instructions on how to get them."
  74. exit 1
  75. fi
  76. chmod +x "$DRMEMORY_SFX" # Cygwin won't run it without +x.
  77. "$DRMEMORY_SFX" -o"$DRMEMORY_PATH/unpacked" -y
  78. export DRMEMORY_COMMAND="$DRMEMORY_PATH/unpacked/bin/drmemory.exe"
  79. fi
  80. fi
  81. PYTHONPATH=$THISDIR/../python/google python \
  82. "$THISDIR/chrome_tests.py" $ARGV_COPY