Add support for --target flag to webrtc_tests.py.

In https://codereview.chromium.org/26190002 Chromium
started a cleanup of their wrapper script, by adding
the --target flag and start passing build dir similar
to how the bots are setting it (i.e. pass out and not
out/Release).
This CL adds --target support for our wrapper script,
without changing the existing behavior (I'll do a
larger update at a later stage).

BUG=none
TEST=Ran the following successfully:
tools/valgrind-webrtc/webrtc_tests.sh --build_dir out/Release --target Release --test test_support_unittests
tools/valgrind-webrtc/webrtc_tests.sh --build_dir out --target Release --test test_support_unittests
tools/valgrind-webrtc/webrtc_tests.sh --target Release --test  out/Release/test_support_unittests
TBR=phoglund@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/2396004

git-svn-id: http://webrtc.googlecode.com/svn/trunk@4957 4adac7df-926f-26a2-2b94-8c16560cd09d
diff --git a/tools/valgrind-webrtc/webrtc_tests.py b/tools/valgrind-webrtc/webrtc_tests.py
index 288dbf4..2c2eeed 100755
--- a/tools/valgrind-webrtc/webrtc_tests.py
+++ b/tools/valgrind-webrtc/webrtc_tests.py
@@ -93,6 +93,7 @@
   parser.add_option('-b', '--build_dir',
                     help=('Location of the compiler output. Can only be used '
                           'when the test argument does not contain this path.'))
+  parser.add_option("--target", help="Debug or Release")
   parser.add_option('-t', '--test', help='Test to run.')
   parser.add_option('', '--baseline', action='store_true', default=False,
                     help='Generate baseline data instead of validating')
@@ -121,6 +122,11 @@
   if not options.test:
     parser.error('--test not specified')
 
+  # Support build dir both with and without the target.
+  if (options.target and options.build_dir and
+      not options.build_dir.endswith(options.target)):
+    options.build_dir = os.path.join(options.build_dir, options.target)
+
   # If --build_dir is provided, prepend it to the test executable if needed.
   test_executable = options.test
   if options.build_dir and not test_executable.startswith(options.build_dir):