talloc_stack: Call talloc destructors while frame is still around
[Samba.git] / source4 / scripting / bin / gen_output.py
blob8dc1d6aff24e9d456f33ed18ed7cdb458951e451
1 #!/usr/bin/env python
3 # Copyright (C) Catalyst IT Ltd. 2017
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.
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.
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/>.
18 """
19 A data generator to help tests.
21 Generate large output to stdout by repeating input data.
22 Usage:
24 python gen_output.py --data @ --repeat 1024 --retcode 1
26 The above command will output @ x 1024 (1K) and exit with 1.
27 """
29 import sys
30 import argparse
32 parser = argparse.ArgumentParser(description='Generate output data')
34 parser.add_argument(
35 '--data', type=str, default='$',
36 help='Characters used to generate data by repeating them'
39 parser.add_argument(
40 '--repeat', type=int, default=1024 * 1024,
41 help='How many times to repeat the data'
44 parser.add_argument(
45 '--retcode', type=int, default=0,
46 help='Specify the exit code for this script'
49 args = parser.parse_args()
51 sys.stdout.write(args.data * args.repeat)
53 sys.exit(args.retcode)