[autotest] Verify that suite control files exist in sanity check.
If someone adds a suite to suite_scheduler, it should probably actually
exist. This is pretty easy to check just by looking at the autotest
directory, so let's make sure someone doesn't accidentally upload a
silly CL.
BUG=chromium:220432
TEST=Ran, no output, and return value 0
Modified suite_scheduler.ini to have an invalid suite name, ran sanity
check, and the sanity check failed and printed out the invalid suite
name.
Change-Id: I2bbfb4e0563525a32523167d86a6fbb8a773ac98
Reviewed-on: https://gerrit.chromium.org/gerrit/65159
Reviewed-by: Prashanth Balasubramanian <beeps@chromium.org>
Commit-Queue: Alex Miller <milleral@chromium.org>
Tested-by: Alex Miller <milleral@chromium.org>
diff --git a/site_utils/suite_scheduler/sanity.py b/site_utils/suite_scheduler/sanity.py
index 5646a90..1c37292 100644
--- a/site_utils/suite_scheduler/sanity.py
+++ b/site_utils/suite_scheduler/sanity.py
@@ -5,6 +5,7 @@
import collections
import logging
+import os
import common
from autotest_lib.client.common_lib import global_config
@@ -85,3 +86,27 @@
logging.warn("Increase %s to |num: %d|", c[0], c[1])
return 1 if corrections else 0
+
+
+def CheckControlFileExistance(tasks):
+ """
+ Make sure that for any task that schedules a suite, that
+ test_suites/control.<suite> exists. this prevents people from accidentally
+ adding a suite to suite_scheduler.ini but not adding an actual suite
+ control file, thus resulting in their suite not running and the lab team
+ getting lots of email
+
+ @param tasks The list of tasks to check.
+ @return 0 if no missing control files are found
+ 1 if there are at least one missing control files
+ """
+ corrections = False
+
+ for task in tasks:
+ suite_path = os.path.join(common.autotest_dir,
+ 'test_suites', 'control.'+task.suite)
+ if not os.path.exists(suite_path):
+ corrections = True
+ logging.warn("No suite control file for %s", task.suite)
+
+ return 1 if corrections else 0