File: run_tests

package info (click to toggle)
python-nss 0.15.0-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 1,452 kB
  • ctags: 1,755
  • sloc: ansic: 27,607; python: 2,688; makefile: 2
file content (79 lines) | stat: -rwxr-xr-x 2,458 bytes parent folder | download
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
#!/usr/bin/python

import argparse
import os
import sys
import unittest
from util import get_build_dir

#-------------------------------------------------------------------------------

def run_tests():

    import setup_certs
    import test_cert_components
    import test_cipher
    import test_digest
    import test_pkcs12
    import test_misc
    import test_ocsp
    import test_cert_request
    import test_client_server

    setup_certs.setup_certs([])

    loader = unittest.TestLoader()
    runner = unittest.TextTestRunner()

    suite  = loader.loadTestsFromModule(test_cert_components)
    suite.addTests(loader.loadTestsFromModule(test_cipher))
    suite.addTests(loader.loadTestsFromModule(test_digest))
    suite.addTests(loader.loadTestsFromModule(test_pkcs12))
    suite.addTests(loader.loadTestsFromModule(test_misc))
    suite.addTests(loader.loadTestsFromModule(test_ocsp))
    suite.addTests(loader.loadTestsFromModule(test_cert_request))
    suite.addTests(loader.loadTestsFromModule(test_client_server))

    result = runner.run(suite)
    return len(result.failures)

#-------------------------------------------------------------------------------

def main():
    parser = argparse.ArgumentParser(description='run the units (installed or in tree)')
    parser.add_argument('-i', '--installed', action='store_false', dest='in_tree',
                        help='run tests using installed library')
    parser.add_argument('-t', '--in-tree', action='store_true', dest='in_tree',
                        help='run tests using devel tree')

    parser.set_defaults(in_tree = False,
                        )

    options = parser.parse_args()

    if options.in_tree:
        # Run the tests "in the tree"
        # Rather than testing with installed versions run the test
        # with the package built in this tree.

        build_dir = get_build_dir()
        if build_dir and os.path.exists(build_dir):
            print "Using local libraries from tree, located here:\n%s\n" % build_dir
            sys.path.insert(0, build_dir)
        else:
            print >>sys.stderr, "ERROR: Unable to locate in tree libraries"
            return 2
    else:
        print "Using installed libraries"

    num_failures = run_tests()

    if num_failures == 0:
        return 0
    else:
        return 1

#-------------------------------------------------------------------------------

if __name__ == '__main__':
    sys.exit(main())