testability-driver 0.9.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (214) hide show
  1. data/README +1 -0
  2. data/bin/start_app_perf +199 -0
  3. data/bin/tdriver-devtools +3 -0
  4. data/config/sut_parameters.rb +39 -0
  5. data/ext/extconf.rb +67 -0
  6. data/ext/native_extensions.c +70 -0
  7. data/lib/matti.rb +30 -0
  8. data/lib/tdriver-devtools/behaviour/old/xml/example/flick-example.rb +223 -0
  9. data/lib/tdriver-devtools/behaviour/old/xml/example/impl.rb_invalid +194 -0
  10. data/lib/tdriver-devtools/behaviour/old/xml/generate_behaviour_xml.rb +95 -0
  11. data/lib/tdriver-devtools/behaviour/old/xml/lib/tdriver_generator.rb +722 -0
  12. data/lib/tdriver-devtools/behaviour/old/xml/qdoc_generator.rb +321 -0
  13. data/lib/tdriver-devtools/behaviour/old/xml/templates/behaviour.method.template +43 -0
  14. data/lib/tdriver-devtools/behaviour/old/xml/templates/behaviour.module.template +54 -0
  15. data/lib/tdriver-devtools/behaviour/old/xml/templates/behaviour.xml.argument.template +7 -0
  16. data/lib/tdriver-devtools/behaviour/old/xml/templates/behaviour.xml.argument_type.template +7 -0
  17. data/lib/tdriver-devtools/behaviour/old/xml/templates/behaviour.xml.exception.template +5 -0
  18. data/lib/tdriver-devtools/behaviour/old/xml/templates/behaviour.xml.howto.line.template +2 -0
  19. data/lib/tdriver-devtools/behaviour/old/xml/templates/behaviour.xml.howto.template +5 -0
  20. data/lib/tdriver-devtools/behaviour/old/xml/templates/behaviour.xml.method.template +23 -0
  21. data/lib/tdriver-devtools/behaviour/old/xml/templates/behaviour.xml.template +14 -0
  22. data/lib/tdriver-devtools/behaviour/old/xml/update +3 -0
  23. data/lib/tdriver-devtools/behaviour/xml/generate.rb +88 -0
  24. data/lib/tdriver-devtools/behaviour/xml/rdoc_behaviour_xml_generator.rb +1924 -0
  25. data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.argument.default.template +1 -0
  26. data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.argument.template +3 -0
  27. data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.argument_type.template +4 -0
  28. data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.exception.template +4 -0
  29. data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.method.arguments.template +4 -0
  30. data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.method.deprecated.template +3 -0
  31. data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.method.exceptions.template +3 -0
  32. data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.method.info.template +1 -0
  33. data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.method.returns.template +3 -0
  34. data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.method.tables.template +3 -0
  35. data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.method.template +12 -0
  36. data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.returns.template +5 -0
  37. data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.table.item.template +1 -0
  38. data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.table.row.template +2 -0
  39. data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.table.template +8 -0
  40. data/lib/tdriver-devtools/behaviour/xml/templates/behaviour.xml.template +14 -0
  41. data/lib/tdriver-devtools/behaviour/xml_generator/example/flick-example.rb +245 -0
  42. data/lib/tdriver-devtools/behaviour/xml_generator/example/sut.rb +964 -0
  43. data/lib/tdriver-devtools/behaviour/xml_generator/generate.rb +68 -0
  44. data/lib/tdriver-devtools/behaviour/xml_generator/lib/custom_rdoc_generator.rb +1865 -0
  45. data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.argument.default.template +1 -0
  46. data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.argument.template +3 -0
  47. data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.argument_type.template +4 -0
  48. data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.exception.template +4 -0
  49. data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.method.arguments.template +4 -0
  50. data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.method.deprecated.template +3 -0
  51. data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.method.exceptions.template +3 -0
  52. data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.method.info.template +1 -0
  53. data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.method.returns.template +3 -0
  54. data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.method.tables.template +3 -0
  55. data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.method.template +12 -0
  56. data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.returns.template +5 -0
  57. data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.table.item.template +1 -0
  58. data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.table.row.template +2 -0
  59. data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.table.template +7 -0
  60. data/lib/tdriver-devtools/behaviour/xml_generator/templates/behaviour.xml.template +14 -0
  61. data/lib/tdriver-devtools/behaviour/xml_generator/update +3 -0
  62. data/lib/tdriver-devtools/doc/behaviour_xml/QtExampleGestureBehaviour.xml +138 -0
  63. data/lib/tdriver-devtools/doc/behaviour_xml/created.rid +1 -0
  64. data/lib/tdriver-devtools/doc/behaviour_xml/tdriver.hash +1 -0
  65. data/lib/tdriver-devtools/doc/feature_xml/qt_widget_hold.feature.xml +9 -0
  66. data/lib/tdriver-devtools/doc/feature_xml/qt_widget_tap.feature.xml +9 -0
  67. data/lib/tdriver-devtools/doc/generate.rb +892 -0
  68. data/lib/tdriver-devtools/doc/update +1 -0
  69. data/lib/tdriver-devtools/doc/xslt/html.rb +7 -0
  70. data/lib/tdriver-devtools/doc/xslt/template.xsl +1861 -0
  71. data/lib/tdriver-devtools/doc/xslt/update +3 -0
  72. data/lib/tdriver-devtools/plugin/placeholder.txt +1 -0
  73. data/lib/tdriver-devtools/tdriver-devtools.rb +404 -0
  74. data/lib/tdriver-devtools/tests/feature_tests/example/flick-example.rb +233 -0
  75. data/lib/tdriver-devtools/tests/feature_tests/example/impl.rb +194 -0
  76. data/lib/tdriver-devtools/tests/feature_tests/generate.rb +82 -0
  77. data/lib/tdriver-devtools/tests/feature_tests/lib/custom_rdoc_generator.rb +468 -0
  78. data/lib/tdriver-devtools/tests/feature_tests/templates/feature_attribute.template +5 -0
  79. data/lib/tdriver-devtools/tests/feature_tests/templates/feature_method.template +5 -0
  80. data/lib/tdriver-devtools/tests/feature_tests/templates/scenario_attribute.template +5 -0
  81. data/lib/tdriver-devtools/tests/feature_tests/templates/scenario_method.template +5 -0
  82. data/lib/tdriver-devtools/tests/feature_tests/update +3 -0
  83. data/lib/tdriver.rb +26 -0
  84. data/lib/tdriver/base/behaviour/behaviour.rb +32 -0
  85. data/lib/tdriver/base/behaviour/behaviours/object_behaviour_composition.rb +94 -0
  86. data/lib/tdriver/base/behaviour/behaviours/object_behaviour_description.rb +262 -0
  87. data/lib/tdriver/base/behaviour/behaviours/object_composition.rb +111 -0
  88. data/lib/tdriver/base/behaviour/factory.rb +380 -0
  89. data/lib/tdriver/base/behaviour/loader.rb +28 -0
  90. data/lib/tdriver/base/command_data/command_data.rb +51 -0
  91. data/lib/tdriver/base/command_data/loader.rb +25 -0
  92. data/lib/tdriver/base/errors.rb +131 -0
  93. data/lib/tdriver/base/loader.rb +38 -0
  94. data/lib/tdriver/base/state_object.rb +270 -0
  95. data/lib/tdriver/base/sut/adapter.rb +28 -0
  96. data/lib/tdriver/base/sut/controller.rb +119 -0
  97. data/lib/tdriver/base/sut/factory.rb +287 -0
  98. data/lib/tdriver/base/sut/generic/behaviours/application.rb +243 -0
  99. data/lib/tdriver/base/sut/generic/behaviours/controller.rb +67 -0
  100. data/lib/tdriver/base/sut/generic/behaviours/find.rb +96 -0
  101. data/lib/tdriver/base/sut/generic/behaviours/flash_behaviour.rb +346 -0
  102. data/lib/tdriver/base/sut/generic/behaviours/sut.rb +1268 -0
  103. data/lib/tdriver/base/sut/generic/behaviours/switchbox_behaviour.rb +182 -0
  104. data/lib/tdriver/base/sut/generic/behaviours/verification.rb +119 -0
  105. data/lib/tdriver/base/sut/generic/commands/application.rb +219 -0
  106. data/lib/tdriver/base/sut/generic/commands/key_sequence.rb +82 -0
  107. data/lib/tdriver/base/sut/generic/commands/screen_capture.rb +58 -0
  108. data/lib/tdriver/base/sut/generic/plugin.rb +96 -0
  109. data/lib/tdriver/base/sut/loader.rb +35 -0
  110. data/lib/tdriver/base/sut/sut.rb +67 -0
  111. data/lib/tdriver/base/test_object/abstract.rb +179 -0
  112. data/lib/tdriver/base/test_object/behaviours/syncronization.rb +94 -0
  113. data/lib/tdriver/base/test_object/behaviours/test_object.rb +787 -0
  114. data/lib/tdriver/base/test_object/factory.rb +618 -0
  115. data/lib/tdriver/base/test_object/identificator.rb +511 -0
  116. data/lib/tdriver/base/test_object/loader.rb +37 -0
  117. data/lib/tdriver/env.rb +21 -0
  118. data/lib/tdriver/loader.rb +36 -0
  119. data/lib/tdriver/matti.rb +35 -0
  120. data/lib/tdriver/report/error_recovery/tdriver_custom_error_recovery.rb +83 -0
  121. data/lib/tdriver/report/error_recovery/tdriver_error_recovery.rb +158 -0
  122. data/lib/tdriver/report/error_recovery/tdriver_error_recovery_settings.rb +98 -0
  123. data/lib/tdriver/report/report.rb +47 -0
  124. data/lib/tdriver/report/report_api.rb +207 -0
  125. data/lib/tdriver/report/report_combine.rb +86 -0
  126. data/lib/tdriver/report/report_crash_file_capture.rb +167 -0
  127. data/lib/tdriver/report/report_creator.rb +571 -0
  128. data/lib/tdriver/report/report_cucumber.rb +158 -0
  129. data/lib/tdriver/report/report_cucumber_listener.rb +337 -0
  130. data/lib/tdriver/report/report_cucumber_reporter.rb +335 -0
  131. data/lib/tdriver/report/report_data_presentation.rb +152 -0
  132. data/lib/tdriver/report/report_data_table.rb +64 -0
  133. data/lib/tdriver/report/report_execution_statistics.rb +284 -0
  134. data/lib/tdriver/report/report_file_capture.rb +159 -0
  135. data/lib/tdriver/report/report_grouping.rb +539 -0
  136. data/lib/tdriver/report/report_junit_xml.rb +147 -0
  137. data/lib/tdriver/report/report_rspec.rb +108 -0
  138. data/lib/tdriver/report/report_test_case_run.rb +621 -0
  139. data/lib/tdriver/report/report_test_run.rb +1286 -0
  140. data/lib/tdriver/report/report_test_unit.rb +175 -0
  141. data/lib/tdriver/report/report_writer.rb +1405 -0
  142. data/lib/tdriver/tdriver.rb +158 -0
  143. data/lib/tdriver/util/common.rb +24 -0
  144. data/lib/tdriver/util/common/array.rb +39 -0
  145. data/lib/tdriver/util/common/crc16.rb +100 -0
  146. data/lib/tdriver/util/common/environment.rb +153 -0
  147. data/lib/tdriver/util/common/error.rb +39 -0
  148. data/lib/tdriver/util/common/file.rb +315 -0
  149. data/lib/tdriver/util/common/gem.rb +108 -0
  150. data/lib/tdriver/util/common/kernel.rb +189 -0
  151. data/lib/tdriver/util/common/loader.rb +39 -0
  152. data/lib/tdriver/util/common/retryable.rb +98 -0
  153. data/lib/tdriver/util/common/string.rb +77 -0
  154. data/lib/tdriver/util/dbaccess/dbaccess.rb +188 -0
  155. data/lib/tdriver/util/dbaccess/dbconnection.rb +41 -0
  156. data/lib/tdriver/util/dbaccess/error.rb +35 -0
  157. data/lib/tdriver/util/dbaccess/loader.rb +29 -0
  158. data/lib/tdriver/util/dynamic_attribute_filter.rb +182 -0
  159. data/lib/tdriver/util/hooking.rb +434 -0
  160. data/lib/tdriver/util/loader.rb +65 -0
  161. data/lib/tdriver/util/localisation.rb +24 -0
  162. data/lib/tdriver/util/localisation/error.rb +32 -0
  163. data/lib/tdriver/util/localisation/loader.rb +28 -0
  164. data/lib/tdriver/util/localisation/localisation.rb +479 -0
  165. data/lib/tdriver/util/logger.rb +377 -0
  166. data/lib/tdriver/util/operator_data/error.rb +29 -0
  167. data/lib/tdriver/util/operator_data/loader.rb +26 -0
  168. data/lib/tdriver/util/operator_data/operator_data.rb +93 -0
  169. data/lib/tdriver/util/other/config.rb +221 -0
  170. data/lib/tdriver/util/parameter.rb +24 -0
  171. data/lib/tdriver/util/parameter/error.rb +45 -0
  172. data/lib/tdriver/util/parameter/loader.rb +37 -0
  173. data/lib/tdriver/util/parameter/parameter.rb +285 -0
  174. data/lib/tdriver/util/parameter/parameter_hash.rb +101 -0
  175. data/lib/tdriver/util/parameter/parameter_template.rb +120 -0
  176. data/lib/tdriver/util/parameter/parameter_user_api.rb +84 -0
  177. data/lib/tdriver/util/parameter/parameter_xml.rb +247 -0
  178. data/lib/tdriver/util/plugin/abstract.rb +60 -0
  179. data/lib/tdriver/util/plugin/error.rb +25 -0
  180. data/lib/tdriver/util/plugin/loader.rb +28 -0
  181. data/lib/tdriver/util/plugin/service.rb +200 -0
  182. data/lib/tdriver/util/recorder.rb +292 -0
  183. data/lib/tdriver/util/stats.rb +90 -0
  184. data/lib/tdriver/util/user_data/error.rb +29 -0
  185. data/lib/tdriver/util/user_data/loader.rb +26 -0
  186. data/lib/tdriver/util/user_data/user_data.rb +103 -0
  187. data/lib/tdriver/util/video_rec.rb +264 -0
  188. data/lib/tdriver/util/xml/abstraction.rb +47 -0
  189. data/lib/tdriver/util/xml/builder.rb +54 -0
  190. data/lib/tdriver/util/xml/document.rb +32 -0
  191. data/lib/tdriver/util/xml/element.rb +32 -0
  192. data/lib/tdriver/util/xml/error.rb +46 -0
  193. data/lib/tdriver/util/xml/loader.rb +46 -0
  194. data/lib/tdriver/util/xml/nil_element.rb +89 -0
  195. data/lib/tdriver/util/xml/nodeset.rb +32 -0
  196. data/lib/tdriver/util/xml/parsers/libxml/libxml.rb +140 -0
  197. data/lib/tdriver/util/xml/parsers/loader.rb +22 -0
  198. data/lib/tdriver/util/xml/parsers/nokogiri/abstraction.rb +111 -0
  199. data/lib/tdriver/util/xml/parsers/nokogiri/attribute.rb +54 -0
  200. data/lib/tdriver/util/xml/parsers/nokogiri/builder.rb +58 -0
  201. data/lib/tdriver/util/xml/parsers/nokogiri/document.rb +58 -0
  202. data/lib/tdriver/util/xml/parsers/nokogiri/element.rb +147 -0
  203. data/lib/tdriver/util/xml/parsers/nokogiri/loader.rb +42 -0
  204. data/lib/tdriver/util/xml/parsers/nokogiri/nodeset.rb +187 -0
  205. data/lib/tdriver/util/xml/xml.rb +170 -0
  206. data/lib/tdriver/verify/verify.rb +687 -0
  207. data/lib/tdriver/verify/verify.rb_org +630 -0
  208. data/lib/tdriver/version.rb +21 -0
  209. data/xml/behaviours/generic.xml +495 -0
  210. data/xml/defaults/generic.xml +97 -0
  211. data/xml/defaults/sut_generic.xml +36 -0
  212. data/xml/parameters/tdriver_parameters.xml +23 -0
  213. data/xml/templates/generic.xml +227 -0
  214. metadata +327 -0
@@ -0,0 +1,1286 @@
1
+ ############################################################################
2
+ ##
3
+ ## Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
4
+ ## All rights reserved.
5
+ ## Contact: Nokia Corporation (testabilitydriver@nokia.com)
6
+ ##
7
+ ## This file is part of TDriver.
8
+ ##
9
+ ## If you have questions regarding the use of this file, please contact
10
+ ## Nokia at testabilitydriver@nokia.com .
11
+ ##
12
+ ## This library is free software; you can redistribute it and/or
13
+ ## modify it under the terms of the GNU Lesser General Public
14
+ ## License version 2.1 as published by the Free Software Foundation
15
+ ## and appearing in the file LICENSE.LGPL included in the packaging
16
+ ## of this file.
17
+ ##
18
+ ############################################################################
19
+
20
+
21
+ module TDriverReportCreator
22
+
23
+ #Test run class for new test run
24
+ class TestRun < ReportCombine
25
+ include TDriverReportWriter
26
+ include ReportDataTable
27
+ attr_accessor(
28
+ :report_folder,
29
+ :reporting_groups,
30
+ :generic_reporting_groups,
31
+ :start_time,
32
+ :end_time,
33
+ :run_time,
34
+ :total_run,
35
+ :total_passed,
36
+ :total_failed,
37
+ :total_not_run,
38
+ :total_crash_files,
39
+ :total_device_resets,
40
+ :test_case_user_defined_status,
41
+ :test_run_behaviour_log,
42
+ :test_run_user_log,
43
+ :test_case_user_data,
44
+ :test_case_user_data_columns,
45
+ :test_case_user_chronological_table_data,
46
+ :attached_test_reports,
47
+ :report_pages_ready,
48
+ :memory_amount_start,
49
+ :memory_amount_end,
50
+ :memory_amount_total,
51
+ :total_dump_count,
52
+ :total_received_data,
53
+ :total_sent_data,
54
+ :result_storage_in_use,
55
+ :pages,
56
+ :duration_graph,
57
+ :pass_statuses,
58
+ :fail_statuses,
59
+ :not_run_statuses,
60
+ :report_editable
61
+ )
62
+ #class variables for summary report
63
+ def initialize()
64
+ @report_folder=nil
65
+ @reporting_groups=nil
66
+ @generic_reporting_groups=''
67
+ @start_time=nil
68
+ @end_time=nil
69
+ @run_time=nil
70
+ @total_run=0
71
+ @total_passed=0
72
+ @total_failed=0
73
+ @total_not_run=0
74
+ @total_crash_files=0
75
+ @total_device_resets=0
76
+ @test_case_user_defined_status=nil
77
+ @test_run_behaviour_log = Array.new
78
+ @test_run_user_log = Array.new
79
+ @test_case_user_data=Array.new
80
+ @test_case_user_data_columns = Array.new
81
+ @test_case_user_chronological_table_data = Hash.new
82
+ @attached_test_reports = Array.new
83
+ @report_pages_ready=Array.new
84
+ @memory_amount_start='-'
85
+ @memory_amount_end='-'
86
+ @memory_amount_total='-'
87
+ @total_dump_count=Hash.new
88
+ @total_received_data=Hash.new
89
+ @total_sent_data=Hash.new
90
+ $result_storage_in_use=false
91
+ @pages=MobyUtil::Parameter[ :report_results_per_page, 10]
92
+ @duration_graph=MobyUtil::Parameter[ :report_generate_duration_graph, false]
93
+ @pass_statuses=MobyUtil::Parameter[ :report_passed_statuses, "passed" ].split('|')
94
+ @fail_statuses=MobyUtil::Parameter[ :report_failed_statuses, "failed" ].split('|')
95
+ @not_run_statuses=MobyUtil::Parameter[ :report_not_run_statuses, "not run" ].split('|')
96
+ @report_editable=MobyUtil::Parameter[ :report_editable, "false" ]
97
+ end
98
+ #This method sets the test case user defined status
99
+ #
100
+ # === params
101
+ # value: test case status
102
+ # === returns
103
+ # nil
104
+ # === raises
105
+ def set_test_case_user_defined_status(value)
106
+ @test_case_user_defined_status=value
107
+ end
108
+ #This method sets user created log
109
+ #
110
+ # === params
111
+ # value: test run execution log entry
112
+ # === returns
113
+ # nil
114
+ # === raises
115
+ def set_log(value)
116
+ if value==nil
117
+ @test_run_user_log=nil
118
+ @test_run_user_log=Array.new
119
+ else
120
+ @test_run_user_log << ["USER LOG: #{value.to_s}"]
121
+ end
122
+ end
123
+ #This method adds user data
124
+ #
125
+ # === params
126
+ # value: the data to be added an array or hash
127
+ # === returns
128
+ # nil
129
+ # === raises
130
+ # TypeError exception
131
+ def set_user_data(value)
132
+ if value==nil
133
+ @test_case_user_data = Array.new
134
+ @test_case_user_data_columns = Array.new
135
+ else
136
+ raise TypeError.new( 'Input parameter not of Type: Hash or Array.\nIt is: ' + value.class.to_s ) unless value.kind_of?( Hash ) || value.kind_of?( Array )
137
+ if value.kind_of?( Hash )
138
+ add_data_from_hash(value,@test_case_user_data,@test_case_user_data_columns)
139
+ end
140
+ if value.kind_of?( Array )
141
+ add_data_from_array(value,@test_case_user_data,@test_case_user_data_columns)
142
+ end
143
+ end
144
+ end
145
+ #This method adds user table data
146
+ #
147
+ # === params
148
+ # column_name: the column name in chronological table
149
+ # value: the data
150
+ # === returns
151
+ # nil
152
+ # === raises
153
+ def set_user_table_data(column_name,value)
154
+ if (!column_name.empty? && column_name!=nil)
155
+ @test_case_user_chronological_table_data[column_name.to_s]=value.to_s
156
+ end
157
+ end
158
+ #This method sets the test run behaviour log
159
+ #
160
+ # === params
161
+ # value: test run execution log entry
162
+ # === returns
163
+ # nil
164
+ # === raises
165
+ def set_test_run_behaviour_log(value,test_case)
166
+ @test_run_behaviour_log << [value.to_s,test_case]
167
+ end
168
+ #This method sets generic reporting groups
169
+ #
170
+ # === params
171
+ #
172
+ # === returns
173
+ # nil
174
+ # === raises
175
+ def set_generic_reporting_groups(value)
176
+ if check_if_group_exists_groups(@generic_reporting_groups,value)==false
177
+ @generic_reporting_groups=@generic_reporting_groups+value
178
+ end
179
+ get_reporting_groups()
180
+ end
181
+ #This method sets the report folder value
182
+ #
183
+ # === params
184
+ # value: test set report folder
185
+ # === returns
186
+ # nil
187
+ # === raises
188
+ def set_report_folder(value)
189
+ @report_folder=value
190
+ end
191
+ #This method sets the test run start time
192
+ #
193
+ # === params
194
+ # value: test set start time
195
+ # === returns
196
+ # nil
197
+ # === raises
198
+ def set_start_time(value)
199
+ @start_time=value
200
+ end
201
+ #This method sets the test run end time
202
+ #
203
+ # === params
204
+ # value: test set end time
205
+ # === returns
206
+ # nil
207
+ # === raises
208
+ def set_end_time(value)
209
+ @end_time=value
210
+ end
211
+ #This method sets the test run run time
212
+ #
213
+ # === params
214
+ # value: test set run time
215
+ # === returns
216
+ # nil
217
+ # === raises
218
+ def set_run_time(value)
219
+ @run_time=value
220
+ end
221
+ #This method sets the total tests run
222
+ #
223
+ # === params
224
+ # value: total run value
225
+ # === returns
226
+ # nil
227
+ # === raises
228
+ def set_total_run(value)
229
+ if value==1
230
+ @total_run=@total_run.to_i+1
231
+ else
232
+ @total_run=value
233
+ end
234
+ end
235
+ #This method sets the total passed tests run
236
+ #
237
+ # === params
238
+ # value: total passed value
239
+ # === returns
240
+ # nil
241
+ # === raises
242
+ def set_total_passed(value)
243
+ if value==1
244
+ @total_passed=@total_passed.to_i+1
245
+ else
246
+ @total_passed=value
247
+ end
248
+ end
249
+ #This method sets the total failed tests run
250
+ #
251
+ # === params
252
+ # value: total failed value
253
+ # === returns
254
+ # nil
255
+ # === raises
256
+ def set_total_failed(value)
257
+ if value==1
258
+ @total_failed=@total_failed.to_i+1
259
+ else
260
+ @total_failed=value
261
+ end
262
+ end
263
+ #This method sets the total amount of not run cases
264
+ #
265
+ # === params
266
+ # value: total not run value
267
+ # === returns
268
+ # nil
269
+ # === raises
270
+ def set_total_not_run(value)
271
+ if value==1
272
+ @total_not_run=@total_not_run.to_i+1
273
+ else
274
+ @total_not_run=value
275
+ end
276
+ end
277
+ #This method sets the total amount of found crash files
278
+ #
279
+ # === params
280
+ # value: total not run value
281
+ # === returns
282
+ # nil
283
+ # === raises
284
+ def set_total_crash_files(value)
285
+ @total_crash_files=@total_crash_files.to_i+value.to_i
286
+ end
287
+ #This method sets the total amount of device resets
288
+ #
289
+ # === params
290
+ # value: total not run value
291
+ # === returns
292
+ # nil
293
+ # === raises
294
+ def set_total_device_resets(value)
295
+ @total_device_resets=@total_device_resets.to_i+value.to_i
296
+ end
297
+
298
+ #This method sets the memory amount end
299
+ #
300
+ # === params
301
+ #
302
+ # === returns
303
+ # nil
304
+ # === raises
305
+ def set_memory_amount_end(value)
306
+ @memory_amount_end=value
307
+ end
308
+ #This method sets the memory amount start
309
+ #
310
+ # === params
311
+ #
312
+ # === returns
313
+ # nil
314
+ # === raises
315
+ def set_memory_amount_start(value)
316
+ @memory_amount_start=value
317
+ end
318
+ #This method sets the memory amount total
319
+ #
320
+ # === params
321
+ #
322
+ # === returns
323
+ # nil
324
+ # === raises
325
+ def set_memory_amount_total(value)
326
+ @memory_amount_total=value
327
+ end
328
+
329
+ #This method gets the not run cases name array
330
+ #
331
+ # === params
332
+ #
333
+ # === returns
334
+ # nil
335
+ # === raises
336
+ def get_not_run_cases_arr()
337
+ #@not_run_cases_arr
338
+ read_result_storage('not run')
339
+ end
340
+ #This method gets the passed cases name array
341
+ #
342
+ # === params
343
+ #
344
+ # === returns
345
+ # nil
346
+ # === raises
347
+ def get_passed_cases_arr()
348
+ #@passed_cases_arr
349
+ read_result_storage('passed')
350
+ end
351
+ #This method gets the failed cases name array
352
+ #
353
+ # === params
354
+ #
355
+ # === returns
356
+ # nil
357
+ # === raises
358
+ def get_failed_cases_arr()
359
+ #@failed_cases_arr
360
+ read_result_storage('failed')
361
+ end
362
+ #This method gets the failed cases name array
363
+ #
364
+ # === params
365
+ #
366
+ # === returns
367
+ # nil
368
+ # === raises
369
+ def get_all_cases_arr()
370
+ #@all_cases_arr
371
+ read_result_storage('all')
372
+ end
373
+
374
+ #This method gets reporting groups
375
+ #
376
+ # === params
377
+ #
378
+ # === returns
379
+ # nil
380
+ # === raises
381
+ def get_reporting_groups()
382
+ @reporting_groups=MobyUtil::Parameter[ :report_groups, nil ]
383
+ if @reporting_groups==nil
384
+ @reporting_groups=@generic_reporting_groups
385
+ end
386
+ @reporting_groups
387
+ end
388
+
389
+ #This method gets user created data
390
+ #
391
+ # === params
392
+ # nil
393
+ # === returns
394
+ # the testcase data and column objects
395
+ # === raises
396
+ def get_user_data()
397
+ return @test_case_user_data,@test_case_user_data_columns
398
+ end
399
+
400
+ #This method sets user data to display in chronological table
401
+ #
402
+ # === params
403
+ # nil
404
+ # === returns
405
+ # the testcase data and column objects
406
+ # === raises
407
+ def set_user_chronological_table_data(value)
408
+ if (value==nil)
409
+ @test_case_user_chronological_table_data=Hash.new
410
+ else
411
+ @test_case_user_chronological_table_data=value
412
+ end
413
+ end
414
+ #This method will parse duplicate groups out
415
+ #
416
+ # === params
417
+ #
418
+ # === returns
419
+ # nil
420
+ # === raises
421
+ def check_if_group_exists_groups(groups,new_group_item)
422
+ if groups.include? new_group_item
423
+ true
424
+ else
425
+ false
426
+ end
427
+ end
428
+ #This method creates a new TDriver test report folder when testing is started
429
+ #
430
+ # === params
431
+ # nil
432
+ # === returns
433
+ # nil
434
+ # === raises
435
+ def initialize_tdriver_report_folder()
436
+ t = Time.now
437
+ b_fixed_report_folder=false
438
+ @start_time=t
439
+ @reporter_base_folder = MobyUtil::Parameter[ :report_outputter_path, 'tdriver_reports/' ]
440
+ if MobyUtil::Parameter[ :report_outputter_folder, nil ] != nil
441
+ @report_folder=@reporter_base_folder+MobyUtil::Parameter[ :report_outputter_folder, nil ]
442
+ b_fixed_report_folder=true
443
+ else
444
+ @report_folder=@reporter_base_folder+"test_run_"+t.strftime( "%Y%m%d%H%M%S" )
445
+ end
446
+
447
+ begin
448
+ #check if report directory exists
449
+ if File::directory?(@report_folder)==false
450
+ FileUtils.mkdir_p @report_folder+'/environment'
451
+ FileUtils.mkdir_p @report_folder+'/cases'
452
+ FileUtils.mkdir_p @report_folder+'/junit_xml'
453
+
454
+ else
455
+ if b_fixed_report_folder==true
456
+ FileUtils::remove_entry_secure(@report_folder, :force => true)
457
+ FileUtils.mkdir_p @report_folder+'/environment'
458
+ FileUtils.mkdir_p @report_folder+'/cases'
459
+ FileUtils.mkdir_p @report_folder+'/junit_xml'
460
+ end
461
+ end
462
+ write_style_sheet(@report_folder+'/tdriver_report_style.css')
463
+ write_page_start(@report_folder+'/cases/1_passed_index.html','Passed')
464
+ write_page_end(@report_folder+'/cases/1_passed_index.html')
465
+ write_page_start(@report_folder+'/cases/1_failed_index.html','Failed')
466
+ write_page_end(@report_folder+'/cases/1_failed_index.html')
467
+ write_page_start(@report_folder+'/cases/1_not_run_index.html','Not run')
468
+ write_page_end(@report_folder+'/cases/1_not_run_index.html')
469
+ write_page_start(@report_folder+'/cases/1_total_run_index.html','Total run')
470
+ write_page_end(@report_folder+'/cases/1_total_run_index.html')
471
+ #write_page_start(@report_folder+'/cases/tdriver_log_index.html','TDriver log')
472
+ #write_page_end(@report_folder+'/cases/tdriver_log_index.html')
473
+ write_page_start(@report_folder+'/cases/statistics_index.html','Statistics')
474
+ write_page_end(@report_folder+'/cases/statistics_index.html')
475
+ rescue Exception => e
476
+ Kernel::raise e, "Unable to create report folder", caller
477
+ end
478
+ return nil
479
+ end
480
+
481
+ #This method updates the tdriver test run summary page
482
+ #
483
+ # === params
484
+ # nil
485
+ # === returns
486
+ # nil
487
+ # === raises
488
+ def update_summary_page(status)
489
+ begin
490
+ #Calculate run time
491
+ @run_time=Time.now-@start_time
492
+ if status=='inprogress'
493
+ write_page_start(@report_folder+'/index.html','TDriver test results')
494
+ write_summary_body(@report_folder+'/index.html',@start_time,'Tests Ongoing...',@run_time,@total_run,@total_passed,@total_failed,@total_not_run,@total_crash_files,@total_device_resets)
495
+ write_page_end(@report_folder+'/index.html')
496
+ else
497
+ all_cases_arr=read_result_storage('all')
498
+ write_page_start(@report_folder+'/index.html','TDriver test results')
499
+ write_summary_body(@report_folder+'/index.html',@start_time,@end_time,@run_time,@total_run,@total_passed,@total_failed,@total_not_run,@total_crash_files,@total_device_resets,all_cases_arr)
500
+ write_page_end(@report_folder+'/index.html')
501
+ end
502
+ rescue Exception => e
503
+ Kernel::raise e, "Unable to update summary page", caller
504
+ end
505
+ return nil
506
+ end
507
+ #This method updates the tdriver test run enviroment page
508
+ #
509
+ # === params
510
+ # nil
511
+ # === returns
512
+ # nil
513
+ # === raises
514
+ def update_environment_page()
515
+ begin
516
+ sw_version='-'
517
+ variant='-'
518
+ product='-'
519
+ language='-'
520
+ loc='-'
521
+ #Copy behaviour and parameter xml files in to the report folder
522
+ if /win/ =~ MobyUtil::EnvironmentHelper.ruby_platform
523
+ FileUtils.cp_r 'C:/tdriver/behaviours', @report_folder+'/environment' if File.directory?('C:/tdriver/behaviours')
524
+ FileUtils.cp_r 'C:/tdriver/templates', @report_folder+'/environment' if File.directory?('C:/tdriver/templates')
525
+ FileUtils.cp_r 'C:/tdriver/defaults', @report_folder+'/environment' if File.directory?('C:/tdriver/defaults')
526
+ FileUtils.copy('C:/tdriver/tdriver_parameters.xml',@report_folder+'/environment/tdriver_parameters.xml') if File.file?('C:/tdriver/tdriver_parameters.xml')
527
+ else
528
+ FileUtils.cp_r '/etc/tdriver/behaviours', @report_folder+'/environment' if File.directory?('/etc/tdriver/behaviours')
529
+ FileUtils.cp_r '/etc/tdriver/templates', @report_folder+'/environment' if File.directory?('/etc/tdriver/templates')
530
+ FileUtils.cp_r '/etc/tdriver/defaults', @report_folder+'/environment' if File.directory?('/etc/tdriver/defaults')
531
+ FileUtils.copy('/etc/tdriver/tdriver_parameters.xml',@report_folder+'/environment/tdriver_parameters.xml') if File.file?('/etc/tdriver/tdriver_parameters.xml')
532
+ end
533
+ if MobyUtil::Parameter[ :report_monitor_memory, 'false']=='true'
534
+ MobyBase::SUTFactory.instance.connected_suts.each do |sut_id, sut_attributes|
535
+ if sut_attributes[:is_connected]
536
+ @memory_amount_start=get_sut_used_memory(sut_id, sut_attributes) if @memory_amount_start==nil || @memory_amount_start=='-'
537
+ @memory_amount_end=get_sut_used_memory(sut_id, sut_attributes)
538
+ @memory_amount_total=get_sut_total_memory(sut_id, sut_attributes)
539
+ @memory_amount_start='-' if @memory_amount_start==nil
540
+ @memory_amount_end='-' if @memory_amount_end==nil
541
+ @memory_amount_total='-' if @memory_amount_total==nil
542
+ end
543
+ end
544
+ end
545
+ if MobyUtil::Parameter[ :report_collect_environment_data_from_sut, 'true']=='true'
546
+ MobyBase::SUTFactory.instance.connected_suts.each do |sut_id, sut_attributes|
547
+ begin
548
+ if sut_attributes[:is_connected]
549
+ sw_version=get_sut_sw_version(sut_id, sut_attributes)
550
+ variant=get_sut_lang_version(sut_id, sut_attributes)
551
+ @memory_amount_start=get_sut_used_memory(sut_id, sut_attributes) if @memory_amount_start==nil || @memory_amount_start=='-'
552
+ @memory_amount_end=get_sut_used_memory(sut_id, sut_attributes)
553
+ @memory_amount_total=get_sut_total_memory(sut_id, sut_attributes)
554
+ product=MobyUtil::Parameter[sut_id][:product]
555
+ language=MobyUtil::Parameter[sut_id][:language]
556
+ loc=MobyUtil::Parameter[sut_id][:localisation_server_database_tablename]
557
+ end
558
+ @memory_amount_start='-' if @memory_amount_start==nil
559
+ @memory_amount_end='-' if @memory_amount_end==nil
560
+ @memory_amount_total='-' if @memory_amount_total==nil
561
+
562
+ sw_version='-' if sw_version==nil
563
+ variant='-' if variant==nil
564
+ product='-' if product==nil
565
+ language='-' if language==nil
566
+ loc='-' if loc==nil
567
+ rescue
568
+ end
569
+ end
570
+ end
571
+
572
+ write_page_start(@report_folder+'/environment/index.html','TDriver test environment')
573
+ write_environment_body(@report_folder+'/environment/index.html',RUBY_PLATFORM,sw_version,variant,product,language,loc)
574
+ write_page_end(@report_folder+'/environment/index.html')
575
+ $new_junit_xml_results.test_suite_properties(RUBY_PLATFORM,sw_version,variant,product,language,loc,@memory_amount_total,@memory_amount_start,@memory_amount_end)
576
+ rescue Exception => e
577
+ Kernel::raise e, "Unable to update environment page", caller
578
+ end
579
+ return nil
580
+ end
581
+ #This method updates the tdriver log page
582
+ #
583
+ # === params
584
+ # nil
585
+ # === returns
586
+ # nil
587
+ # === raises
588
+ def update_tdriver_log_page()
589
+ begin
590
+ write_page_start(@report_folder+'/cases/tdriver_log_index.html','TDriver log')
591
+ write_tdriver_log_body(@report_folder+'/cases/tdriver_log_index.html',@test_run_behaviour_log)
592
+ write_page_end(@report_folder+'/cases/tdriver_log_index.html')
593
+ rescue Exception => e
594
+ Kernel::raise e
595
+ end
596
+ return nil
597
+ end
598
+ #This method gets the sut langugage version
599
+ #
600
+ # === params
601
+ # sut_id: sut id
602
+ # === returns
603
+ # nil
604
+ # === raises
605
+ def get_sut_lang_version(sut_id, sut_attributes)
606
+ MobyUtil::Logger.instance.enabled=false
607
+ lang_version='-'
608
+ begin
609
+ if MobyUtil::Parameter[sut_id][:type]=='S60' || MobyUtil::Parameter[sut_id][:type]=='S60QT'
610
+ lang_version=sut_attributes[:sut].sysinfo( :Lang_version )
611
+ end
612
+ if MobyUtil::Parameter[sut_id][:type]=='QT'
613
+ if /win/ =~ MobyUtil::EnvironmentHelper.ruby_platform
614
+ lang_version=0
615
+ else
616
+ lang_version=0
617
+ end
618
+ end
619
+ rescue
620
+ ensure
621
+ if MobyUtil::Parameter[ :logging_level, 0 ].to_i > 0
622
+ MobyUtil::Logger.instance.enabled=true
623
+ else
624
+ MobyUtil::Logger.instance.enabled=false
625
+ end
626
+ return lang_version
627
+ end
628
+ end
629
+ #This method gets the sut sw version
630
+ #
631
+ # === params
632
+ # sut_id: sut id
633
+ # === returns
634
+ # nil
635
+ # === raises
636
+ def get_sut_sw_version(sut_id, sut_attributes)
637
+ MobyUtil::Logger.instance.enabled=false
638
+ sw_version='-'
639
+ begin
640
+ if MobyUtil::Parameter[sut_id][:type]=='S60' || MobyUtil::Parameter[sut_id][:type]=='S60QT'
641
+ sw_version=sut_attributes[:sut].sysinfo( :Sw_version )
642
+ end
643
+ if MobyUtil::Parameter[sut_id][:type]=='QT'
644
+ if /win/ =~ MobyUtil::EnvironmentHelper.ruby_platform
645
+ sw_version=0
646
+ else
647
+ sw_version=0
648
+ end
649
+ end
650
+ rescue
651
+ ensure
652
+ if MobyUtil::Parameter[ :logging_level, 0 ].to_i > 0
653
+ MobyUtil::Logger.instance.enabled=true
654
+ else
655
+ MobyUtil::Logger.instance.enabled=false
656
+ end
657
+ return sw_version
658
+ end
659
+ end
660
+ #This method gets the sut used memory amount
661
+ #
662
+ # === params
663
+ # sut_id: sut id
664
+ # === returns
665
+ # nil
666
+ # === raises
667
+ def get_sut_used_memory(sut_id, sut_attributes)
668
+ MobyUtil::Logger.instance.enabled=false
669
+ memory=0
670
+ begin
671
+ if MobyUtil::Parameter[sut_id][:type]=='S60' || MobyUtil::Parameter[sut_id][:type]=='S60QT'
672
+ memory=sut_attributes[:sut].sysinfo( :Get_used_ram )
673
+ end
674
+ if MobyUtil::Parameter[sut_id][:type]=='QT'
675
+ if /win/ =~ MobyUtil::EnvironmentHelper.ruby_platform
676
+ memory=0
677
+ else
678
+ memory=0
679
+ end
680
+ end
681
+ rescue
682
+ ensure
683
+ if MobyUtil::Parameter[ :logging_level, 0 ].to_i > 0
684
+ MobyUtil::Logger.instance.enabled=true
685
+ else
686
+ MobyUtil::Logger.instance.enabled=false
687
+ end
688
+ return memory
689
+ end
690
+
691
+ end
692
+ #This method gets the sut total memory amount
693
+ #
694
+ # === params
695
+ # sut_id: sut id
696
+ # === returns
697
+ # nil
698
+ # === raises
699
+ def get_sut_total_memory(sut_id, sut_attributes)
700
+ MobyUtil::Logger.instance.enabled=false
701
+ memory=0
702
+ begin
703
+ if MobyUtil::Parameter[sut_id][:type]=='S60' || MobyUtil::Parameter[sut_id][:type]=='S60QT'
704
+ memory=sut_attributes[:sut].sysinfo( :Get_total_ram )
705
+ end
706
+ if MobyUtil::Parameter[sut_id][:type]=='QT'
707
+ if /win/ =~ MobyUtil::EnvironmentHelper.ruby_platform
708
+ memory=0
709
+ else
710
+ memory=0
711
+ end
712
+ end
713
+ rescue
714
+ ensure
715
+ if MobyUtil::Parameter[ :logging_level, 0 ].to_i > 0
716
+ MobyUtil::Logger.instance.enabled=true
717
+ else
718
+ MobyUtil::Logger.instance.enabled=false
719
+ end
720
+ return memory
721
+ end
722
+ end
723
+ #This method gets the sut total dump count
724
+ #
725
+ # === params
726
+ # sut_id: sut id
727
+ # === returns
728
+ # nil
729
+ # === raises
730
+ def get_sut_total_dump_count(sut_id, sut_attributes)
731
+
732
+ dump_count=sut_attributes[:sut].dump_count
733
+ @total_dump_count[sut_id.to_sym]=dump_count
734
+ @total_dump_count
735
+
736
+ end
737
+
738
+ #This method gets the sut total received data
739
+ #
740
+ # === params
741
+ # sut_id: sut id
742
+ # === returns
743
+ # nil
744
+ # === raises
745
+ def get_sut_total_received_data(sut_id, sut_attributes)
746
+ data=sut_attributes[:sut].received_data
747
+ @total_received_data[sut_id.to_sym]=data
748
+ @total_received_data
749
+ end
750
+
751
+ #This method gets the sut total sent data
752
+ #
753
+ # === params
754
+ # sut_id: sut id
755
+ # === returns
756
+ # nil
757
+ # === raises
758
+ def get_sut_total_sent_data(sut_id, sut_attributes)
759
+ data=sut_attributes[:sut].sent_data
760
+ @total_sent_data[sut_id.to_sym]=data
761
+ @total_sent_data
762
+ end
763
+
764
+ def write_to_result_storage(status,
765
+ testcase,
766
+ group,
767
+ reboots=0,
768
+ crashes=0,
769
+ start_time=nil,
770
+ user_data=nil,
771
+ duration=0,
772
+ memory_usage=0,
773
+ index=0,
774
+ log='',
775
+ comment='',
776
+ link='',
777
+ total_dump=nil,
778
+ total_sent=nil,
779
+ total_received=nil )
780
+ while $result_storage_in_use==true
781
+ sleep 1
782
+ end
783
+ $result_storage_in_use=true
784
+ begin
785
+ storage_file=nil
786
+ html_link=status+'_'+index.to_s+'_'+testcase+'/index.html' if link==''
787
+ storage_file='all_cases.xml'
788
+
789
+ file=@report_folder+'/'+storage_file
790
+
791
+ if File.exist?(file)
792
+ io = File.open(file, 'r')
793
+ xml_data = Nokogiri::XML(io){ |config| config.options = Nokogiri::XML::ParseOptions::STRICT }
794
+ io.close
795
+ test = Nokogiri::XML::Node.new("test",xml_data)
796
+ test_name = Nokogiri::XML::Node.new("name",test)
797
+ test_name.content = testcase
798
+ test_group = Nokogiri::XML::Node.new("group",test)
799
+ test_group.content = group
800
+ test_reboots = Nokogiri::XML::Node.new("reboots",test)
801
+ test_reboots.content = reboots
802
+ test_crashes = Nokogiri::XML::Node.new("crashes",test)
803
+ test_crashes.content = crashes
804
+ test_start_time = Nokogiri::XML::Node.new("start_time",test)
805
+ test_start_time.content = start_time.strftime("%d.%m.%Y %H:%M:%S")
806
+ test_duration = Nokogiri::XML::Node.new("duration",test)
807
+ test_duration.content = duration
808
+ test_memory_usage = Nokogiri::XML::Node.new("memory_usage",test)
809
+ test_memory_usage.content = memory_usage
810
+ test_status = Nokogiri::XML::Node.new("status",test)
811
+ test_status.content = status
812
+ test_index = Nokogiri::XML::Node.new("index",test)
813
+ test_index.content = index
814
+ test_log = Nokogiri::XML::Node.new("log",test)
815
+ test_log.content = log
816
+ test_comment = Nokogiri::XML::Node.new("comment",test)
817
+ test_comment.content = comment
818
+ test_link = Nokogiri::XML::Node.new("link",test)
819
+ test_link.content = html_link
820
+ test_dump_count = Nokogiri::XML::Node.new("dump_count",test)
821
+ test_dump_count.content = total_dump
822
+ test_sent_bytes = Nokogiri::XML::Node.new("sent_bytes",test)
823
+ test_sent_bytes.content = total_sent
824
+ test_received_bytes = Nokogiri::XML::Node.new("received_bytes",test)
825
+ test_received_bytes.content = total_received
826
+
827
+ test << test_name
828
+ test << test_group
829
+ test << test_reboots
830
+ test << test_crashes
831
+ test << test_start_time
832
+ test << test_duration
833
+ test << test_memory_usage
834
+ test << test_status
835
+ test << test_index
836
+ test << test_log
837
+ test << test_comment
838
+ test << test_link
839
+ test << test_dump_count
840
+ test << test_sent_bytes
841
+ test << test_received_bytes
842
+
843
+ if user_data!=nil && !user_data.empty?
844
+ test_data = Nokogiri::XML::Node.new("user_display_data",test)
845
+ user_data.each { |key,value|
846
+ data_value=Nokogiri::XML::Node.new("data",test_data)
847
+ data_value.content = value.to_s
848
+ data_value.set_attribute("id",key.to_s)
849
+ test_data << data_value
850
+ }
851
+ test<<test_data
852
+ end
853
+
854
+ xml_data.root.add_child(test)
855
+ File.open(file, 'w') {|f| f.write(xml_data.to_xml) }
856
+ test=nil
857
+ xml_data=nil
858
+ else
859
+ counter=0
860
+ if user_data!=nil && !user_data.empty?
861
+ #to avoid odd number list for hash error!
862
+ user_data_keys = user_data.keys
863
+ user_data_values = user_data.values
864
+ counter = user_data_values.size-1
865
+ end
866
+ builder = Nokogiri::XML::Builder.new do |xml|
867
+ xml.tests {
868
+ xml.test {
869
+ xml.name testcase
870
+ xml.group group
871
+ xml.reboots reboots
872
+ xml.crashes crashes
873
+ xml.start_time start_time.strftime("%d.%m.%Y %H:%M:%S")
874
+ xml.duration duration
875
+ xml.memory_usage memory_usage
876
+ xml.status status
877
+ xml.index index
878
+ xml.log log
879
+ xml.comment comment
880
+ xml.link html_link
881
+ xml.dump_count total_dump
882
+ xml.sent_bytes total_sent
883
+ xml.received_bytes total_received
884
+ if user_data!=nil && !user_data.empty?
885
+ xml.user_display_data {
886
+ (0..counter).each { |i|
887
+ xml.data("id"=>user_data_keys.at(i).to_s){
888
+ xml.text user_data_values.at(i).to_s{
889
+ }
890
+ }
891
+ }
892
+ }
893
+ end
894
+ }
895
+ }
896
+ end
897
+ File.open(file, 'w') {|f| f.write(builder.to_xml) }
898
+ end
899
+ $result_storage_in_use=false
900
+ builder=nil
901
+ rescue Nokogiri::XML::SyntaxError => e
902
+ $result_storage_in_use=false
903
+ $stderr.puts "caught exception when writing results: #{e}"
904
+ end
905
+ end
906
+
907
+ def read_result_storage(results)
908
+ while $result_storage_in_use==true
909
+ sleep 1
910
+ end
911
+ $result_storage_in_use=true
912
+ begin
913
+ result_storage=nil
914
+ result_storage=Array.new
915
+ storage_file='all_cases.xml'
916
+
917
+ file=@report_folder+'/'+storage_file
918
+ if File.exist?(file)
919
+ io = File.open(file, 'r')
920
+ xml_data = Nokogiri::XML(io){ |config| config.options = Nokogiri::XML::ParseOptions::STRICT }
921
+ io.close
922
+ xml_data.root.xpath("//tests/test").each do |node|
923
+ value=node.search("name").text #0
924
+ group=node.search("group").text #1
925
+ reboots=node.search("reboots").text #2
926
+ crashes=node.search("crashes").text #3
927
+ start_time=node.search("start_time").text #4
928
+ duration=node.search("duration").text #5
929
+ memory_usage=node.search("memory_usage").text #6
930
+ status=node.search("status").text #7
931
+ index=node.search("index").text #8
932
+ log=node.search("log").text #9
933
+ comment=node.search("comment").text #10
934
+ link=node.search("link").text #11
935
+ dump_count=node.search("dump_count").text #12
936
+ sent_bytes=node.search("sent_bytes").text #13
937
+ received_bytes=node.search("received_bytes").text #14
938
+
939
+ user_data = Hash.new
940
+ node.xpath("user_display_data/data").each do |data_node|
941
+ value_name = data_node.get_attribute("id")
942
+ val = data_node.text
943
+ user_data[value_name] = val
944
+ end
945
+
946
+ case results
947
+ when 'passed'
948
+ if @pass_statuses.include?(status)
949
+ result_storage << [value,
950
+ group,
951
+ reboots,
952
+ crashes,
953
+ start_time,
954
+ duration,
955
+ memory_usage,
956
+ status,
957
+ index,
958
+ log,
959
+ comment,
960
+ link,
961
+ user_data,
962
+ dump_count,
963
+ sent_bytes,
964
+ received_bytes
965
+ ]
966
+ end
967
+ when 'failed'
968
+ if @fail_statuses.include?(status)
969
+ result_storage << [value,
970
+ group,
971
+ reboots,
972
+ crashes,
973
+ start_time,
974
+ duration,
975
+ memory_usage,
976
+ status,
977
+ index,
978
+ log,
979
+ comment,
980
+ link,
981
+ user_data,
982
+ dump_count,
983
+ sent_bytes,
984
+ received_bytes
985
+ ]
986
+ end
987
+ when 'not_run'
988
+ if @not_run_statuses.include?(status)
989
+ result_storage << [value,
990
+ group,
991
+ reboots,
992
+ crashes,
993
+ start_time,
994
+ duration,
995
+ memory_usage,
996
+ status,
997
+ index,
998
+ log,
999
+ comment,
1000
+ link,
1001
+ user_data,
1002
+ dump_count,
1003
+ sent_bytes,
1004
+ received_bytes
1005
+ ]
1006
+ end
1007
+ when 'crash'
1008
+ if crashes.to_i > 0
1009
+ result_storage << [value,
1010
+ group,
1011
+ reboots,
1012
+ crashes,
1013
+ start_time,
1014
+ duration,
1015
+ memory_usage,
1016
+ status,
1017
+ index,
1018
+ log,
1019
+ comment,
1020
+ link,
1021
+ user_data,
1022
+ dump_count,
1023
+ sent_bytes,
1024
+ received_bytes
1025
+ ]
1026
+ end
1027
+ when 'reboot'
1028
+ if reboots.to_i > 0
1029
+ result_storage << [value,
1030
+ group,
1031
+ reboots,
1032
+ crashes,
1033
+ start_time,
1034
+ duration,
1035
+ memory_usage,
1036
+ status,
1037
+ index,
1038
+ log,
1039
+ comment,
1040
+ link,
1041
+ user_data,
1042
+ dump_count,
1043
+ sent_bytes,
1044
+ received_bytes
1045
+ ]
1046
+ end
1047
+ when 'all'
1048
+ result_storage << [value,
1049
+ group,
1050
+ reboots,
1051
+ crashes,
1052
+ start_time,
1053
+ duration,
1054
+ memory_usage,
1055
+ status,
1056
+ index,
1057
+ log,
1058
+ comment,
1059
+ link,
1060
+ user_data,
1061
+ dump_count,
1062
+ sent_bytes,
1063
+ received_bytes
1064
+ ]
1065
+ end
1066
+ end
1067
+ xml_data=nil
1068
+ $result_storage_in_use=false
1069
+ result_storage
1070
+ else
1071
+ $result_storage_in_use=false
1072
+ result_storage
1073
+ end
1074
+ rescue Nokogiri::XML::SyntaxError => e
1075
+ $result_storage_in_use=false
1076
+ $stderr.puts "caught exception when reading results: #{e}"
1077
+ result_storage
1078
+ end
1079
+ end
1080
+
1081
+ def delete_result_storage()
1082
+ storage_file='passed_cases.xml'
1083
+ file=@report_folder+'/'+storage_file
1084
+ if File.exist?(file)
1085
+ File.delete(file)
1086
+ end
1087
+
1088
+ storage_file='failed_cases.xml'
1089
+ file=@report_folder+'/'+storage_file
1090
+ if File.exist?(file)
1091
+ File.delete(file)
1092
+ end
1093
+
1094
+ storage_file='not_run_cases.xml'
1095
+ file=@report_folder+'/'+storage_file
1096
+ if File.exist?(file)
1097
+ File.delete(file)
1098
+ end
1099
+
1100
+ storage_file='all_cases.xml'
1101
+ file=@report_folder+'/'+storage_file
1102
+ if File.exist?(file)
1103
+ File.delete(file)
1104
+ end
1105
+ end
1106
+ #This method disconencts the connected devices
1107
+ #
1108
+ # === params
1109
+ # status: last run test case
1110
+ # === returns
1111
+ # nil
1112
+ # === raises
1113
+ def disconnect_connected_devices()
1114
+ if MobyUtil::Parameter[ :report_disconnect_connected_devices, false ] == 'true'
1115
+ MobyBase::SUTFactory.instance.connected_suts.each do |sut_id, sut_attributes|
1116
+ sut_attributes[:sut].disconnect() if sut_attributes[:is_connected]
1117
+ end
1118
+ end
1119
+ end
1120
+
1121
+ def split_array(splittable_array,chunks)
1122
+ a = []
1123
+ splittable_array.each_with_index do |x,i|
1124
+ a << [] if i % chunks == 0
1125
+ a.last << x
1126
+ end
1127
+ a
1128
+ end
1129
+
1130
+
1131
+
1132
+ #This method updates the tdriver test run enviroment page
1133
+ #
1134
+ # === params
1135
+ # status: last run test case
1136
+ # === returns
1137
+ # nil
1138
+ # === raises
1139
+ def update_test_case_summary_page(status,rewrite=false,title="")
1140
+ @cases_arr=Array.new
1141
+
1142
+ @cases_arr=read_result_storage(status)
1143
+ splitted_arr=Array.new
1144
+ splitted_arr=split_array(@cases_arr,@pages.to_i)
1145
+ page=1
1146
+ splitted_arr.each do |case_arr|
1147
+ if @report_pages_ready.include?("#{page}_passed")==false || rewrite==true
1148
+ write_page_start(@report_folder+"/cases/#{page}_#{status}_index.html",title,page,splitted_arr.length)
1149
+ write_test_case_summary_body(@report_folder+"/cases/#{page}_#{status}_index.html",status,case_arr,nil)
1150
+ page_ready=write_page_end(@report_folder+"/cases/#{page}_#{status}_index.html",page,splitted_arr.length)
1151
+ end
1152
+ if page_ready!=nil
1153
+ @report_pages_ready << "#{page_ready}_#{status}"
1154
+ end
1155
+ page_ready=nil
1156
+ page+=1
1157
+ end
1158
+
1159
+ end
1160
+ #This method updates the tdriver test run enviroment pages
1161
+ #
1162
+ # === params
1163
+ # status: last run test case
1164
+ # === returns
1165
+ # nil
1166
+ # === raises
1167
+ def update_test_case_summary_pages(status,rewrite=false)
1168
+
1169
+ @all_cases_arr=Array.new
1170
+ begin
1171
+ case status
1172
+ when 'passed'
1173
+ update_test_case_summary_page(status,rewrite,'Passed')
1174
+
1175
+ when 'failed'
1176
+ update_test_case_summary_page(status,rewrite,'Failed')
1177
+
1178
+ when 'not run'
1179
+ update_test_case_summary_page('not_run',rewrite,'Not run')
1180
+
1181
+ when 'statistics'
1182
+ @all_cases_arr=read_result_storage('all')
1183
+ write_page_start(@report_folder+'/cases/statistics_index.html','Statistics')
1184
+ write_test_case_summary_body(@report_folder+'/cases/statistics_index.html','statistics',@all_cases_arr)
1185
+ write_duration_graph(@report_folder+'/cases/statistics_index.html', @report_folder, 'duration_graph.png', @all_cases_arr) if @duration_graph!=false
1186
+ write_page_end(@report_folder+'/cases/statistics_index.html')
1187
+ when 'all'
1188
+ @all_cases_arr=read_result_storage(status)
1189
+ splitted_arr=Array.new
1190
+ splitted_arr=split_array(@all_cases_arr,@pages.to_i)
1191
+ page=1
1192
+ splitted_arr.each do |case_arr|
1193
+ if File.exist?(@report_folder+"/cases/#{page+1}_total_run_index.html")==false || rewrite==true
1194
+ if @report_pages_ready.include?("#{page}_all")==false || rewrite==true
1195
+ write_page_start(@report_folder+"/cases/#{page}_total_run_index.html",'Total run',page,splitted_arr.length)
1196
+ write_page_start(@report_folder+"/cases/#{page}_chronological_total_run_index.html",'Total run',page,splitted_arr.length)
1197
+ write_test_case_summary_body(@report_folder+"/cases/#{page}_total_run_index.html",'total run',case_arr,@report_folder+"/cases/#{page}_chronological_total_run_index.html",page)
1198
+ end
1199
+ end
1200
+ write_page_end(@report_folder+"/cases/#{page}_chronological_total_run_index.html",page,splitted_arr.length) if @report_pages_ready.include?("#{page}_all")==false || rewrite==true
1201
+ page_ready=write_page_end(@report_folder+"/cases/#{page}_total_run_index.html",page,splitted_arr.length) if @report_pages_ready.include?("#{page}_all")==false || rewrite==true
1202
+
1203
+ if page_ready!=nil
1204
+ @report_pages_ready << "#{page_ready}_all"
1205
+ end
1206
+ page_ready=nil
1207
+ page+=1
1208
+ end
1209
+ end
1210
+ @all_cases_arr=nil
1211
+ update_test_case_summary_pages_for_crashes_and_reboots(rewrite)
1212
+ rescue Exception => e
1213
+ Kernel::raise e, "Unable to update test case summary pages", caller
1214
+ end
1215
+ return nil
1216
+ end
1217
+
1218
+ def update_test_case_summary_pages_for_crashes_and_reboots(rewrite=false)
1219
+
1220
+ begin
1221
+ update_test_case_summary_page('crash',rewrite,'Crash')
1222
+ update_test_case_summary_page('reboot',rewrite,'Reboot')
1223
+ rescue Exception => e
1224
+ Kernel::raise e, "Unable to update test case summary pages for crashes and reboots", caller
1225
+ end
1226
+ return nil
1227
+ end
1228
+
1229
+ def create_csv
1230
+ storage_file='all_cases.xml'
1231
+ csv_file = 'all_cases.csv'
1232
+ csv_array = Array.new
1233
+ not_added=false
1234
+
1235
+ file=@report_folder+'/'+storage_file
1236
+ csv = nil
1237
+ begin
1238
+ if File.exist?(file)
1239
+ io = File.open(file, 'r')
1240
+ csv = File.new(@report_folder+'/'+ csv_file, 'w')
1241
+ xml_data = Nokogiri::XML(io){ |config| config.options = Nokogiri::XML::ParseOptions::STRICT }
1242
+ io.close
1243
+ xml_data.root.xpath("//tests/test").each do |node|
1244
+
1245
+ line=Array.new
1246
+ first_line=Array.new
1247
+
1248
+ value=node.search("name").text
1249
+ first_line<<"name" if !not_added
1250
+ line<<value
1251
+ start_time=node.search("start_time").text
1252
+ first_line<<"start_time" if !not_added
1253
+ line<<start_time
1254
+ duration=node.search("duration").text
1255
+ first_line<<"duration" if !not_added
1256
+ line<<duration
1257
+ memory_usage=node.search("memory_usage").text
1258
+ first_line<<"memory_usage" if !not_added
1259
+ line<<memory_usage
1260
+ status=node.search("status").text
1261
+ first_line<<"status" if !not_added
1262
+ line<<status
1263
+
1264
+ node.xpath("user_display_data/data").each do |data_node|
1265
+ value_name = data_node.get_attribute("id")
1266
+ value = data_node.text
1267
+ first_line<<value_name if !not_added
1268
+ line<<value
1269
+ end
1270
+
1271
+ csv.puts(first_line.join(",")) if !not_added
1272
+ csv.puts(line.join(","))
1273
+ not_added=true
1274
+ end
1275
+ csv.close
1276
+ else
1277
+ puts "Unable to create csv file"
1278
+ end
1279
+ rescue Exception => e
1280
+ puts "Error creating csv file"
1281
+ puts e.to_s
1282
+ end
1283
+ end
1284
+
1285
+ end
1286
+ end