• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5
6import logging
7import os
8
9import common
10
11
12_WHITELISTED_SUITES = (
13    'arc-cts',
14    'arc-cts-perbuild',
15    'arc-cts-dev',
16    'arc-cts-beta',
17    'arc-cts-stable',
18    'arc-gts',
19    'arc-gts-perbuild',
20    'arc-gts-tot',
21    'arc-nightly',
22    'arc-weekly',
23    'crosbolt_arc_perf',
24    'crosbolt_arc_perf_nightly',
25    'crosbolt_arc_perf_perbuild',
26)
27
28def CheckControlFileExistence(tasks):
29    """
30    Make sure that for any task that schedules a suite, that
31    test_suites/control.<suite> exists. this prevents people from accidentally
32    adding a suite to suite_scheduler.ini but not adding an actual suite
33    control file, thus resulting in their suite not running and the lab team
34    getting lots of email
35
36    @param tasks The list of tasks to check.
37    @return 0 if no missing control files are found
38            1 if there are at least one missing control files
39    """
40    corrections = False
41
42    for task in tasks:
43        suite_path = os.path.join(common.autotest_dir,
44                                  'test_suites', 'control.'+task.suite)
45        if task.suite in _WHITELISTED_SUITES:
46            continue
47        if not os.path.exists(suite_path):
48            corrections = True
49            logging.warning("No suite control file for %s", task.suite)
50
51    return 1 if corrections else 0
52