source: XIOS/dev/dev_ym/XIOS_COUPLING/xios_test_suite/TEST_SUITE/step2.py @ 2210

Last change on this file since 2210 was 2210, checked in by jderouillat, 5 months ago

Setting XIOS_COULING test suite for Jean-Zay (validated in OpenMPI)

File size: 3.7 KB
Line 
1import glob
2import sys
3import subprocess
4import os
5import json
6import itertools
7import copy
8
9
10mode=os.getenv("mode")
11arch=os.getenv("arch")
12svnr=os.getenv("svnR")
13ref_location=os.getenv("ref_location")
14ref_file=os.getenv("ref_file")
15
16
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.PIPE, close_fds=True)
21    theInfo, theErr = osstdout.communicate()
22    #print(theInfo)
23    if theErr:
24        print(red(runthis+" FAILED"))
25        print(theErr)
26        sys.exit()
27
28#def OSinfo(runthis):
29#    red = lambda text: '\033[0;31m' + text + '\033[0m'
30#    osstdout = subprocess.Popen(runthis, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, close_fds=True)
31#    theInfo = osstdout.communicate()[0].strip()
32#    if osstdout.returncode!=0:
33#        print(red(runthis+" FAILED"))
34#        print(theInfo)
35#        sys.exit()
36
37
38
39def nonblank_lines(f):
40    for l in f:
41        line = l.rstrip()
42        if line and not line.startswith("#"):
43            yield line
44
45def main():
46    ref_list = glob.glob(ref_location+"/*")
47    for i in range(len(ref_list)):
48        tmp = ref_list[i].split("/")
49        rev = tmp[len(tmp)-1]
50        ref_list[i] = int(rev)
51    ref_list.sort(reverse=True) #ref_list in descending order
52   
53    ref_rev = ""
54    for ref in ref_list:
55        if int(svnr) >= ref :
56            ref_rev = str(ref)
57            print("corresponding reference = ", ref)
58            break
59       
60    if not ref_rev:
61        print("no available reference found ... exit")
62        return
63   
64    OSinfo("cp "+ref_location+"/"+ref_rev+"/"+ref_file+" ./")
65    OSinfo("tar -zxvf "+ref_location+"/"+ref_rev+"/"+ref_file)
66    OSinfo("rm -f "+ref_file)
67   
68   
69    test_folder_list = glob.glob('test_*')
70
71    for test_folder in test_folder_list:
72        config_list = glob.glob(test_folder+"/CONFIG_*")
73       
74       
75        with open(test_folder+"/checkfile.def", "r") as fh:
76            checkfiles = list(nonblank_lines(fh))
77
78        with open("report_"+svnr+"_"+arch+"_"+mode+".txt", "a") as report:
79            for config in config_list:
80                folder_name = list(config.split("/"))[0]
81                config_name = list(config.split("/"))[1]
82                for checkfile in checkfiles:
83                    if os.path.exists(config+"/"+checkfile) and os.path.exists("reference/ref_"+config+"/"+checkfile):
84                        OSinfo("cdo -W diffn "+config+"/"+checkfile+" "+"reference/ref_"+config+"/"+checkfile+"  2>&1 |grep -v 'Found more than one time variable'|grep -v 'cdo diffn: Processed'|grep -v 'cdo    diffn: Processed'|grep -v 'Time variable >time_counter< not found!' > diff_"+checkfile+".txt")
85                        if os.stat("diff_"+checkfile+".txt").st_size==0: # if no diff -> set 0
86                            report.write(folder_name+" "+folder_name+"@"+config_name+" "+folder_name+"@"+config_name+"@"+checkfile+" "+str(1)+"\n")
87                        else: # if cdo diffn returns diff -> set -1
88                            report.write(folder_name+" "+folder_name+"@"+config_name+" "+folder_name+"@"+config_name+"@"+checkfile+" "+str(-1)+"\n")
89
90                    elif os.path.exists(config+"/"+checkfile): # if no ref file -> set 0
91                        report.write(folder_name+" "+folder_name+"@"+config_name+" "+folder_name+"@"+config_name+"@"+checkfile+" "+str(0)+"\n")
92                    elif os.path.exists("reference/ref_"+config+"/"+checkfile): # if no output file -> set -2
93                        report.write(folder_name+" "+folder_name+"@"+config_name+" "+folder_name+"@"+config_name+"@"+checkfile+" "+str(-2)+"\n")
94
95                   
96
97if __name__== "__main__":
98  main()
Note: See TracBrowser for help on using the repository browser.