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

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

trunk : commit for checking

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(theInfo)
25        sys.exit()
26
27
28def 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
34def nonblank_lines(f):
35    for l in f:
36        line = l.rstrip()
37        if line and not line.startswith("#"):
38            yield line
39
40def main():
41    OSinfo("cp "+ref_location+"/"+ref_file+" ./")
42    OSinfo("tar -zxvf "+ref_file)
43    OSinfo("rm -f "+ref_file)
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:
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")
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
67if __name__== "__main__":
68  main()
Note: See TracBrowser for help on using the repository browser.