autotest_analyser.py 5.58 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#! /usr/bin/python
#******************************************************************************
#
# \file		autotest_analyser.py
#
# \par     Informations
#            - \b Project  : UED Autotest Framework
#            - \b Software : 
#
# \date		16 september 2016
#
# \version	0.1
#
# \brief	helper to test lib_autotest_analyser.py
#
# \author	Benoit ROBERT (benoit.robert@syrtem.com)
#
# \par		Statement of Ownership
#           COPYRIGHT (c) 2016  BY SYRTEM S.A.R.L
#           This software is furnished under license and may be used and copied 
#			only in accordance with the terms of such license and with the inclusion
#			of the above COPYRIGHT notice. This SOFTWARE or any other copies thereof
#			may not be provided or otherwise made available to any other person. 
#			No title to and ownership of the SOFTWARE is hereby transferred.
#
#			The information in this SOFTWARE is subject to change without notice 
#			and should not be constructed as a commitment by SYRTEM.
#           SYRTEM assumes no responsibility for the use or reliability of its 
#			SOFTWARE on equipment or platform not explicitly validated by SYRTEM.
#
# *******************************************************************************

import os
import getopt
import sys
from subprocess import call

38
39
40
import encoder

sys.path.append(os.path.expandvars('$OPENAIR_DIR/cmake_targets/autotests/tools/'))
41
42
43


#test_cases = ('030001', '030901', '031001', '031601', '031701', '031801', '031901', '032001', '032101', '032201', '032301', '032501', '032601', '032801')
44
test_cases = ('032800' , '032730' ) 
45

46
nb_run = 2
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63

def error_opt(msg):
    print("Option error: " + msg)


def main(args):
	try:
		analyser = __import__("lib_autotest_analyser")
	except ImportError as err:
		print('Import error: ' + str(err))
		exit(0)


	log_path = 'log_save_2016-08-14/log/'



64
65
66
67
68
69
70
71
72
73
	# metric = {}
	# metric['id'] 			= 'UE_DLSCH_BITRATE'
	# metric['description'] 	= 'UE downlink physical throughput'	
	# metric['regex'] 		= '(UE_DLSCH_BITRATE) =\s+(\d+\.\d+) kbps.+frame = (\d+)\)'
	# metric['unit_of_meas']	= 'kbps'
	# metric['min_limit']		= 14668.8


#AUTOTEST Metric : RRC Measurments RSRP[0]=-97.60 dBm/RE, RSSI=-72.83 dBm, RSRQ[0] 9.03 dB, N0 -125 dBm/RE, NF 7.2 dB (frame = 4490)

74
	metric = {}
75
76
77
78
79
	metric['id'] 		= 'UE_DL_RRC_MEAS'
	metric['description'] 	= 'UE downlink RRC Measurments'	
	metric['nb_metric']	= 5
#	metric['regex'] 	= 'AUTOTEST Metric : RRC Measurments (RSRP\[0\])=(-?\d+\.?\d*)\s+(.+),\s+(RSRQ\[0\])=(-?\d+\.?\d*)\s+(.+),,\s+(N0)=(-?\d+\.?\d*)\s+(.+),,\s+(NF)=(-?\d+\.?\d*)\s+(.+)\s+\(frame = (\d+)\) '
	metric['regex'] 	= 'AUTOTEST Metric : RRC Measurments (RSRP\[0\])=(-?\d+\.?\d*)\s+(.+)\,\s+(RSSI)=(-?\d+\.?\d*)\s+(.+)\,\s+(RSRQ\[0\])=(-?\d+\.?\d*)\s+(.+)\,\s+(N0)=(-?\d+\.?\d*)\s+(.+)\,\s+(NF)=(-?\d+\.?\d*)\s+(.+)\s+\(frame = (\d+)\)'
80
81
82
83
	metric['unit_of_meas']	= 'kbps'
	metric['min_limit']		= 14668.8


84

85
86
87
88
89
90
91
92
#report_path = log_path+'/report/'

#os.system(' mkdir -p ' + report_path)

#analyser.create_report_html(report_path)

#return(0)

93
	test_results = []
94

95
	for test_case in test_cases:
96
97

		for i in range(0, nb_run):
98
			fname = '..//log//'+test_case+'/run_'+str(i)+'/UE_exec_'+str(i)+'_.log'
99
100
101
			args = {'metric' : metric,
					'file' : fname }

102
103
104
105
106
107
			# cell_synch_status = analyser.check_cell_synchro(fname)
			# if cell_synch_status == 'CELL_SYNCH':
			#   print '!!!!!!!!!!!!!!  Cell synchronized !!!!!!!!!!!'
			#   metric_checks_flag = 0
			# else :
			#   print '!!!!!!!!!!!!!!  Cell NOT  NOT synchronized !!!!!!!!!!!'
108
	
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#			metrics_extracted = analyser.do_extract_metrics_new(args)


			# de-xmlfy test report
			xml_file = '..//log//'+test_case+'/test.'+test_case+'_ng.xml'
			print xml_file

		# 	test_result =


  # 			test_results.append(test_result)

  # xmlFile = logdir_local_testcase + '/test.' + testcasename + '.xml'
  # xml="\n<testcase classname=\'"+ testcaseclass +  "\' name=\'" + testcasename + "."+tags +  "\' Run_result=\'" + test_result_string + "\' time=\'" + str(duration) + " s \' RESULT=\'" + testcase_verdict + "\'></testcase> \n"
  # write_file(xmlFile, xml, mode="w")

  # xmlFile_ng = logdir_local_testcase + '/test.' + testcasename + '_ng.xml'
  # xml_ng = xmlify(test_result, wrap=testcasename, indent="  ")
  # write_file(xmlFile_ng, xml_ng, mode="w")



131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147

#			print "min       = "+ str( metric_extracted['metric_min'] )
#			print "min_index = "+ str( metric_extracted['metric_min_index'] )
#			print "max       = "+ str( metric_extracted['metric_max'] )
#			print "max_index = "+ str( metric_extracted['metric_max_index'] )
#			print "mean      = "+ str( metric_extracted['metric_mean'] )
#			print "median    = "+ str( metric_extracted['metric_median'] )			

#			verdict = analyser.do_check_verdict(metric, metric_extracted)
#			print verdict

#			fname= 'report/2016-9-8_toto/'+test_case+'/UE_metric_UE_DLSCH_BITRATE_'+str(i)+'_.png'
#			fname= 'report/UE_metric_UE_DLSCH_BITRATE_'+test_case+'_'+str(i)+'.png'
			
#			print fname
#			analyser.do_img_metrics(metric, metric_extracted, fname)

148
			# fname = 'log//'+test_case+'/run_'+str(i)+'/UE_traffic_'+str(i)+'_.log'
149
			
150
			# args = {'file' : fname }
151

152
			# traffic_metrics = analyser.do_extract_traffic_metrics(args)
153

154
			# fname= 'report/iperf_'+test_case+'_'+str(i)+'.png'
155
			
156
157
158
159
160
161
162
163
164
165
166
167
168
			# print fname
			# analyser.do_img_traffic(traffic_metrics, fname)


	for test_result in test_results:
	  cmd = 'mkdir -p ' + report_dir + '/'+ test_result['testcase_name']
	  result = os.system(cmd)

	  report_file = report_dir + '/'+ test_result['testcase_name'] + '/'+ test_result['testcase_name']+ '_report.html'

	  analyser.create_test_report_detailed_html(test_result, report_file )

	  print test_result
169
170
171
172
173
174



if __name__ == "__main__":
    main(sys.argv)