r26088: Import some native-python python modules and move original python swig tortur...
[gd/samba-autobuild/.git] / source4 / scripting / python / samba / torture / pytorture
1 #!/usr/bin/python
2
3 import sys
4 from optparse import OptionParser
5
6 # Parse command line
7
8 parser = OptionParser()
9
10 parser.add_option("-b", "--binding", action="store", type="string",
11                   dest="binding")
12
13 parser.add_option("-d", "--domain", action="store", type="string",
14                   dest="domain")
15
16 parser.add_option("-u", "--username", action="store", type="string",
17                   dest="username")
18
19 parser.add_option("-p", "--password", action="store", type="string",
20                   dest="password")
21
22 (options, args) = parser.parse_args()
23
24 if not options.binding:
25    parser.error('You must supply a binding string')
26
27 if not options.username or not options.password or not options.domain:
28    parser.error('You must supply a domain, username and password')
29
30 binding = options.binding
31 domain = options.domain
32 username = options.username
33 password = options.password
34
35 if len(args) == 0:
36    parser.error('You must supply the name of a module to test')
37
38 # Import and test
39
40 for test in args:
41
42    try:
43       module = __import__('torture_%s' % test)
44    except ImportError:
45       print 'No such module "%s"' % test
46       sys.exit(1)
47
48    if not hasattr(module, 'runtests'):
49       print 'Module "%s" does not have a runtests function' % test
50
51    module.runtests(binding, (domain, username, password))