[autotest] Testing mode for autoserv.

To be able to do better load testing it's useful if autoserv has the
functionality to just simulate it would run tests on DUTs.

With this autoserv will sleep for 10 seconds and will then return
like after a successful test.

BUG=None
TEST=Ran suites.

Change-Id: I9b1527054d494ee356e8951561cf6a426e30cd14
Reviewed-on: https://chromium-review.googlesource.com/219638
Reviewed-by: Prashanth B <beeps@chromium.org>
Commit-Queue: Jakob Jülich <jakobjuelich@chromium.org>
Tested-by: Jakob Jülich <jakobjuelich@chromium.org>
diff --git a/server/autoserv b/server/autoserv
index fa682bb..1424adc 100755
--- a/server/autoserv
+++ b/server/autoserv
@@ -16,6 +16,10 @@
         'AUTOSERV', 'require_atfork_module', type=bool, default=True)
 
 
+# Number of seconds to wait before returning if testing mode is enabled
+TESTING_MODE_SLEEP_SECS = 10
+
+
 try:
     import atfork
     atfork.monkeypatch_os_fork_functions()
@@ -310,7 +314,12 @@
     exit_code = 0
     try:
         try:
-            run_autoserv(pid_file_manager, results, parser)
+            if not global_config.global_config.get_config_value(
+                        'AUTOSERV', 'testing_mode', type=bool, default=False):
+                run_autoserv(pid_file_manager, results, parser)
+            else:
+                # TODO(beeps): Extend this to cover different failure modes.
+                time.sleep(TESTING_MODE_SLEEP_SECS)
         except SystemExit as e:
             exit_code = e.code
             if exit_code: