Use "board" directory instead of ugly custom->suite_Factory symlink.

BUG=None
CQ-DEPEND=CL:40138,CL:*30449
TEST=buildbot

Change-Id: I8645cbc9b80aca1215544bc6cec033612cddd5d3
Reviewed-on: https://gerrit.chromium.org/gerrit/40138
Reviewed-by: Cheng-Yi Chiang <cychiang@chromium.org>
Tested-by: Jon Salz <jsalz@chromium.org>
Commit-Queue: Jon Salz <jsalz@chromium.org>
diff --git a/py/goofy/goofy.py b/py/goofy/goofy.py
index c5fc57b..9876737 100755
--- a/py/goofy/goofy.py
+++ b/py/goofy/goofy.py
@@ -96,7 +96,14 @@
   '''
   hwid_cfg = get_hwid_cfg()
 
-  search_dirs = [CUSTOM_DIR, DEFAULT_TEST_LISTS_DIR]
+  search_dirs = [DEFAULT_TEST_LISTS_DIR]
+  if not utils.in_chroot():
+    # Also look in suite_Factory.  For backward compatibility only;
+    # new boards should just put the test list in the "test_lists"
+    # directory.
+    search_dirs.insert(0, os.path.join(
+        os.path.dirname(factory.FACTORY_PATH),
+        'autotest', 'site_tests', 'suite_Factory'))
 
   # Try in order: test_list_${hwid_cfg}, test_list, test_list.all
   search_files = ['test_list', 'test_list.all']
diff --git a/py/goofy/goofy_remote.py b/py/goofy/goofy_remote.py
index 43c9619..fd726b1 100755
--- a/py/goofy/goofy_remote.py
+++ b/py/goofy/goofy_remote.py
@@ -37,17 +37,22 @@
   board = match.group(1)
 
   if test_list is None:
-    logging.info('Copying test_list from %s overlay', board)
+    test_list_globs = []
+    for x in [['chromeos-factory-board', 'files', 'test_lists',
+               'test_list'],
+              ['autotest-private-board', 'files', 'test_list']]:
+      test_list_globs.append(
+        os.path.join(
+            os.environ['CROS_WORKON_SRCROOT'], 'src',
+            '*-overlays', 'overlay-%s-*' % board,
+            'chromeos-base', *x))
 
-    test_list_glob = os.path.join(
-        os.environ['CROS_WORKON_SRCROOT'], 'src',
-        '*-overlays', 'overlay-%s-*' % board,
-        'chromeos-base', 'autotest-private-board', 'files', 'test_list')
-    test_lists = glob.glob(test_list_glob)
+    test_lists = sum([glob.glob(x) for x in test_list_globs], [])
     if not test_lists:
-      logging.warn('Unable to find test list %s', test_list_glob)
+      logging.warn('Unable to find test list %s', test_list_globs)
       return
     test_list = test_lists[0]
+    logging.info('Using test list %s', test_list)
 
   if clear_factory_environment:
     test_list_data = open(test_list).read().replace(
@@ -57,8 +62,12 @@
     tmp_test_list.write(test_list_data)
     test_list = tmp_test_list.name
 
+  test_list_dir = (
+      'custom' if 'autotest-private-board' in test_list
+      else 'test_lists')
+
   Spawn(rsync_command +
-        [test_list, host + ':/usr/local/factory/custom/test_list'],
+        [test_list, host + ':/usr/local/factory/%s/test_list' % test_list_dir],
         check_call=True, log=True)
 
   return board