source: XIOS/trunk/xios_test_suite/TEST_SUITE/step2.py @ 1890

Last change on this file since 1890 was 1890, checked in by yushan, 4 years ago

trunk : minor modif

File size: 2.5 KB
Line 
1import glob
2import sys
3import subprocess
4import os
5import json
6import itertools
7import copy
8
9param_list = ["ATMdomain", "UsingServer2", "NumberClients", "NumberServers", "RatioServer2", "NumberPoolsServer2", "Duration"]
10param_short_list = ["ATMdom", "Srv2", "NbClnt", "NbSrv", "RatioSrv2", "NbPlSrv2", "Duration"]
11
12mode=os.getenv("mode")
13arch=os.getenv("arch")
14svnr=os.getenv("svnR")
15ref_location=os.getenv("ref_location")
16ref_file=os.getenv("ref_file")
17
18def 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
30def 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
36def nonblank_lines(f):
37    for l in f:
38        line = l.rstrip()
39        if line and not line.startswith("#"):
40            yield line
41
42def 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
69if __name__== "__main__":
70  main()
Note: See TracBrowser for help on using the repository browser.