[1888] | 1 | import glob |
---|
| 2 | import sys |
---|
| 3 | import subprocess |
---|
| 4 | import os |
---|
| 5 | import json |
---|
| 6 | import itertools |
---|
| 7 | import copy |
---|
| 8 | |
---|
| 9 | param_list = ["ATMdomain", "UsingServer2", "NumberClients", "NumberServers", "RatioServer2", "NumberPoolsServer2", "Duration"] |
---|
| 10 | param_short_list = ["ATMdom", "Srv2", "NbClnt", "NbSrv", "RatioSrv2", "NbPlSrv2", "Duration"] |
---|
| 11 | |
---|
| 12 | mode=os.getenv("mode") |
---|
| 13 | arch=os.getenv("arch") |
---|
| 14 | svnr=os.getenv("svnR") |
---|
[1890] | 15 | ref_location=os.getenv("ref_location") |
---|
| 16 | ref_file=os.getenv("ref_file") |
---|
[1888] | 17 | |
---|
| 18 | def OSinfo(runthis): |
---|
| 19 | red = lambda text: '\033[0;31m' + text + '\033[0m' |
---|
| 20 | osstdout = subprocess.Popen(runthis, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, close_fds=True) |
---|
| 21 | theInfo = osstdout.communicate()[0].strip() |
---|
| 22 | if osstdout.returncode!=0: |
---|
| 23 | print(red(runthis+" FAILED")) |
---|
[1891] | 24 | print(theInfo) |
---|
[1888] | 25 | sys.exit() |
---|
| 26 | |
---|
| 27 | |
---|
| 28 | def get_default_param(): |
---|
| 29 | f=open("default_param.json", 'r') |
---|
| 30 | default_param = json.load(f) |
---|
| 31 | f.close() |
---|
| 32 | return default_param[0] |
---|
| 33 | |
---|
| 34 | def nonblank_lines(f): |
---|
| 35 | for l in f: |
---|
| 36 | line = l.rstrip() |
---|
| 37 | if line and not line.startswith("#"): |
---|
| 38 | yield line |
---|
| 39 | |
---|
| 40 | def main(): |
---|
[1890] | 41 | OSinfo("cp "+ref_location+"/"+ref_file+" ./") |
---|
| 42 | OSinfo("tar -zxvf "+ref_file) |
---|
| 43 | OSinfo("rm -f "+ref_file) |
---|
[1888] | 44 | test_folder_list = glob.glob('test_*') |
---|
| 45 | |
---|
| 46 | for test_folder in test_folder_list: |
---|
| 47 | config_list = glob.glob(test_folder+"/CONFIG_*") |
---|
| 48 | #print(*config_list, sep = "\n") |
---|
| 49 | |
---|
| 50 | |
---|
| 51 | with open(test_folder+"/checkfile.def", "r") as fh: |
---|
| 52 | checkfiles = list(nonblank_lines(fh)) |
---|
| 53 | |
---|
| 54 | with open("report_"+svnr+"_"+arch+"_"+mode+".txt", "a") as report: |
---|
| 55 | for config in config_list: |
---|
| 56 | folder_name = list(config.split("/"))[0] |
---|
| 57 | config_name = list(config.split("/"))[1] |
---|
| 58 | for checkfile in checkfiles: |
---|
[1890] | 59 | if os.path.exists(config+"/"+checkfile) and os.path.exists("reference/ref_"+config+"/"+checkfile): |
---|
| 60 | OSinfo("cdo -W diffn "+config+"/"+checkfile+" "+"reference/ref_"+config+"/"+checkfile+" | > diff.txt") |
---|
[1888] | 61 | if os.stat("diff.txt").st_size==0: |
---|
| 62 | report.write(folder_name+" "+folder_name+"@"+config_name+" "+folder_name+"@"+config_name+"@"+checkfile+" "+str(1)+"\n") |
---|
| 63 | elif os.path.exists(config+"/"+checkfile): |
---|
| 64 | report.write(folder_name+" "+folder_name+"@"+config_name+" "+folder_name+"@"+config_name+"@"+checkfile+" "+str(0)+"\n") |
---|
| 65 | |
---|
| 66 | |
---|
| 67 | if __name__== "__main__": |
---|
| 68 | main() |
---|