selftest: Run krb5.kdc with an account that has a UPN and an SPN
[Samba.git] / script / show_test_time
blobf3ea56ef1ecfa970214ada4676e04124a24d055b
1 #!/usr/bin/python
3 import optparse
4 import os.path
5 import subprocess
6 import sys
8 parser = optparse.OptionParser()
9 parser.add_option("--limit", dest="limit", type=int,
10 help="Limit to this number of output entries.", default=0)
11 (opts, args) = parser.parse_args()
13 third_party_path = os.path.join(os.path.dirname(sys.argv[0]), "..", "lib")
14 subunit_prefix = "PYTHONPATH="+ ":".join([
15 os.path.join(third_party_path, "testtools"),
16 os.path.join(third_party_path, "mimeparse"),
17 os.path.join(third_party_path, "extras"),
18 os.path.join(third_party_path, "subunit/python")]) + (
19 " " + os.path.join(third_party_path, "subunit"))
21 durations = {}
23 cmd = (os.path.join(subunit_prefix, "filters/subunit-1to2") + " | " +
24 os.path.join(subunit_prefix, "filters/subunit-ls") + " --times --no-passthrough")
26 p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stdin=sys.stdin, shell=True)
27 for l in p.stdout:
28 l = l.strip()
29 (name, duration) = l.rsplit(" ", 1)
30 durations[name] = float(duration)
32 if opts.limit:
33 print "Top %d tests by run time:" % opts.limit
35 for i, (name, length) in enumerate(sorted(
36 durations.items(), cmp=lambda (k1,v1), (k2, v2): cmp(v1, v2), reverse=True)):
37 if opts.limit and i == opts.limit:
38 break
39 print "%d: %s -> %ds" % (i+1, name, length)