Changeset 1734 for XIOS/dev/dev_trunk_omp/GENERIC_TESTCASE/check.py
- Timestamp:
- 10/04/19 17:36:51 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/dev/dev_trunk_omp/GENERIC_TESTCASE/check.py
r1726 r1734 1 1 import os 2 2 import sys 3 import subprocess 3 4 4 5 5 6 from user_param import * 7 8 9 def OSinfo(runthis): 10 osstdout = subprocess.Popen(runthis, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, close_fds=True) 11 theInfo = osstdout.communicate()[0].strip() 12 # print(theInfo) 13 # print(osstdout.returncode) 14 # return (osstdout.returncode) 15 16 if osstdout.returncode!=0: 17 print >> sys.stderr, osstdout.returncode 18 sys.exit() 19 else: 20 print(runthis+" OK") 21 6 22 7 23 def main(): … … 57 73 configName = "config_default" 58 74 75 check_result=False 76 59 77 60 78 if not os.path.exists(configName): … … 65 83 print blue(" ****************************************************************\n") 66 84 67 os.mkdir(configName+'/setup') 85 # os.mkdir(configName+'/setup') 86 os.system("mkdir "+configName+'/setup') 68 87 os.mkdir(configName+'/tmp_reference') 69 88 os.mkdir(configName+'/xios_output') … … 85 104 h.write("Config : "+configName+"\n") 86 105 l.write("<p>Config : "+configName+"</p>") 106 endloop=False 87 107 for line in f: 88 108 line=line.strip() 89 109 line=line.rstrip() 110 111 if line.startswith("all"): 112 allfiles = os.listdir(os.getcwd()) 113 for thisfile in allfiles: 114 if thisfile.endswith(".nc") and thisfile!="dynamico_grid.nc": 115 cmd = 'mv '+thisfile + ' '+configName+'/tmp_reference/' 116 os.system(cmd) 117 118 h.write("test for "+lpurple("all NC files")+" \t"+yellow('INITIALIZED')+"\n") 119 l.write("<p>test for <font color=\"purple\">"+"all NC files"+"</font> <font color=\"darkorange\">INITIALIZED</font></p>") 120 print yellow("\n ****************************************") 121 print yellow(" ** "+"all NC files"+" is stored as temporal reference !!! **") 122 print yellow("\n ****************************************") 123 124 break 125 90 126 if not line.startswith("#") and len(line) != 0: 91 127 cmd = 'mv '+line + ' '+configName+'/tmp_reference/' … … 107 143 print blue("\n ********************************************************") 108 144 print blue(" * Directory " + repr(configName) + " already exists") 109 print blue(" * Start comparing results with (tmp)references")145 print blue(" * Start comparing results with references") 110 146 print blue(" ********************************************************\n") 111 147 112 148 tmp_ref = os.path.isdir(configName+'/tmp_reference') 113 ref = os.path.isdir(configName+'/reference') 149 ref = os.path.isdir(configName+'/reference') and not tmp_ref 114 150 115 151 if ref: … … 117 153 print blue(" | Comparing results with references |") 118 154 print blue(" =====================================\n") 119 os.system('rm -rf '+configName+'/tmp_reference/')120 tmp_ref = False121 155 path = configName+'/reference/' 122 156 elif tmp_ref: … … 124 158 print blue(" | Comparing results with NON-Validated references |") 125 159 print blue(" ===================================================\n") 126 path = ' '+configName+'/tmp_reference/'160 path = configName+'/tmp_reference/' 127 161 128 162 f=open("checkfile.def", "r") … … 138 172 line=line.rstrip() 139 173 140 if not line.startswith("#") and len(line) != 0: 141 cmd = 'cdo diffn '+ line + path + line + ' | tail -1 > diff.txt' 142 os.system(cmd) 174 if line.startswith("all") : 175 for thisfile in os.listdir(path): 176 if thisfile.endswith(".nc"): 177 cmd = 'cdo -W diffn '+ thisfile +' '+ path + thisfile + ' | tail -1 > diff.txt' 178 179 OSinfo(cmd) 180 181 if os.stat("diff.txt").st_size==0: 182 h.write("test for "+lpurple(thisfile)+" \t"+green('PASSED')+"\n") 183 l.write("<p>test for <font color=\"purple\">"+thisfile+"</font> <font color=\"green\">PASSED</font></p>") 184 print green("\n ****************************************") 185 print green(" ** "+thisfile+" is valid !!! **") 186 print green("\n ****************************************") 187 188 else: 189 g=open("diff.txt", "r") 190 for gline in g: 191 if gline.strip().startswith("0") or ":" in gline : 192 h.write("test for "+lpurple(thisfile)+" \t"+green('PASSED')+"\n") 193 l.write("<p>test for <font color=\"purple\">"+thisfile+"</font> <font color=\"green\">PASSED</font></p>") 194 print green("\n ****************************************") 195 print green(" ** "+thisfile+" is valid !!! **") 196 print green("\n ****************************************") 197 else: 198 h.write("test for "+lpurple(thisfile)+" \t"+red('FAILED')+"\n") 199 l.write("<p>test for <font color=\"purple\">"+thisfile+"</font> <font color=\"red\">FAILED</font></p>") 200 print red("\n **************************************************") 201 print red(" ** "+thisfile+" is NOT valid. Please debugging.. **") 202 print red("\n **************************************************") 203 g.close() 204 break 205 206 207 elif not line.startswith("#") and len(line) != 0: 208 cmd = 'cdo -W diffn '+ line +' '+ path + line + ' | tail -1 > diff.txt' 209 210 OSinfo(cmd) 143 211 144 212 if os.stat("diff.txt").st_size==0: … … 187 255 188 256 257 258 189 259 if __name__== "__main__": 190 260 main()
Note: See TracChangeset
for help on using the changeset viewer.