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

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

trunk : some scripts for parallel job submission.

File size: 2.3 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")
15
16
17def OSinfo(runthis):
18    red = lambda text: '\033[0;31m' + text + '\033[0m'
19    osstdout = subprocess.Popen(runthis, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, close_fds=True)
20    theInfo = osstdout.communicate()[0].strip()
21    if osstdout.returncode!=0:
22        print(red(runthis+" FAILED"))
23        print >> sys.stderr, osstdout.returncode
24        sys.exit()
25    # else:
26    #     print(runthis+" OK")
27
28
29def get_default_param():
30    f=open("default_param.json", 'r')
31    default_param = json.load(f)
32    f.close()
33    return default_param[0]
34
35def nonblank_lines(f):
36    for l in f:
37        line = l.rstrip()
38        if line and not line.startswith("#"):
39            yield line
40
41def main():
42   
43    test_folder_list = glob.glob('test_*')
44
45    for test_folder in test_folder_list:
46        config_list = glob.glob(test_folder+"/CONFIG_*")
47        #print(*config_list, sep = "\n")
48       
49       
50        with open(test_folder+"/checkfile.def", "r") as fh:
51            checkfiles = list(nonblank_lines(fh))
52
53        with open("report_"+svnr+"_"+arch+"_"+mode+".txt", "a") as report:
54            for config in config_list:
55                folder_name = list(config.split("/"))[0]
56                config_name = list(config.split("/"))[1]
57                for checkfile in checkfiles:
58                    if os.path.exists(config+"/"+checkfile) and os.path.exists("ref_"+config+"/"+checkfile):
59                        OSinfo("cdo -W diffn "+config+"/"+checkfile+" "+"ref_"+config+"/"+checkfile+" | > diff.txt")
60                        if os.stat("diff.txt").st_size==0:
61                            report.write(folder_name+" "+folder_name+"@"+config_name+" "+folder_name+"@"+config_name+"@"+checkfile+" "+str(1)+"\n")
62                    elif os.path.exists(config+"/"+checkfile):
63                        report.write(folder_name+" "+folder_name+"@"+config_name+" "+folder_name+"@"+config_name+"@"+checkfile+" "+str(0)+"\n")
64                   
65
66if __name__== "__main__":
67  main()
Note: See TracBrowser for help on using the repository browser.