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/>.
19 A data generator to help tests.
21 Generate large output to stdout by repeating input data.
24 python gen_output.py --data @ --repeat 1024 --retcode 1
26 The above command will output @ x 1024 (1K) and exit with 1.
32 parser
= argparse
.ArgumentParser(description
='Generate output data')
35 '--data', type=str, default
='$',
36 help='Characters used to generate data by repeating them'
40 '--repeat', type=int, default
=1024 * 1024,
41 help='How many times to repeat the data'
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
)