source: XIOS/dev/dev_trunk_omp/GENERIC_TESTCASE/test_function/Check.py @ 1706

Last change on this file since 1706 was 1706, checked in by yushan, 5 years ago

Generic_testcase : add a bash script for launching tests in different sub-folders (test_function, test_axis_algo). Generate a status report test_report.txt for all tests

File size: 3.5 KB
Line 
1import os
2import sys
3
4
5from user_param import *
6
7def main():
8       
9        configNamePattern=[0, 0, 0, 0, 0, 0]
10
11        f=open("user_param.py", "r")
12        for line in f:
13                line = line.strip()
14                if line.startswith("UsingServer2"):
15                        configNamePattern[0] = '_UsingSrv2=' + UsingServer2
16                elif line.startswith("RatioServer2"):
17                        configNamePattern[1] = '_RatioSrv2=' + repr(RatioServer2)
18                elif line.startswith("NumberPoolsServer2"):
19                        configNamePattern[2] = '_NbPoolsSrv2=' + repr(NumberPoolsServer2)
20                elif line.startswith("NumberClients"):
21                        configNamePattern[3] = '_NbClients=' + repr(NumberClients)
22                elif line.startswith("NumberServers"):
23                        configNamePattern[4] = '_NbServers=' + repr(NumberServers)
24                elif line.startswith("Duration"):
25                        configNamePattern[5] = '_Duration=' + Duration
26        f.close()
27               
28       
29        configName = "config"
30        defaultConfig = True
31
32        for i in range(len(configNamePattern)):
33                if configNamePattern[i] != 0:
34                        configName = configName + configNamePattern[i]
35                        defaultConfig = False
36
37        if defaultConfig:
38                configName = "config_default"
39
40
41        if not os.path.exists(configName):
42                os.mkdir(configName)
43                print("\n    ****************************************************************")
44                print("    * Directory " + repr(configName) + " Created ")
45                print("    * Copy results to \'not_validated_reference\' folder")
46                print("    ****************************************************************\n")
47
48                os.mkdir(configName+'/setup')
49                os.mkdir(configName+'/tmp_reference')
50               
51                os.system('cp param.def '+configName+'/setup/')
52                os.system('cp iodef.xml '+configName+'/setup/')
53                os.system('cp context_atm.xml '+configName+'/setup/')
54                os.system('cp context_grid_dynamico.xml '+configName+'/setup/')
55                os.system('cp dynamico_grid.nc '+configName+'/setup/')
56               
57                os.system('cp atm_output.nc '+configName+'/tmp_reference/')
58                # os.system('cp -r '+configName+'/tmp_reference/ ' + configName+'/reference/')
59
60        else:   
61                print("\n    ********************************************************")
62                print("    * Directory " + repr(configName) + " already exists")
63                print("    * Start comparing results with (tmp) references")
64                print("    ********************************************************\n")
65
66                tmp_ref = os.path.isdir(configName+'/tmp_reference')
67                ref = os.path.isdir(configName+'/reference')
68
69                if ref:
70                        print("\n    =====================================")
71                        print("    | Comparing results with references |")
72                        print("    =====================================\n")
73                        os.system('rm -rf '+configName+'/tmp_reference/')
74                        tmp_ref = False
75                        path = configName+'/reference/'
76                elif tmp_ref:
77                        print("\n    ===================================================")
78                        print("    | Comparing results with NON-Validated references |")
79                        print("    ===================================================\n")
80                        path = configName+'/tmp_reference/'
81
82                os.system('cdo diffn atm_output.nc '+path+'/atm_output.nc | tail -1 > diff.txt')
83
84                f=open("diff.txt", "r")
85                for line in f:
86                        if line.strip().startswith("0"):
87                                print "\n        ***********************"
88                                print "        ** Test is valid !!! **"
89                                print "        ***********************\n"
90                                valid = True
91
92                        else:
93                                print "\n        *******************************************"
94                                print "        ** Test is NOT valid. Please debuging... **"
95                                print "        *******************************************\n"
96                                valid = False
97
98                f.close()
99
100                f=open("report.txt", "a+")
101                if valid:
102                        f.write("test for "+configName+" passed.\n")
103                else:
104                        f.write("test for "+configName+" failed.\n")
105                f.close()
106
107
108if __name__== "__main__":
109  main()
Note: See TracBrowser for help on using the repository browser.