Ignore:
Timestamp:
10/04/19 17:36:51 (5 years ago)
Author:
yushan
Message:

GENERIC_TESTCASE : check all .nc files by default. Generate Cmake files from python scripts (user_config.py, setup.py). Add scripts for copy to/from compressed reference stored in /gpfswork/rech/psl/rpsl954 (Jean-Zay and Irene).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/dev_trunk_omp/GENERIC_TESTCASE/check.py

    r1726 r1734  
    11import os 
    22import sys 
     3import subprocess 
    34 
    45 
    56from user_param import * 
     7 
     8 
     9def 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 
    622 
    723def main(): 
     
    5773                configName = "config_default" 
    5874 
     75        check_result=False 
     76 
    5977 
    6078        if not os.path.exists(configName): 
     
    6583                print blue("    ****************************************************************\n") 
    6684 
    67                 os.mkdir(configName+'/setup') 
     85                # os.mkdir(configName+'/setup') 
     86                os.system("mkdir "+configName+'/setup') 
    6887                os.mkdir(configName+'/tmp_reference') 
    6988                os.mkdir(configName+'/xios_output') 
     
    85104                h.write("Config : "+configName+"\n")             
    86105                l.write("<p>Config : "+configName+"</p>")        
     106                endloop=False 
    87107                for line in f: 
    88108                        line=line.strip() 
    89109                        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> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <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 
    90126                        if not line.startswith("#") and len(line) != 0: 
    91127                                cmd = 'mv '+line + ' '+configName+'/tmp_reference/' 
     
    107143                print blue("\n    ********************************************************") 
    108144                print blue("    * Directory " + repr(configName) + " already exists") 
    109                 print blue("    * Start comparing results with (tmp) references") 
     145                print blue("    * Start comparing results with references") 
    110146                print blue("    ********************************************************\n") 
    111147 
    112148                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 
    114150 
    115151                if ref: 
     
    117153                        print blue("    | Comparing results with references |") 
    118154                        print blue("    =====================================\n") 
    119                         os.system('rm -rf '+configName+'/tmp_reference/') 
    120                         tmp_ref = False 
    121155                        path = configName+'/reference/' 
    122156                elif tmp_ref: 
     
    124158                        print blue("    | Comparing results with NON-Validated references |") 
    125159                        print blue("    ===================================================\n") 
    126                         path = ' '+configName+'/tmp_reference/' 
     160                        path = configName+'/tmp_reference/' 
    127161                 
    128162                f=open("checkfile.def", "r") 
     
    138172                        line=line.rstrip() 
    139173                         
    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> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <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> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <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> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <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) 
    143211 
    144212                                if os.stat("diff.txt").st_size==0: 
     
    187255 
    188256 
     257 
     258 
    189259if __name__== "__main__": 
    190260  main() 
Note: See TracChangeset for help on using the changeset viewer.