Make audiofuntest's success rate threshold an argument

The threshold was previously hard coded to 50, which is not flexible and
pretty easy to pass. Make it an argument so we can easily adjust it in
the future.

BUG=chrome-os-partner:27853
TEST=Manually tested, the test won't pass after covering with tape on
    the mic

Change-Id: Ib7f961c44aedd83f784321fd91fa530b89ebb3d5
Reviewed-on: https://chromium-review.googlesource.com/195397
Reviewed-by: Cheng-Yi Chiang <cychiang@chromium.org>
Commit-Queue: Mao Huang <littlecvr@chromium.org>
Tested-by: Mao Huang <littlecvr@chromium.org>
diff --git a/py/test/pytests/audio_loop/audio_loop.py b/py/test/pytests/audio_loop/audio_loop.py
index 90dc33d..8b0a212 100644
--- a/py/test/pytests/audio_loop/audio_loop.py
+++ b/py/test/pytests/audio_loop/audio_loop.py
@@ -49,9 +49,6 @@
 _DEFAULT_FREQ_THRESHOLD_HZ = 50
 _DEFAULT_SINE_DURATION_SEC = 1
 
-# Pass threshold for audiofuntest
-_AUDIOFUNTEST_THRESHOLD = 50.0
-
 # Regular expressions to match audiofuntest message.
 _AUDIOFUNTEST_STOP_RE = re.compile('^Stop')
 _AUDIOFUNTEST_SUCCESS_RATE_RE = re.compile('.*rate\s*=\s*(.*)$')
@@ -90,6 +87,8 @@
     Arg('autostart', bool, 'Auto start option', False),
     Arg('require_dongle', bool, 'Require dongle option', False),
     Arg('enable_audiofun', bool, 'Enable audio function test'),
+    Arg('audiofun_threshold', int, 'Minimum success rate to pass the test',
+        default=50),
     Arg('check_dongle', bool,
         'Check dongle status whether match require_dongle', False),
     # Only used for speaker and dmic
@@ -194,7 +193,7 @@
 
         m = _AUDIOFUNTEST_STOP_RE.match(proc_output)
         if m is not None:
-          test_result = (last_success_rate > _AUDIOFUNTEST_THRESHOLD)
+          test_result = (last_success_rate > self.args.audiofun_threshold)
           break
 
       # Show instant message and wait for a while