Esempio n. 1
0
def get_tests_from_fs(parent_dir, control_pattern, add_noncompliant=False):
    """
    Find control files in file system and load a list with their info.

    :param parent_dir: directory to search recursively.
    :param control_pattern: name format of control file.
    :param add_noncompliant: ignore control file parse errors.

    :return: dictionary of the form: tests[file_path] = parsed_object
    """
    tests = {}
    profilers = False
    if "client/profilers" in parent_dir:
        profilers = True
    for dir in [parent_dir]:
        files = recursive_walk(dir, control_pattern)
        for file in files:
            if "__init__.py" in file or ".svn" in file:
                continue
            if not profilers:
                if not add_noncompliant:
                    try:
                        found_test = control_data.parse_control(file, raise_warnings=True)
                        tests[file] = found_test
                    except control_data.ControlVariableException, e:
                        logging.warn("Skipping %s\n%s", file, e)
                    except Exception, e:
                        logging.error("Bad %s\n%s", file, e)
                else:
                    found_test = control_data.parse_control(file)
                    tests[file] = found_test
            else:
                tests[file] = compiler.parseFile(file).doc
Esempio n. 2
0
def get_tests_from_fs(parent_dir, control_pattern, add_noncompliant=False):
    """
    Find control files in file system and load a list with their info.

    :param parent_dir: directory to search recursively.
    :param control_pattern: name format of control file.
    :param add_noncompliant: ignore control file parse errors.

    :return: dictionary of the form: tests[file_path] = parsed_object
    """
    tests = {}
    profilers = False
    if 'client/profilers' in parent_dir:
        profilers = True
    for dir in [parent_dir]:
        files = recursive_walk(dir, control_pattern)
        for file in files:
            if '__init__.py' in file or '.svn' in file:
                continue
            if not profilers:
                if not add_noncompliant:
                    try:
                        found_test = control_data.parse_control(
                            file, raise_warnings=True)
                        tests[file] = found_test
                    except control_data.ControlVariableException as e:
                        logging.warn("Skipping %s\n%s", file, e)
                    except Exception as e:
                        logging.error("Bad %s\n%s", file, e)
                else:
                    found_test = control_data.parse_control(file)
                    tests[file] = found_test
            else:
                tests[file] = compiler.parseFile(file).doc
    return tests
Esempio n. 3
0
def update_from_whitelist(whitelist_set, add_experimental, add_noncompliant,
                          autotest_dir):
    """
    Scans through all tests in the whitelist and add them to the database.

    This function invoked when -w supplied.

    :param whitelist_set: set of tests in full-path form from a whitelist.
    :param add_experimental: add tests with experimental attribute set.
    :param add_noncompliant: attempt adding test with invalid control files.
    :param autotest_dir: prepended to path strings
            (see global_config.ini, COMMON, autotest_top_path).
    """
    tests = {}
    profilers = {}
    for file_path in whitelist_set:
        if file_path.find('client/profilers') == -1:
            try:
                found_test = control_data.parse_control(file_path,
                                                        raise_warnings=True)
                tests[file_path] = found_test
            except control_data.ControlVariableException, e:
                logging.warn("Skipping %s\n%s", file, e)
        else:
            profilers[file_path] = compiler.parseFile(file_path).doc
Esempio n. 4
0
def update_from_whitelist(whitelist_set, add_experimental, add_noncompliant,
                          autotest_dir):
    """
    Scans through all tests in the whitelist and add them to the database.

    This function invoked when -w supplied.

    :param whitelist_set: set of tests in full-path form from a whitelist.
    :param add_experimental: add tests with experimental attribute set.
    :param add_noncompliant: attempt adding test with invalid control files.
    :param autotest_dir: prepended to path strings
            (see global_config.ini, COMMON, autotest_top_path).
    """
    tests = {}
    profilers = {}
    for file_path in whitelist_set:
        if file_path.find('client/profilers') == -1:
            try:
                found_test = control_data.parse_control(file_path,
                                                        raise_warnings=True)
                tests[file_path] = found_test
            except control_data.ControlVariableException as e:
                logging.warn("Skipping %s\n%s", file, e)
        else:
            profilers[file_path] = compiler.parseFile(file_path).doc

    if len(tests) > 0:
        update_tests_in_db(tests,
                           add_experimental=add_experimental,
                           add_noncompliant=add_noncompliant,
                           autotest_dir=autotest_dir)
    if len(profilers) > 0:
        update_profilers_in_db(profilers,
                               add_noncompliant=add_noncompliant,
                               description='NA')
 def test_parse_control(self):
     cd = control_data.parse_control(self.control_tmp.name, True)
     self.assertEquals(cd.author, "Author")
     self.assertEquals(cd.dependencies, set(['console', 'power']))
     self.assertEquals(cd.doc, "doc stuff")
     self.assertEquals(cd.experimental, False)
     self.assertEquals(cd.name, "nAmE")
     self.assertEquals(cd.run_verify, False)
     self.assertEquals(cd.sync_count, 2)
     self.assertEquals(cd.time, "short")
     self.assertEquals(cd.test_class, "kernel")
     self.assertEquals(cd.test_category, "stress")
     self.assertEquals(cd.test_type, "client")
 def test_parse_control(self):
     cd = control_data.parse_control(self.control_tmp.name, True)
     self.assertEquals(cd.author, "Author")
     self.assertEquals(cd.dependencies, set(['console', 'power']))
     self.assertEquals(cd.doc, "doc stuff")
     self.assertEquals(cd.experimental, False)
     self.assertEquals(cd.name, "nAmE")
     self.assertEquals(cd.run_verify, False)
     self.assertEquals(cd.sync_count, 2)
     self.assertEquals(cd.time, "short")
     self.assertEquals(cd.test_class, "kernel")
     self.assertEquals(cd.test_category, "stress")
     self.assertEquals(cd.test_type, "client")
try:
    import autotest.common as common
except ImportError:
    import common
from autotest.client.shared import control_data

if len(sys.argv) != 2:
    print "Usage %s <control file>" % os.path.basename(sys.argv[0])
    sys.exit(1)

if not os.path.exists(sys.argv[1]):
    print "File %s does not exist" % sys.argv[1]
    sys.exit(1)

try:
    cd = control_data.parse_control(sys.argv[1], True)
except Exception, e:
    print "This control file does not adhear to the spec set forth in"
    print "https://github.com/autotest/autotest/wiki/ControlRequirements"
    print
    print "Specific error:"
    print '\n'.join(textwrap.wrap(str(e), initial_indent='    ',
                                  subsequent_indent='    '))
    sys.exit(1)

if cd.experimental:
    print textwrap.wrap("WARNING: This file is marked experimental.  It will "
                        "not show up on the autotest frontend unless "
                        "experimental is set to False.")
    sys.exit(0)
try:
    import autotest.common as common  # pylint: disable=W0611
except ImportError:
    import common  # pylint: disable=W0611
from autotest.client.shared import control_data

if len(sys.argv) != 2:
    print "Usage %s <control file>" % os.path.basename(sys.argv[0])
    sys.exit(1)

if not os.path.exists(sys.argv[1]):
    print "File %s does not exist" % sys.argv[1]
    sys.exit(1)

try:
    cd = control_data.parse_control(sys.argv[1], True)
except Exception as e:
    print "This control file does not adhear to the spec set forth in"
    print "https://github.com/autotest/autotest/wiki/ControlRequirements"
    print
    print "Specific error:"
    print '\n'.join(
        textwrap.wrap(str(e), initial_indent='    ', subsequent_indent='    '))
    sys.exit(1)

if cd.experimental:
    print textwrap.wrap("WARNING: This file is marked experimental.  It will "
                        "not show up on the autotest frontend unless "
                        "experimental is set to False.")
    sys.exit(0)