[1806] | 1 | import glob |
---|
| 2 | import sys |
---|
| 3 | import subprocess |
---|
| 4 | import os |
---|
| 5 | |
---|
| 6 | def OSinfo(runthis): |
---|
| 7 | red = lambda text: '\033[0;31m' + text + '\033[0m' |
---|
| 8 | osstdout = subprocess.Popen(runthis, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, close_fds=True) |
---|
| 9 | theInfo = osstdout.communicate()[0].strip() |
---|
| 10 | if osstdout.returncode!=0: |
---|
| 11 | print(red(runthis+" FAILED")) |
---|
| 12 | print >> sys.stderr, osstdout.returncode |
---|
| 13 | sys.exit() |
---|
| 14 | # else: |
---|
| 15 | # print(runthis+" OK") |
---|
| 16 | |
---|
| 17 | def Sort(sub_li): |
---|
| 18 | l = len(sub_li) |
---|
| 19 | for i in range(0, l): |
---|
| 20 | for j in range(0, l-i-1): |
---|
| 21 | if (sub_li[j][0] < sub_li[j+1][0]): |
---|
| 22 | tempo = sub_li[j] |
---|
| 23 | sub_li[j]= sub_li[j+1] |
---|
| 24 | sub_li[j+1]= tempo |
---|
| 25 | if (sub_li[j][0] == sub_li[j+1][0]): |
---|
| 26 | if (sub_li[j][2] < sub_li[j+1][2]): |
---|
| 27 | tempo = sub_li[j] |
---|
| 28 | sub_li[j]= sub_li[j+1] |
---|
| 29 | sub_li[j+1]= tempo |
---|
| 30 | if (sub_li[j][1] == sub_li[j+1][1]): |
---|
| 31 | if (sub_li[j][2] < sub_li[j+1][2]): |
---|
| 32 | tempo = sub_li[j] |
---|
| 33 | sub_li[j]= sub_li[j+1] |
---|
| 34 | sub_li[j+1]= tempo |
---|
| 35 | return sub_li |
---|
| 36 | |
---|
| 37 | def subgenerate(directory, machine, machine_name): |
---|
| 38 | |
---|
| 39 | test_list = glob.glob(directory+"/test_"+machine+"/test_*.txt") |
---|
| 40 | if len(test_list) == 0 : |
---|
| 41 | return |
---|
| 42 | |
---|
| 43 | revision_list=[] |
---|
| 44 | relurl_list=[] |
---|
| 45 | machine_list=[] |
---|
| 46 | build_dir_list=[] |
---|
| 47 | arch_list=[] |
---|
| 48 | mode_list=[] |
---|
| 49 | |
---|
| 50 | myTestList=[] |
---|
| 51 | |
---|
| 52 | for test_log in test_list : |
---|
| 53 | f=open(test_log, "r") |
---|
| 54 | for line in f : |
---|
| 55 | if line.startswith("#revision") : |
---|
| 56 | revision = line.replace("\n","").split(" ")[1] |
---|
| 57 | if not revision in revision_list : |
---|
| 58 | revision_list.append(revision) |
---|
| 59 | elif line.startswith("#relurl") : |
---|
| 60 | relurl = line.replace("\n","").split(" ")[1] |
---|
| 61 | tmp_url = relurl.split("/") |
---|
| 62 | branch = tmp_url[len(tmp_url)-1] |
---|
| 63 | if not relurl in relurl_list : |
---|
| 64 | relurl_list.append(relurl) |
---|
| 65 | elif line.startswith("#build_dir") : |
---|
| 66 | build_dir = line.replace("\n","").split(" ")[1] |
---|
| 67 | tmp_list = build_dir.split("/") |
---|
| 68 | short_dir = tmp_list[len(tmp_list)-1] |
---|
| 69 | if not build_dir in build_dir_list : |
---|
| 70 | build_dir_list.append(short_dir) |
---|
| 71 | elif line.startswith("#arch") : |
---|
| 72 | arch = line.replace("\n","").split(" ")[1] |
---|
| 73 | if not arch in arch_list : |
---|
| 74 | arch_list.append(arch) |
---|
| 75 | elif line.startswith("#mode") : |
---|
| 76 | mode = line.replace("\n","").split(" ")[1] |
---|
| 77 | if not mode in mode_list : |
---|
| 78 | mode_list.append(mode) |
---|
| 79 | |
---|
| 80 | myTestList.append([revision, machine, short_dir, branch, machine_name, arch, mode, build_dir]) |
---|
| 81 | f.close() |
---|
| 82 | |
---|
| 83 | revision_list = sorted(revision_list, reverse=True) |
---|
| 84 | print(revision_list) |
---|
| 85 | |
---|
| 86 | Sort(myTestList) |
---|
| 87 | print(myTestList) |
---|
| 88 | |
---|
[1812] | 89 | f=open("_test_"+machine+"_info.js", "w") |
---|
[1806] | 90 | f.write("var test_"+machine+"_revision_list = "+repr(revision_list)+"\n\n") |
---|
| 91 | f.write("var test_"+machine+"_info_list = [\n") |
---|
| 92 | for i in range(len(myTestList)) : |
---|
| 93 | if i<len(myTestList)-1 : |
---|
| 94 | f.write(" "+repr(myTestList[i])+",\n") |
---|
| 95 | else : |
---|
| 96 | f.write(" "+repr(myTestList[i])+"]\n\n") |
---|
| 97 | |
---|
| 98 | myReportDict=dict() |
---|
| 99 | for i in range(len(myTestList)) : |
---|
| 100 | myReportList=[] # algo, config, file, status |
---|
| 101 | print(myTestList[i]) |
---|
| 102 | file_to_open = directory+"/test_"+machine+"/test_"+myTestList[i][0]+"_"+myTestList[i][1]+"_"+myTestList[i][2].replace("build_","")+".txt" |
---|
| 103 | g=open(file_to_open, "r") |
---|
| 104 | for line in g : |
---|
| 105 | if not line.startswith("#") : |
---|
| 106 | line = line.replace("\n","").split(" ") |
---|
| 107 | algo = line[0] |
---|
| 108 | config = line[1].split("@")[1] |
---|
| 109 | file = line[2].split("@")[2] |
---|
| 110 | status = line[3] |
---|
| 111 | myReportList.append([algo, config, file, status]) |
---|
| 112 | g.close() |
---|
| 113 | print(len(myReportList)) |
---|
| 114 | myReportDict.update({myTestList[i][0]+"_"+myTestList[i][2].replace("build_","") : myReportList}) |
---|
| 115 | |
---|
| 116 | for i in range(len(myReportDict)) : |
---|
| 117 | key = list(myReportDict.keys())[i] |
---|
| 118 | f.write("var test_"+machine+"_"+key+" = [\n") |
---|
| 119 | for j in range(len(myReportDict[key])) : |
---|
| 120 | if j<len(myReportDict[key])-1 : |
---|
| 121 | f.write(" [\'"+myReportDict[key][j][0]+"\', \'"+myReportDict[key][j][1]+"\', \'"+myReportDict[key][j][2]+"\', "+myReportDict[key][j][3]+"],\n") |
---|
| 122 | else : |
---|
[1821] | 123 | f.write(" [\'"+myReportDict[key][j][0]+"\', \'"+myReportDict[key][j][1]+"\', \'"+myReportDict[key][j][2]+"\', "+myReportDict[key][j][3]+"]") |
---|
| 124 | f.write("]\n\n\n") |
---|
[1806] | 125 | |
---|
| 126 | for revision in revision_list : |
---|
| 127 | algo_list = glob.glob(directory+"/def_files/"+revision+"/test_*") |
---|
| 128 | |
---|
| 129 | for l in algo_list : |
---|
| 130 | tmp_algo = l.split("/") |
---|
| 131 | f.write("var test_"+machine+"_"+revision+"_"+tmp_algo[len(tmp_algo)-1]+"_user_params = [\n") |
---|
[1841] | 132 | if os.path.exists(l+"/user_param.json"): |
---|
| 133 | g=open(l+"/user_param.json","r") |
---|
| 134 | for line in g: |
---|
| 135 | if not line=="\n" and not line.startswith("#"): |
---|
| 136 | f.write(" \'"+line.replace("\n","").replace("'","\\\'")+"\',\n") |
---|
| 137 | g.close() |
---|
| 138 | else : |
---|
| 139 | g=open(l+"/user_params.def","r") |
---|
| 140 | for line in g: |
---|
| 141 | if not line=="\n" and not line.startswith("#"): |
---|
| 142 | f.write(" \'"+line.replace("\n","").replace("'","\\\'")+"\',\n") |
---|
| 143 | g.close() |
---|
[1806] | 144 | f.write(" ]\n\n") |
---|
| 145 | |
---|
| 146 | for revision in revision_list : |
---|
[1819] | 147 | algo_list = glob.glob(directory+"/def_files/"+revision+"/test_*") |
---|
[1806] | 148 | |
---|
| 149 | for algo in algo_list : |
---|
| 150 | config_list = glob.glob(algo+"/config_*") |
---|
| 151 | tmp_algo = algo.split("/") |
---|
| 152 | algo_name = tmp_algo[len(tmp_algo)-1] |
---|
| 153 | for config in config_list : |
---|
| 154 | tmp_config = config.split("/") |
---|
| 155 | config_name = tmp_config[len(tmp_config)-1] |
---|
| 156 | config_name_bis = config_name.replace("=","_") |
---|
| 157 | f.write("var test_"+machine+"_"+revision+"_"+algo_name+"_"+config_name_bis+"_all_params = [\n") |
---|
| 158 | g=open(config+"/all_param.def","r") |
---|
| 159 | for line in g: |
---|
| 160 | line = line.replace("&", "& ") |
---|
| 161 | if not line=="\n" : |
---|
| 162 | f.write(" \'"+line.replace("\n","").replace("'","\\\'")+"\',\n") |
---|
| 163 | g.close() |
---|
| 164 | f.write(" ]\n\n") |
---|
| 165 | |
---|
| 166 | f.close() |
---|
| 167 | |
---|
| 168 | |
---|
| 169 | def main(): |
---|
| 170 | repository_name=os.getenv('xios_test_suite_repository') |
---|
| 171 | machine=os.getenv('xios_machine_name') |
---|
| 172 | machine_name=os.getenv('xios_full_machine_name') |
---|
| 173 | |
---|
| 174 | subgenerate(repository_name+'/RUN',machine, machine_name) |
---|
| 175 | |
---|
| 176 | |
---|
| 177 | if __name__== "__main__": |
---|
| 178 | main() |
---|