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") |
---|
15 | ref_location=os.getenv("ref_location") |
---|
16 | ref_file=os.getenv("ref_file") |
---|
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")) |
---|
24 | print >> sys.stderr, osstdout.returncode |
---|
25 | sys.exit() |
---|
26 | # else: |
---|
27 | # print(runthis+" OK") |
---|
28 | |
---|
29 | |
---|
30 | def get_default_param(): |
---|
31 | f=open("default_param.json", 'r') |
---|
32 | default_param = json.load(f) |
---|
33 | f.close() |
---|
34 | return default_param[0] |
---|
35 | |
---|
36 | def nonblank_lines(f): |
---|
37 | for l in f: |
---|
38 | line = l.rstrip() |
---|
39 | if line and not line.startswith("#"): |
---|
40 | yield line |
---|
41 | |
---|
42 | def main(): |
---|
43 | OSinfo("cp "+ref_location+"/"+ref_file+" ./") |
---|
44 | OSinfo("tar -zxvf "+ref_file) |
---|
45 | OSinfo("rm -f "+ref_file) |
---|
46 | test_folder_list = glob.glob('test_*') |
---|
47 | |
---|
48 | for test_folder in test_folder_list: |
---|
49 | config_list = glob.glob(test_folder+"/CONFIG_*") |
---|
50 | #print(*config_list, sep = "\n") |
---|
51 | |
---|
52 | |
---|
53 | with open(test_folder+"/checkfile.def", "r") as fh: |
---|
54 | checkfiles = list(nonblank_lines(fh)) |
---|
55 | |
---|
56 | with open("report_"+svnr+"_"+arch+"_"+mode+".txt", "a") as report: |
---|
57 | for config in config_list: |
---|
58 | folder_name = list(config.split("/"))[0] |
---|
59 | config_name = list(config.split("/"))[1] |
---|
60 | for checkfile in checkfiles: |
---|
61 | if os.path.exists(config+"/"+checkfile) and os.path.exists("reference/ref_"+config+"/"+checkfile): |
---|
62 | OSinfo("cdo -W diffn "+config+"/"+checkfile+" "+"reference/ref_"+config+"/"+checkfile+" | > diff.txt") |
---|
63 | if os.stat("diff.txt").st_size==0: |
---|
64 | report.write(folder_name+" "+folder_name+"@"+config_name+" "+folder_name+"@"+config_name+"@"+checkfile+" "+str(1)+"\n") |
---|
65 | elif os.path.exists(config+"/"+checkfile): |
---|
66 | report.write(folder_name+" "+folder_name+"@"+config_name+" "+folder_name+"@"+config_name+"@"+checkfile+" "+str(0)+"\n") |
---|
67 | |
---|
68 | |
---|
69 | if __name__== "__main__": |
---|
70 | main() |
---|