This file is indexed.

/usr/share/checkbox/scripts/mago_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
#!/usr/bin/python

import os
import sys
import posixpath

from subprocess import Popen

from optparse import OptionParser


DEFAULT_DIRECTORY = "/tmp/checkbox.mago"
DEFAULT_LOCATION = "http://bazaar.launchpad.net/%7Emago-contributors/mago/mago"
DEFAULT_TIMEOUT = 300

COMMAND_TEMPLATE = "mago --log-level=debug -n '%(suite)s' 2>&1 >/dev/null | awk '/xsltproc/ {print $NF}' | xargs -r mago_filter"


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.items():
        print_line(key, value)

    print

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

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

    process = Popen(["bzr", "branch", location, directory])
    if process.wait():
        raise Exception, "Failed to branch mago from %s" % location

def run_mago(location, directory, timeout=None):
    branch_mago(location, directory)

    sys.path.insert(0, directory)
    from mago.cmd.discovery import discover_applications

    elements = []
    for application in discover_applications([directory], [], [], [], []):
        for suite in application.suites():
            element = {}
            element["plugin"] = "remote"
            element["depends"] = "mago"
            element["timeout"] = timeout
            element["name"] = suite.name
            element["description"] = suite.description.strip()
            element["command"] = COMMAND_TEMPLATE % {"suite": suite.name}
            element["environ"] = [
                "PATH=%s:$PATH" % posixpath.join(directory, "bin"),
                "PYTHONPATH=%s:$PYTHONPATH" % directory,
                "MAGO_SHARE=%s" % directory]

            elements.append(element)

    return elements

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

    suites = run_mago(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:]))