diff --git a/tools/valgrind-libyuv/libyuv_tests.py b/tools/valgrind-libyuv/libyuv_tests.py
index f93e97bb7..1b912b8ba 100755
--- a/tools/valgrind-libyuv/libyuv_tests.py
+++ b/tools/valgrind-libyuv/libyuv_tests.py
@@ -73,9 +73,10 @@ class LibyuvTest(chrome_tests.ChromeTests):
def main(_):
parser = optparse.OptionParser('usage: %prog -b
-t ')
parser.disable_interspersed_args()
- parser.add_option('-b', '--build_dir',
+ 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')
@@ -104,6 +105,11 @@ def main(_):
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):