This file is indexed.

/usr/share/checkbox/scripts/autotest_suite is in checkbox 0.13.7.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#!/usr/bin/python

import os
import sys
import logging
import posixpath

from optparse import OptionParser
from urlparse import urlparse


DEFAULT_DIRECTORY = "/var/cache/checkbox/autotest"
DEFAULT_LOCATION = "http://test.kernel.org/svn/autotest/trunk/client/"
DEFAULT_TIMEOUT = 900

COMMAND_TEMPLATE = "%(directory)s/bin/autotest %(directory)s/tests/%(test)s/control 2>/dev/null | autotest_filter --suite=autotest"


def print_line(key, value):
    if type(value) is list:
        print "%s:" % key
        for v in value:
            print " %s" % v
    else:
        print "%s: %s" % (key, value)

def print_element(element):
    for key, value in element.iteritems():
        print_line(key, value)

    print

def fetch_autotest(location, directory):
    if posixpath.exists(directory):
        return

    dirname = posixpath.dirname(directory)
    if not posixpath.exists(dirname):
        os.makedirs(dirname)

    autotest_path = urlparse(location)[2]
    cut_dirs = len(autotest_path.strip(posixpath.sep).split(posixpath.sep))

    command = "wget -q -e robots=off -R index.html -np -nH --cut-dirs=%d -P %s -r %s" \
        % (cut_dirs, directory, location)
    logging.info("Running command: %s" % command)
    if os.system(command) != 0:
        raise Exception, "Failed to run command: %s" % command

    # Change mode of binary files
    directories = [posixpath.join(directory, d)
        for d in "bin", "common_lib", "deps", "profilers",
                 "samples", "tests", "tools"]
    while directories:
        directory = directories.pop()
        for name in os.listdir(directory):
            path = posixpath.join(directory, name)
            if posixpath.isfile(path) \
               and name is not "control":
                os.chmod(path, 0755)
            elif posixpath.isdir(path):
                directories.append(path)

def list_autotest(location, directory):
    fetch_autotest(location, directory)

    directory = posixpath.join(directory, "tests")
    return os.listdir(directory)

def run_autotest(names, location, directory, timeout=None):
    fetch_autotest(location, directory)

    for name in names:
        path = posixpath.join(directory, "tests", name)

        # Initialize test structure
        test = {}
        test["plugin"] = "remote"
        test["depends"] = "autotest"
        test["timeout"] = timeout
        test["name"] = name
        test["user"] = "root"
        test["command"] = COMMAND_TEMPLATE % {
            "directory": directory,
            "test": name}

        yield test

def main(args):
    usage = "Usage: %prog [OPTIONS] [NAMES]"
    parser = OptionParser(usage=usage)
    parser.add_option("-d", "--directory",
        default=DEFAULT_DIRECTORY,
        help="Directory where to branch autotest")
    parser.add_option("-l", "--location",
        default=DEFAULT_LOCATION,
        help="Location from where to checkout autotest")
    parser.add_option("-t", "--timeout",
        default=DEFAULT_TIMEOUT,
        type="int",
        help="Timeout when running autotest")
    (options, names) = parser.parse_args(args)

    if not names:
        names = list_autotest(options.location, options.directory)

    suites = run_autotest(names, options.location, options.directory, options.timeout)
    if not suites:
        return 1

    for suite in suites:
        print_element(suite)

    return 0


if __name__ == "__main__":
    sys.exit(main(sys.argv[1:]))