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,67 @@
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 Testability Driver.
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 MobyBehaviour
22
+
23
+ # == description
24
+ # SUT controller behaviours
25
+ #
26
+ # == behaviour
27
+ # GenericSutController
28
+ #
29
+ # == requires
30
+ # *
31
+ #
32
+ # == input_type
33
+ # *
34
+ #
35
+ # == sut_type
36
+ # *
37
+ #
38
+ # == sut_version
39
+ # *
40
+ #
41
+ # == objects
42
+ # sut
43
+ #
44
+ module SutController
45
+
46
+ include MobyBehaviour::Behaviour
47
+
48
+ # == nodoc
49
+ def execution_order
50
+
51
+ @_sutController.execution_order
52
+
53
+ end
54
+
55
+ # == nodoc
56
+ def execution_order=( order )
57
+
58
+ @_sutController.execution_order = order
59
+
60
+ end
61
+
62
+ # enable hooking for performance measurement & debug logging
63
+ MobyUtil::Hooking.instance.hook_methods( self ) if defined?( MobyUtil::Hooking )
64
+
65
+ end # SutController
66
+
67
+ end # MobyBehaviour
@@ -0,0 +1,96 @@
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 Testability Driver.
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
+ # Find behaviour
22
+ # Methods for finding test objects on the suttest objet state
23
+ module MobyBehaviour
24
+
25
+ # == description
26
+ # This module contains generic find behaviour
27
+ #
28
+ # == behaviour
29
+ # GenericFind
30
+ #
31
+ # == requires
32
+ # *
33
+ #
34
+ # == input_type
35
+ # *
36
+ #
37
+ # == sut_type
38
+ # *
39
+ #
40
+ # == sut_version
41
+ # *
42
+ #
43
+ # == objects
44
+ # *;sut
45
+ module Find
46
+
47
+ include MobyBehaviour::Behaviour
48
+
49
+ # == description
50
+ # Finds a child test_object given its name and type and returns it as a reference
51
+ #
52
+ # == arguments
53
+ # find_hash
54
+ # Hash
55
+ # description: one or more attributes defining the rules for the test object search. Must not be empty.
56
+ # example: { :name => 'oneButton' }
57
+ # default: {}
58
+ #
59
+ # == returns
60
+ # MobyBase::TestObject
61
+ # description: found test object
62
+ # example: -
63
+ #
64
+ # == exceptions
65
+ # TypeError
66
+ # description: raised if agument is not a Hash or is an emtpy Hash
67
+ #
68
+ # == info
69
+ # Same as calling child method.
70
+ def find ( find_hash = {} )
71
+
72
+ begin
73
+
74
+ raise TypeError.new( 'Input parameter not of Type: Hash or empty.\nIt is: ' + find_hash.class.to_s ) unless find_hash.kind_of?( Hash ) and !find_hash.empty?
75
+
76
+ search_result = child(find_hash)
77
+
78
+ rescue Exception => e
79
+
80
+ MobyUtil::Logger.instance.log "behaviour" , "FAIL;Failed to find test object.;#{id.to_s};sut;{};find;" << ( find_hash.kind_of?( Hash ) ? find_hash.inspect : find_hash.class.to_s )
81
+
82
+ Kernel::raise e
83
+
84
+ end
85
+
86
+ MobyUtil::Logger.instance.log "behaviour" , "PASS;Test object found.;#{id.to_s};sut;{};application;" << find_hash.inspect
87
+
88
+ search_result
89
+ end
90
+
91
+ # enable hooking for performance measurement & debug logging
92
+ MobyUtil::Hooking.instance.hook_methods( self ) if defined?( MobyUtil::Hooking )
93
+
94
+ end # Find
95
+
96
+ end # MobyBehaviour
@@ -0,0 +1,346 @@
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 Testability Driver.
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
+ module MobyBehaviour
21
+ # == description
22
+ # This module contains implementation to control device flashing
23
+ #
24
+ # == behaviour
25
+ # GenericFlashBehaviour
26
+ #
27
+ # == requires
28
+ # *
29
+ # == input_type
30
+ # *
31
+ #
32
+ # == sut_type
33
+ # *
34
+ #
35
+ # == sut_version
36
+ # *
37
+ #
38
+ # == objects
39
+ # sut
40
+ #
41
+ module FlashBehaviour
42
+
43
+ include MobyBehaviour::Behaviour
44
+
45
+ # == description
46
+ # Instructs the sut to start the flash operation with default TDriver parameters for sut that are:
47
+ # how many times TDriver will attempt to flash the device:
48
+ # [code]<parameter name="flash_attempts" value="2" />[/code]
49
+ # timeout in seconds between the switchbox commands:
50
+ # [code]<parameter name="timeout_between_command_sequence" value="25" />[/code]
51
+ # commands you want to be executed before flash:
52
+ # [code]<parameter name="switchbox_commands_before_flash" value="" />[/code]
53
+ # flash commands before flash:
54
+ # [code]<parameter name="commands_before_flash" value="" />[/code]
55
+ # intial flash command:
56
+ # [code]<parameter name="flash_command" value="" />[/code]
57
+ # timeout in seconds before executing the commands during flash:
58
+ # <parameter name="timeout_before_executing_commands_during_flash" value="20" />
59
+ # commands you want to be executed during flash:
60
+ # <parameter name="switchbox_commands_during_flash" value="" />
61
+ # optional flash parameters:
62
+ # <parameter name="optional_parameters_after_flashing" value="" />
63
+ # images to flash:
64
+ # <parameter name="flash_images" value="" />
65
+ # need to wait for the flash process to finish:
66
+ # <parameter name="sleep_time_after_flash_command" value="70" />
67
+ # flash command after flash:
68
+ # <parameter name="command_after_flash" value="" />
69
+ # commands for switchbox after failed flash:
70
+ # <parameter name="switchbox_commands_after_failed_flash" value="" />
71
+ # commands after failed flash:
72
+ # <parameter name="commands_after_failed_flash" value="" />
73
+ # If no error then no string is displayed:
74
+ # <parameter name="flash_command_success_string" value="" />
75
+ # commands you want to be executed after flash:
76
+ # <parameter name="switchbox_commands_after_flash" value="" />
77
+ # == arguments
78
+ # == returns
79
+ # == exceptions
80
+ # BehaviourError
81
+ # description: If mandatory parameters are missing
82
+ # BehaviourError
83
+ # description: If flashing is failed
84
+ # === info
85
+ def flash()
86
+
87
+ flash_images
88
+
89
+ end
90
+
91
+ # == description
92
+ # Instructs the sut to start the flash operation with default TDriver parameters for sut that are:
93
+ # how many times TDriver will attempt to flash the device:
94
+ # <parameter name="flash_attempts" value="2" />
95
+ # timeout in seconds between the switchbox commands:
96
+ # <parameter name="timeout_between_command_sequence" value="25" />
97
+ # commands you want to be executed before flash:
98
+ # <parameter name="switchbox_commands_before_flash" value="" />
99
+ # flash commands before flash:
100
+ # <parameter name="commands_before_flash" value="" />
101
+ # intial flash command:
102
+ # <parameter name="flash_command" value="" />
103
+ # timeout in seconds before executing the commands during flash:
104
+ # <parameter name="timeout_before_executing_commands_during_flash" value="20" />
105
+ # commands you want to be executed during flash:
106
+ # <parameter name="switchbox_commands_during_flash" value="" />
107
+ # optional flash parameters:
108
+ # <parameter name="optional_parameters_after_flashing" value="" />
109
+ # images to flash:
110
+ # <parameter name="flash_images" value="" />
111
+ # need to wait for the flash process to finish:
112
+ # <parameter name="sleep_time_after_flash_command" value="70" />
113
+ # flash command after flash:
114
+ # <parameter name="command_after_flash" value="" />
115
+ # commands for switchbox after failed flash:
116
+ # <parameter name="switchbox_commands_after_failed_flash" value="" />
117
+ # commands after failed flash:
118
+ # <parameter name="commands_after_failed_flash" value="" />
119
+ # If no error then no string is displayed:
120
+ # <parameter name="flash_command_success_string" value="" />
121
+ # commands you want to be executed after flash:
122
+ # <parameter name="switchbox_commands_after_flash" value="" />
123
+ # == arguments
124
+ # flash_files
125
+ # String
126
+ # description: The location of the software image file
127
+ # example: "C:/images/flash_image.img"
128
+ # == returns
129
+ # == raises
130
+ # BehaviourError If mandatory parameters are missing
131
+ # BehaviourError If flashing is failed
132
+ # === examples
133
+ # @sut.flash_images("C:/path/image_file.img")
134
+ def flash_images(flash_files=nil)
135
+ file, line = caller.first.split(":")
136
+
137
+ begin
138
+ if parameter(:flaxi_flash_attempts)
139
+ $stderr.puts "%s:%s warning: parameter :flaxi_flash_attempts deprecated use :flash_attempts instead" % [ file, line]
140
+ parameter[:flash_attempts]=parameter(:flaxi_flash_attempts)
141
+ end
142
+ rescue
143
+ end
144
+
145
+ begin
146
+ if parameter(:flaxi_commands_before_flash)
147
+ $stderr.puts "%s:%s warning: parameter :flaxi_commands_before_flash deprecated use :commands_before_flash instead" % [ file, line]
148
+ parameter[:commands_before_flash]=parameter(:flaxi_commands_before_flash)
149
+ end
150
+ rescue
151
+ end
152
+
153
+ begin
154
+ if parameter(:flaxi_flash_command)
155
+ $stderr.puts "%s:%s warning: parameter :flaxi_flash_command deprecated use :flash_command instead" % [ file, line]
156
+ parameter[:flash_command]=parameter(:flaxi_flash_command)
157
+ end
158
+ rescue
159
+ end
160
+
161
+ begin
162
+ if parameter(:flaxi_optional_parameters_after_flashing)
163
+ $stderr.puts "%s:%s warning: parameter :flaxi_optional_parameters_after_flashing deprecated use :optional_parameters_after_flashing instead" % [ file, line]
164
+ parameter[:optional_parameters_after_flashing]=parameter(:flaxi_optional_parameters_after_flashing)
165
+ end
166
+ rescue
167
+ end
168
+
169
+ begin
170
+ if parameter(:flaxi_flash_images)
171
+ $stderr.puts "%s:%s warning: parameter :flaxi_flash_images deprecated use :flash_images instead" % [ file, line]
172
+ parameter[:flash_images]=parameter(:flaxi_flash_images)
173
+ end
174
+ rescue
175
+ end
176
+
177
+ begin
178
+ if parameter(:flaxi_sleep_time_after_flash_command)
179
+ $stderr.puts "%s:%s warning: parameter :flaxi_sleep_time_after_flash_command deprecated use :sleep_time_after_flash_command instead" % [ file, line]
180
+ parameter[:sleep_time_after_flash_command]=parameter(:flaxi_sleep_time_after_flash_command)
181
+ end
182
+ rescue
183
+ end
184
+
185
+ begin
186
+ if parameter(:flaxi_command_after_flash)
187
+ $stderr.puts "%s:%s warning: parameter :flaxi_command_after_flash deprecated use :command_after_flash instead" % [ file, line]
188
+ parameter[:command_after_flash]=parameter(:flaxi_command_after_flash)
189
+ end
190
+ rescue
191
+ end
192
+
193
+ begin
194
+ if parameter(:flaxi_commands_after_failed_flash)
195
+ $stderr.puts "%s:%s warning: parameter :flaxi_commands_after_failed_flash deprecated use :commands_after_failed_flash instead" % [ file, line]
196
+ parameter[:commands_after_failed_flash]=parameter(:flaxi_commands_after_failed_flash)
197
+ end
198
+ rescue
199
+ end
200
+
201
+ begin
202
+ if parameter(:flaxi_flash_command_success_string)
203
+ $stderr.puts "%s:%s warning: parameter :flaxi_flash_command_success_string deprecated use :flash_command_success_string instead" % [ file, line]
204
+ parameter[:flash_command_success_string]=parameter(:flaxi_flash_command_success_string)
205
+ end
206
+ rescue
207
+ end
208
+
209
+ if flash_files==nil
210
+ flash_files=parameter(:flash_images)
211
+ Kernel::raise MobyBase::BehaviourError.new("flash_images", "flash_images not defined for sut in tdriver_parameters.xml") if flash_files == nil
212
+ end
213
+
214
+ str_flash_command=parameter(:flash_command)
215
+ Kernel::raise MobyBase::BehaviourError.new("flash_images", "flash_command not defined for sut in tdriver_parameters.xml") if str_flash_command == nil
216
+
217
+ str_optional_parameters=parameter(:optional_parameters_after_flashing,'')
218
+ Kernel::raise MobyBase::BehaviourError.new("flash_images", "optional_parameters_after_flashing not defined for sut in tdriver_parameters.xml") if str_optional_parameters == nil
219
+
220
+ #build flash command
221
+ flash_command="#{str_flash_command} #{flash_files} #{str_optional_parameters}"
222
+
223
+ #start flashing
224
+ result=start_flashing(flash_command)
225
+ Kernel::raise MobyBase::BehaviourError.new("flash_images", "Flashing failed") if result.to_s == 'false'
226
+
227
+ end
228
+
229
+ private
230
+
231
+ def execute_command_sequence(command_sequence)
232
+
233
+ sequence_timeout=parameter(:timeout_between_command_sequence)
234
+
235
+ #command sequenc
236
+ str_command=parameter(command_sequence)
237
+
238
+ #generate the sequence
239
+ str_command_arr = str_command.split('|')
240
+
241
+ #execute command sequence
242
+ str_command_arr.each do |command|
243
+ system(command)
244
+ sleep sequence_timeout.to_i
245
+ end
246
+
247
+ end
248
+
249
+ def flash_error_recovery()
250
+
251
+ #switchbox commands after failed flash
252
+ execute_command_sequence(:switchbox_commands_after_failed_flash)
253
+
254
+ #flaxi commands after failed flash
255
+ execute_command_sequence(:commands_after_failed_flash)
256
+
257
+ end
258
+
259
+ def start_flashing(flash_command)
260
+
261
+ flash_attempts=parameter(:flash_attempts)
262
+ Kernel::raise MobyBase::BehaviourError.new("start_flashing", "flash_attempts not defined for sut in tdriver_parameters.xml") if flash_attempts == nil
263
+
264
+ current_flash_attempt=0
265
+ flash_result='false'
266
+
267
+
268
+ while current_flash_attempt < flash_attempts.to_i
269
+ initialize_prommer
270
+
271
+ initialize_device
272
+ Thread.new do
273
+ #this intializes the commands that are executed during flash
274
+ wait_timeout=0
275
+ wait_timeout=parameter(:timeout_before_executing_commands_during_flash,10) if parameter(:timeout_before_executing_commands_during_flash)
276
+ sleep wait_timeout.to_i
277
+ #commands executed during flash
278
+ execute_command_sequence(:switchbox_commands_during_flash) if parameter(:switchbox_commands_during_flash)
279
+ end
280
+ flash_result=system(flash_command)
281
+ if flash_result.to_s=='true'
282
+ current_flash_attempt==flash_attempts
283
+ else
284
+ flash_error_recovery
285
+ end
286
+ current_flash_attempt+=1
287
+ end
288
+
289
+ finalize_prommer
290
+
291
+ finalize_device
292
+
293
+ flash_result
294
+ end
295
+
296
+ # Instructs the SUT to initialize prommer using foobox
297
+ # === params
298
+ # === returns
299
+ # === raises
300
+ def initialize_prommer()
301
+
302
+ #switchbox command sequence before flash
303
+ execute_command_sequence(:switchbox_commands_before_flash)
304
+
305
+ end
306
+
307
+ # Instructs the SUT to initialize device using flaxi
308
+ # === params
309
+ # === returns
310
+ # === raises
311
+ def initialize_device()
312
+
313
+ #flaxi command sequence before flash
314
+ execute_command_sequence(:commands_before_flash)
315
+
316
+ end
317
+
318
+ # Instructs the SUT to finalize prommer using foobox
319
+ # === params
320
+ # === returns
321
+ # === raises
322
+ def finalize_prommer()
323
+
324
+ #switchbox command sequence before flash
325
+ execute_command_sequence(:switchbox_commands_after_flash)
326
+
327
+ end
328
+
329
+ # Instructs the SUT to finalize device using flaxi
330
+ # === params
331
+ # === returns
332
+ # === raises
333
+ def finalize_device()
334
+
335
+ #flaxi command sequence before flash
336
+ execute_command_sequence(:command_after_flash)
337
+
338
+ end
339
+
340
+ # enable hooking for performance measurement & debug logging
341
+ MobyUtil::Hooking.instance.hook_methods( self ) if defined?( MobyUtil::Hooking )
342
+
343
+ end
344
+
345
+ end
346
+