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,221 @@
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
+ #!/usr/bin/ruby
22
+
23
+ require 'tdriver'
24
+
25
+ #require File.expand_path( File.join( File.dirname( __FILE__ ), 'xml/xml' ) )
26
+ #require File.expand_path( File.join( File.dirname( __FILE__ ), 'common' ) )
27
+
28
+ def find_xml_element( document, name )
29
+
30
+ document.root.xpath( "/parameters/*[@name='#{ name }']" )
31
+
32
+ end
33
+
34
+ def change_attr_value( node, attribute_name, value )
35
+
36
+ node.xml.attr( attribute_name, value.to_s )
37
+
38
+ end
39
+
40
+ def change_value( path, attribute, value )
41
+
42
+ filename = MobyUtil::FileHelper.fix_path( "#{ MobyUtil::FileHelper.tdriver_home }/tdriver_parameters.xml" )
43
+
44
+ xml_document = MobyUtil::XML::parse_file( filename )
45
+
46
+ node = find_xml_element( xml_document, path )
47
+ #p node
48
+
49
+ change_attr_value( node, attribute, value)
50
+ #p node
51
+
52
+ File.open( filename, "w" ){ | file_object | file_object << xml_document.xml }
53
+
54
+ end
55
+
56
+ #xml_document = MobyUtil::XML::parse_file( MobyUtil::FileHelper.fix_path( "#{ MobyUtil::FileHelper.tdriver_home }/tdriver_parameters.xml" ) )
57
+
58
+ #root_element = xml_document.root.xpath("/parameters/*[@id='sut_qt']")
59
+
60
+ =begin
61
+ root_element = xml_document.root.xpath("/parameters/parameter[@name='app_path']")
62
+
63
+ p root_element.xml
64
+
65
+ root_element.xml.attr("value", "10")
66
+
67
+ p root_element.xml
68
+
69
+ p xml_document
70
+
71
+ =end
72
+
73
+ #p root_element.xml.class
74
+
75
+ =begin
76
+
77
+ nimi = 'sut_qt'
78
+
79
+ root_element = xml_document.root.xpath("/parameters/*[@id='#{ nimi }' or @name='#{ nimi }']/fixtures") #*[@id='#{ nimi }' or @name='#{ nimi }']")
80
+
81
+ p root_element
82
+
83
+ root_element = xml_document.root.xpath("/parameters/*[@id='#{ nimi }' or @name='#{ nimi }']")
84
+
85
+
86
+ p root_element
87
+
88
+ =end
89
+
90
+
91
+ #p root_element.xml.keys
92
+
93
+ #node = Nokogiri::XML::Node.new("<nimi>l</nimi>", xml_document.xml)
94
+
95
+ #root_element.xml.push( node )
96
+
97
+ #xml_document.root.xml.add_child( node )
98
+
99
+
100
+ #p root_element.xml.to_xml
101
+
102
+ #p xml_document.xml.to_xml
103
+
104
+
105
+ #p root_element.class
106
+
107
+ #p xml_document.xml
108
+
109
+ #exit
110
+
111
+ def help
112
+
113
+ =begin
114
+
115
+ Usage:
116
+ Products:
117
+ Options:
118
+ -a arch architecture [all] (arm, x86, all)
119
+ -c path custom scratchbox path [/scratchbox]
120
+ -d display debug messages
121
+ WARNING: may contain sensitive information such as password
122
+ -e create targets that use files.maemo.org as the repository
123
+ -f overwrite previously existing target if one exists
124
+ -h display help
125
+ -p pass password for the repository/rootstrap download
126
+ -r name release name [pre-release] (current, pre-release, previous)
127
+ you can use build number instead of release name
128
+ -s select the created target
129
+ -t prefix custom prefix for target names [maemoX]
130
+ target name will be \$prefix-\$arch
131
+ -u user username for the repository/rootstrap download
132
+ -A save authentication data into .netrc in your scratchbox home
133
+ WARNING: your username and password will be written
134
+ in cleartext into your scratchbox home .netrc
135
+ -C config use custom configuration as rootstrap [minimaldev]
136
+ configuration used will be \$arch-\$config
137
+ -D don't install debug links
138
+ -I don't install files to rootstrap
139
+ -P don't allow unauthenticated packages
140
+ -R don't install rootstrap
141
+ -S keep sources.list provided by rootstrap
142
+ -U save authentication data in sources.list
143
+ WARNING: your username and password will be written
144
+ in cleartext into your target's sources.list
145
+
146
+
147
+ =end
148
+
149
+ puts <<HELP
150
+
151
+ Usage:
152
+ tdriver-config read [path]
153
+
154
+ Example:
155
+ tdriver-config read - List keys from root level
156
+ tdriver-config read sut_qt - List keys from "sut_qt" hash
157
+ tdriver-config read sut_qt/keymap/kApp - Retrieve value of kApp
158
+
159
+ HELP
160
+
161
+ exit
162
+
163
+ end
164
+
165
+ def print_key( key, value )
166
+ puts "%s %s" % [ "#{key} ".ljust(65, '.'), value.kind_of?( Hash ) ? "<Multiple values>" : "\"#{ value.to_s }\"" ]
167
+ end
168
+
169
+ def dump_hash_values( hash, path = "" )
170
+ hash.keys.sort{ |a,b| a.to_s <=> b.to_s }.each{ | key | print_key( key, hash[ key ] ) }
171
+ end
172
+
173
+ def resolve_hash_path( hash, path_string )
174
+ return [ "", hash ] if path_string.nil? or ( path_string.kind_of?( String) and path_string.empty? )
175
+ path = hash; path_array = path_string.split( "/" ); current_path = []
176
+ [ path_array[ -1 ], ( path_array.collect{ | key |
177
+ current_path = current_path + [ key ]
178
+ if !path.has_key?( key.to_sym ); puts "No such key/hash found (%s)\n\n" % [ current_path.join( "::" ) ]; exit; end
179
+ path = path[ key.to_sym ]
180
+ }.compact)[ -1 ] ]
181
+ end
182
+
183
+ if ARGV.count < 1;
184
+
185
+ help;
186
+
187
+ else
188
+
189
+ if ![ 'read', 'write' ].include?( ARGV[ 0 ].downcase ) #!= 'read'
190
+ puts "Currently only read and write is supported"; help; exit
191
+ end
192
+
193
+ mode = ARGV[ 0 ].downcase == 'read' ? :read : :write
194
+
195
+ puts "\n"
196
+
197
+ case mode
198
+
199
+ when :write
200
+
201
+ change_value( ARGV[ 1 ], "value", ARGV[ 2 ])
202
+ print_key ARGV[ 1 ], ARGV[ 2 ]
203
+
204
+ # reload new settings
205
+ #Singleton.__init__( MobyUtil::Parameter )
206
+
207
+ when :read
208
+
209
+ require 'tdriver'
210
+
211
+ result = resolve_hash_path( MobyUtil::Parameter.parameters, ARGV[ 1 ])
212
+
213
+ result[ 1 ].kind_of?( Hash ) ? ( dump_hash_values result[ 1 ] ) : ( print_key result[ 0 ], result[ 1 ] )
214
+
215
+ end
216
+
217
+ puts "\n"
218
+
219
+
220
+ end
221
+
@@ -0,0 +1,24 @@
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
+ STDOUT.puts "Please require 'util/parameter/loader.rb' instead of 'util/parameter.rb'"
22
+
23
+ require File.expand_path( File.join( File.dirname( __FILE__ ), 'parameter/loader.rb' ) )
24
+
@@ -0,0 +1,45 @@
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 MobyUtil
21
+
22
+ # This is template for tdriver custom errors
23
+ class CustomError < StandardError;
24
+
25
+ def initialize( msg = nil )
26
+
27
+ super( msg )
28
+
29
+ end
30
+
31
+ end
32
+
33
+ # This error should be raised when referred parameter is not found
34
+ class ParameterNotFoundError < CustomError; end
35
+
36
+ # This error should be raised when parameter file parsing fails
37
+ class ParameterFileParseError < CustomError; end
38
+
39
+ # This error should be raised when desired template was not found
40
+ class TemplateNotFoundError < CustomError; end
41
+
42
+ # This error should be raised when desired template was not found
43
+ class TemplatesFileNotLoaded < CustomError; end
44
+
45
+ end # MobyUtil
@@ -0,0 +1,37 @@
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
+ # Parameter related errors
21
+ require File.expand_path( File.join( File.dirname( __FILE__ ), 'error.rb' ) )
22
+
23
+ # Parameter hash class
24
+ require File.expand_path( File.join( File.dirname( __FILE__ ), 'parameter_hash.rb' ) )
25
+
26
+ # Parameter API etc
27
+ require File.expand_path( File.join( File.dirname( __FILE__ ), 'parameter_template.rb' ) )
28
+
29
+ # Parameter API etc
30
+ require File.expand_path( File.join( File.dirname( __FILE__ ), 'parameter_xml.rb' ) )
31
+
32
+ # Parameter end user API etc
33
+ require File.expand_path( File.join( File.dirname( __FILE__ ), 'parameter_user_api.rb' ) )
34
+
35
+ # Parameter API etc
36
+ require File.expand_path( File.join( File.dirname( __FILE__ ), 'parameter.rb' ) )
37
+
@@ -0,0 +1,285 @@
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 MobyUtil
21
+
22
+ class Parameter
23
+
24
+ include Singleton
25
+
26
+ @@initialized = false
27
+
28
+ private
29
+
30
+ def initialize
31
+
32
+ # this can be done only once due to following method removes --tdriver_parameters argument from ARGV
33
+ @@filename_from_command_list_arguments = parse_command_line_arguments
34
+
35
+ # initialize and load templates, default parameters and user defined parameter file
36
+ reset( true, true, true, true )
37
+
38
+ # parameter singleton is now initialized
39
+ @@initialized = true
40
+
41
+ end
42
+
43
+ def parse_command_line_arguments
44
+
45
+ # reset user_defined_file_defined_in_command_line_arguments flag
46
+ @@user_defined_parameters_file_defined_in_command_line_arguments = false
47
+
48
+ filename = Array.new
49
+ delete_values=Array.new
50
+
51
+ # use command line argument if one exists.
52
+ ARGV.each_index do | index |
53
+
54
+ if ARGV[ index ].to_s == '--matti_parameters'
55
+ puts "--matti_parameters is deprecated, use -tdriver_parameters instead"
56
+ Kernel::raise ArgumentError.new( "TDriver parameters command line argument given without a filename" ) if ARGV.count == index + 1
57
+ delete_values << ARGV[ index ].to_s
58
+ end
59
+
60
+ if ARGV[ index ].to_s == '--tdriver_parameters'
61
+ Kernel::raise ArgumentError.new( "TDriver parameters command line argument given without a filename" ) if ARGV.count == index + 1
62
+ delete_values << ARGV[ index ].to_s
63
+ end
64
+
65
+ if ARGV[ index ].to_s.downcase.include?('.xml')
66
+ # no absolute path required
67
+ filename << File.expand_path( ARGV[ index ].to_s )
68
+ #filename << MobyUtil::FileHelper.expand_path( ARGV[ index ].to_s )
69
+ @@user_defined_parameters_file_defined_in_command_line_arguments = true
70
+ delete_values << ARGV[ index ].to_s
71
+ end
72
+
73
+ end
74
+
75
+ #clean up ARGV
76
+ delete_values.each do | value |
77
+ indx = ARGV.index( value )
78
+ ARGV.delete_at( indx )
79
+ end
80
+
81
+ if filename
82
+ filename.each do | parameter_file |
83
+ Kernel::raise MobyUtil::FileNotFoundError.new( "User defined TDriver parameters file %s does not exist" % [ parameter_file ] ) if !File.exist?( parameter_file )
84
+ end
85
+ end
86
+
87
+ filename
88
+
89
+ end
90
+
91
+ protected
92
+
93
+ def reset_flags
94
+
95
+ # reset loaded_parameter_files list
96
+ @@loaded_parameter_files = []
97
+
98
+ # reset templates_loaded flag
99
+ @@templates_loaded = false
100
+
101
+ # reset default_parameters_loaded flag
102
+ @@default_parameters_loaded = false
103
+
104
+ end
105
+
106
+ def reset( load_template_files = true, load_parameter_defaults = true, load_default_parameters = true, load_command_line_parameters = true )
107
+
108
+ reset_flags
109
+
110
+ # load parameter templates
111
+ load_templates if load_template_files
112
+
113
+ # load global parameters (root level, e.g. MobyUtil::Parameter[ :logging_outputter_enabled ])
114
+ @@parameters = MobyUtil::ParameterTemplates.instance.get_template_from_xml( 'global' )
115
+
116
+ # load and merge with default parameters
117
+ @@parameters.merge_with_hash!( load_default_parameter_files ) if load_parameter_defaults
118
+
119
+ # use filename from command line argument if one exists otherwise use default.
120
+ filename = load_command_line_parameters ? @@filename_from_command_list_arguments : nil
121
+
122
+ # load default tdriver/tdriver_parameters.xml file
123
+ load_parameters_xml( "tdriver_parameters.xml" ) if load_default_parameters
124
+
125
+ # load parameters files unless file does not exist
126
+ if filename
127
+ filename.each do |parameter_file|
128
+
129
+ load_parameters_xml( parameter_file ) if File.exist?( parameter_file )
130
+
131
+ end
132
+ end
133
+
134
+
135
+ end
136
+
137
+ def load_templates
138
+
139
+ @@templates_loaded = true
140
+
141
+ MobyUtil::ParameterTemplates.instance.load_templates()
142
+
143
+ end
144
+
145
+ def load_default_parameter_files
146
+
147
+ @@default_parameters_loaded = true
148
+
149
+ # load default parameter values
150
+ MobyUtil::ParameterXml.instance.parse(
151
+
152
+ MobyUtil::ParameterXml.instance.merge_files( 'defaults/', 'parameters', '/parameters/*' ){ | filename |
153
+
154
+ @@loaded_parameter_files << filename unless @@loaded_parameter_files.include?( filename )
155
+
156
+ }
157
+
158
+ )
159
+
160
+ end
161
+
162
+ public
163
+
164
+ # reset parameters class
165
+ def reset_parameters
166
+
167
+ MobyUtil::ParameterXml.instance.reset
168
+
169
+ reset( true, true, true, true )
170
+
171
+ end
172
+
173
+ # load additional parameter xml files
174
+ def load_parameters_xml( filename, reset = false )
175
+
176
+ reset_parameters if reset == true
177
+
178
+ filename = MobyUtil::FileHelper.expand_path( filename )
179
+
180
+ Kernel::raise MobyUtil::FileNotFoundError.new( "Parameters file %s does not exist" % [ filename ] ) if !File.exist?( filename )
181
+
182
+ @@parameters.merge_with_hash!(
183
+
184
+ MobyUtil::ParameterXml.instance.parse_file( filename )
185
+
186
+ )
187
+
188
+ @@loaded_parameter_files << filename
189
+
190
+ end
191
+
192
+ # empty parameters hash
193
+ def clear
194
+
195
+ MobyUtil::ParameterXml.instance.reset
196
+
197
+ reset_flags
198
+
199
+ @@parameters.clear
200
+
201
+ end
202
+
203
+ public # singleton methods
204
+
205
+ # Function for returning the value of a parameter. If the parameters is not yet populated it populates
206
+ # it with default file (tdriver_home/tdriver_parameters.xml)
207
+ # == params
208
+ # key:: Symbol containing the name of the parameter to be returned
209
+ # == returns
210
+ # String:: value of the parameter, or nil if not found
211
+ def self.[]( key, *default )
212
+
213
+ self.instance unless @@initialized
214
+
215
+ @@parameters[ key, *default ]
216
+
217
+ end
218
+
219
+ def self.fetch( key, *default, &block )
220
+
221
+ self.instance unless @@initialized
222
+
223
+ @@parameters.method(:[]).call( key, *default, &block )
224
+
225
+ end
226
+
227
+ # Function for setting the value of a parameter. If the parameters is not yet populated it populates
228
+ # it with default file (tdriver_home/tdriver_parameters.xml)
229
+ # == params
230
+ # key:: Symbol containing the name of the parameter to be modified
231
+ # == returns
232
+ # String:: new value of the parameter, or nil if not found
233
+ def self.[]=( key, value )
234
+
235
+ self.instance unless @@initialized
236
+
237
+ Kernel::raise ParameterNotFoundError.new( "Unable to set parameter value due to nil is not valid key; Parameter key must be type of String or Symbol" ) unless key
238
+
239
+ @@parameters[ key ] = value
240
+
241
+ end
242
+
243
+ def self.inspect
244
+
245
+ self.instance unless @@initialized
246
+
247
+ @@parameters.inspect
248
+
249
+ end
250
+
251
+ def self.to_s
252
+
253
+ self.instance unless @@initialized
254
+
255
+ @@parameters.to_s
256
+
257
+ end
258
+
259
+ def self.parameters
260
+
261
+ self.instance unless @@initialized
262
+
263
+ @@parameters
264
+
265
+ end
266
+
267
+ def self.configured_suts
268
+
269
+ self.instance unless @@initialized
270
+
271
+ MobyUtil::ParameterXml.instance.sut_list
272
+
273
+ end
274
+
275
+ def self.files
276
+
277
+ @@loaded_parameter_files
278
+
279
+ end
280
+
281
+ MobyUtil::Hooking.instance.hook_methods( self ) if defined?( MobyUtil::Hooking )
282
+
283
+ end # Parameter
284
+
285
+ end # MobyUtil