def testFindSuiteSyntaxErrors(self):
        """Check all control files for syntax errors.

        This test actually parses all control files in the autotest directory
        for syntax errors, by using the un-forgiving parser and pretending to
        look for all control files with the suite attribute.
        """
        autodir = os.path.abspath(
            os.path.join(os.path.dirname(__file__), '..', '..', '..'))
        fs_getter = Suite.create_fs_getter(autodir)
        predicate = lambda t: hasattr(t, 'suite')
        Suite.find_and_parse_tests(fs_getter,
                                   predicate,
                                   add_experimental=True,
                                   forgiving_parser=False)
def main(argv):
    """main scripts to seed attributes in test control files.

  Args:
    @param argv: Command line arguments including `sys.argv[0]`.
  """
    # Parse execution cmd
    parser = argparse.ArgumentParser(
        description='Seed ATTRIBUTES in test control files.')
    parser.add_argument('--execute',
                        action='store_true',
                        default=False,
                        help='Execute the script to seed attributes in all '
                        'test control files.')
    args = parser.parse_args(argv)

    # When execute is True, run the script to seed attributes in control files.
    if args.execute:
        # Get the whitelist path, hardcode the path currently
        path_whitelist = os.path.join(common.autotest_dir,
                                      'site_utils/attribute_whitelist.txt')

        # Go through all control file, check whether attribute matches suite. Return
        # a changelist which contains the paths to the control files not match.
        fs_getter = Suite.create_fs_getter(common.autotest_dir)
        changelist = AttrSuiteMatch(fs_getter.get_control_file_list(),
                                    path_whitelist)
        count = len(changelist)

        logging.info('Starting to seed attributes in %d control files...' %
                     count)
        # Modify attributes based on suite for the control files not match.
        for path in changelist:
            logging.info('Seeding ATTRIBUTES in %s' % path)
            count = count - 1
            logging.info('%d files remaining...' % count)
            SeedAttributes(path)

        logging.info('Finished seeding attributes.')

    # When not specify 'execute' in cmd, not modify control files.
    else:
        logging.info(
            'No files are modified. To seed attributes in control files, '
            'please add \'--execute\' argument when run the script.')
def main():
    """main script."""
    # Parse filepath from cmd line.
    parser = argparse.ArgumentParser(description='Create attribute whitelist.')
    parser.add_argument('path',
                        metavar='WHITELIST_FILE_PATH',
                        help='Path to the file whitelist is written to. E.g. '
                        './attribute_whitelist.txt')
    args = parser.parse_args()

    # Get all the suites from current test control files, and order them.
    fs_getter = Suite.create_fs_getter(common.autotest_dir)
    devserver = dev_server.ImageServer('')
    suite_list = Suite.list_all_suites('', devserver, fs_getter)
    suite_list.sort(key=str.lower)

    # Parse attributes from suites, and write to a file
    whitelist = ['suite:' + x for x in suite_list]
    _WriteToFile(whitelist, args.path)
def main():
    """Entry point to run the suite enumerator command."""
    parser, options, args = parse_options()
    if options.listall:
        if args:
            print 'Cannot use suite_name with --listall'
            parser.print_help()
    elif not args or len(args) != 1:
        parser.print_help()
        return

    fs_getter = Suite.create_fs_getter(options.autotest_dir)
    devserver = dev_server.ImageServer('')
    if options.listall:
        for suite in Suite.list_all_suites('', devserver, fs_getter):
            print suite
        return

    suite = Suite.create_from_name(args[0], {}, '', devserver, fs_getter)
    # If in test list, print firmware_FAFTSetup before other tests
    # NOTE: the test.name value can be *different* from the directory
    # name that appears in test.path
    PRETEST_LIST = [
        'firmware_FAFTSetup',
    ]
    for test in filter(lambda test: test.name in \
                              PRETEST_LIST, suite.stable_tests()):
        print test.path
    for test in filter(lambda test: test.name not in \
                       PRETEST_LIST, suite.stable_tests()):
        print test.path

    # Check if test_suites/control.suite_name exists.
    control_path = os.path.join(options.autotest_dir, 'test_suites',
                                'control.' + args[0])
    if not os.path.exists(control_path):
        print >> sys.stderr, ('Warning! control file is missing: %s' %
                              control_path)