test-zstd-speed.py: added --verbose option
parent
6e5beea715
commit
8c53ad53b1
|
@ -15,13 +15,15 @@ working_path = os.getcwd() + '/' + working_dir_name # /path/to/zstd/tests/sp
|
|||
clone_path = working_path + '/' + 'zstd' # /path/to/zstd/tests/speedTest/zstd
|
||||
email_header = '[ZSTD_speedTest]'
|
||||
pid = str(os.getpid())
|
||||
verbose = False
|
||||
|
||||
|
||||
def log(text):
|
||||
print(time.strftime("%Y/%m/%d %H:%M:%S") + ' - ' + text)
|
||||
|
||||
|
||||
def execute(command, print_output=False, print_error=True, param_shell=True):
|
||||
def execute(command, print_command=True, print_output=False, print_error=True, param_shell=True):
|
||||
if print_command:
|
||||
log("> " + command)
|
||||
popen = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=param_shell, cwd=execute.cwd)
|
||||
stdout = popen.communicate()[0]
|
||||
|
@ -38,7 +40,7 @@ execute.cwd = None
|
|||
|
||||
def does_command_exist(command):
|
||||
try:
|
||||
execute(command, False, False);
|
||||
execute(command, verbose, False, False);
|
||||
except Exception as e:
|
||||
return False
|
||||
return True
|
||||
|
@ -50,9 +52,9 @@ def send_email(emails, topic, text, have_mutt, have_mail):
|
|||
myfile.writelines(text)
|
||||
myfile.close()
|
||||
if have_mutt:
|
||||
execute('mutt -s "' + topic + '" ' + emails + ' < ' + logFileName)
|
||||
execute('mutt -s "' + topic + '" ' + emails + ' < ' + logFileName, verbose)
|
||||
elif have_mail:
|
||||
execute('mail -s "' + topic + '" ' + emails + ' < ' + logFileName)
|
||||
execute('mail -s "' + topic + '" ' + emails + ' < ' + logFileName, verbose)
|
||||
else:
|
||||
log("e-mail cannot be sent (mail or mutt not found)")
|
||||
|
||||
|
@ -71,8 +73,8 @@ def send_email_with_attachments(branch, commit, last_commit, emails, text, resul
|
|||
|
||||
|
||||
def git_get_branches():
|
||||
execute('git fetch -p')
|
||||
branches = execute('git branch -rl')
|
||||
execute('git fetch -p', verbose)
|
||||
branches = execute('git branch -rl', verbose)
|
||||
output = []
|
||||
for line in branches:
|
||||
if ("HEAD" not in line) and ("coverity_scan" not in line) and ("gh-pages" not in line):
|
||||
|
@ -183,7 +185,9 @@ if __name__ == '__main__':
|
|||
parser.add_argument('--lastCLevel', type=int, help='last compression level for testing', default=5)
|
||||
parser.add_argument('--sleepTime', type=int, help='frequency of repository checking in seconds', default=300)
|
||||
parser.add_argument('--dry-run', dest='dry_run', action='store_true', help='not build', default=False)
|
||||
parser.add_argument('--verbose', action='store_true', help='more verbose logs', default=False)
|
||||
args = parser.parse_args()
|
||||
verbose = args.verbose
|
||||
|
||||
# check if test files are accessible
|
||||
testFileNames = args.testFileNames.split()
|
||||
|
@ -203,6 +207,7 @@ if __name__ == '__main__':
|
|||
log("ERROR: e-mail senders 'mail' or 'mutt' not found")
|
||||
exit(1)
|
||||
|
||||
if verbose:
|
||||
print("PARAMETERS:\nrepoURL=%s" % args.repoURL)
|
||||
print("working_path=%s" % working_path)
|
||||
print("clone_path=%s" % clone_path)
|
||||
|
@ -214,6 +219,7 @@ if __name__ == '__main__':
|
|||
print("lastCLevel=%s" % args.lastCLevel)
|
||||
print("sleepTime=%s" % args.sleepTime)
|
||||
print("dry_run=%s" % args.dry_run)
|
||||
print("verbose=%s" % args.verbose)
|
||||
print("have_mutt=%s have_mail=%s" % (have_mutt, have_mail))
|
||||
|
||||
# clone ZSTD repo if needed
|
||||
|
@ -242,7 +248,7 @@ if __name__ == '__main__':
|
|||
if (loadavg <= args.maxLoadAvg):
|
||||
branches = git_get_branches()
|
||||
for branch in branches:
|
||||
commit = execute('git show -s --format=%h ' + branch)[0]
|
||||
commit = execute('git show -s --format=%h ' + branch, verbose)[0]
|
||||
last_commit = update_config_file(branch, commit)
|
||||
if commit == last_commit:
|
||||
log("skipping branch %s: head %s already processed" % (branch, commit))
|
||||
|
@ -253,6 +259,7 @@ if __name__ == '__main__':
|
|||
test_commit(branch, commit, last_commit, args, testFilePaths, have_mutt, have_mail)
|
||||
else:
|
||||
log("WARNING: main loadavg=%.2f is higher than %s" % (loadavg, args.maxLoadAvg))
|
||||
if verbose:
|
||||
log("sleep for %s seconds" % args.sleepTime)
|
||||
time.sleep(args.sleepTime)
|
||||
except Exception as e:
|
||||
|
|
Loading…
Reference in New Issue