#!/usr/bin/python# -*- coding:utf8 -*-import sysimport commandsTEST_CONF="""hd=default,vdbench=/var/www/html/vdbench504,user=root,shell=sshsd=sd1,lun=/dev/vdc,openflags=o_direct,threads=1wd=wd1,sd=sd1,xfersize=16k,readpct={readpct},seekpct={seekpct}rd=rd1,wd=wd1,iorate=max,elapsed=10,maxdata=5500g,interval=1,warmup=3"""def gen_test_file(file_name, rs_list): for num,rs in enumerate(rs_list): with open(file_name + "-" + str(num), 'w') as fw: fw.write(TEST_CONF.format( readpct=rs['readpct'], seekpct=rs['seekpct']) ) returndef main(): fn = 'test' rs_list = [ {'readpct':100, 'seekpct':100}, {'readpct':0, 'seekpct':100}, {'readpct':100, 'seekpct':0}, {'readpct':0, 'seekpct':0}, ]*3 #*3是这4个用例循环3次的意思 gen_test_file('./{}'.format(fn), rs_list) for num0,rs in enumerate(rs_list):
cmd='./vdbench -f {}'.format(fn) + "-" + str(num0) + ' -o /root/res' + str(num0)
#print cmd print commands.getoutput(cmd)if __name__ == '__main__': main() sys.exit(0)