MAN: Adding entry for net ads lookup
[nivanova/samba-autobuild/.git] / source4 / scripting / bin / gen_output.py
1 #!/usr/bin/env python
2
3 # Copyright (C) Catalyst IT Ltd. 2017
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
18 """
19 A data generator to help tests.
20
21 Generate large output to stdout by repeating input data.
22 Usage:
23
24     python gen_output.py --data @ --repeat 1024 --retcode 1
25
26 The above command will output @ x 1024 (1K) and exit with 1.
27 """
28
29 import sys
30 import argparse
31
32 parser = argparse.ArgumentParser(description='Generate output data')
33
34 parser.add_argument(
35     '--data', type=str, default='$',
36     help='Characters used to generate data by repeating them'
37 )
38
39 parser.add_argument(
40     '--repeat', type=int, default=1024 * 1024,
41     help='How many times to repeat the data'
42 )
43
44 parser.add_argument(
45     '--retcode', type=int, default=0,
46     help='Specify the exit code for this script'
47 )
48
49 args = parser.parse_args()
50
51 sys.stdout.write(args.data * args.repeat)
52
53 sys.exit(args.retcode)