testability-driver 1.0.3 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/tdriver-devtools/behaviour/xml/rdoc_behaviour_xml_generator.rb +2 -2
- data/lib/tdriver-devtools/tdriver-devtools.rb +1 -1
- data/lib/tdriver-devtools/tests/feature_tests/lib/custom_rdoc_generator.rb +3 -3
- data/lib/tdriver/base/behaviour/behaviours/object_behaviour_composition.rb +6 -1
- data/lib/tdriver/base/behaviour/behaviours/object_behaviour_description.rb +5 -3
- data/lib/tdriver/base/behaviour/behaviours/object_composition.rb +1 -1
- data/lib/tdriver/base/behaviour/factory.rb +225 -225
- data/lib/tdriver/base/errors.rb +1 -1
- data/lib/tdriver/base/state_object.rb +227 -179
- data/lib/tdriver/base/sut/controller.rb +2 -2
- data/lib/tdriver/base/sut/factory.rb +190 -182
- data/lib/tdriver/base/sut/generic/behaviours/application.rb +69 -25
- data/lib/tdriver/base/sut/generic/behaviours/controller.rb +1 -1
- data/lib/tdriver/base/sut/generic/behaviours/find.rb +4 -4
- data/lib/tdriver/base/sut/generic/behaviours/flash_behaviour.rb +3 -3
- data/lib/tdriver/base/sut/generic/behaviours/sut.rb +350 -165
- data/lib/tdriver/base/sut/generic/behaviours/switchbox_behaviour.rb +9 -9
- data/lib/tdriver/base/sut/generic/behaviours/verification.rb +191 -103
- data/lib/tdriver/base/sut/generic/commands/application.rb +1 -1
- data/lib/tdriver/base/sut/generic/commands/key_sequence.rb +1 -1
- data/lib/tdriver/base/sut/generic/commands/screen_capture.rb +1 -1
- data/lib/tdriver/base/sut/generic/plugin.rb +1 -1
- data/lib/tdriver/base/sut/sut.rb +5 -1
- data/lib/tdriver/base/test_object/abstract.rb +136 -151
- data/lib/tdriver/base/test_object/adapter.rb +293 -82
- data/lib/tdriver/base/test_object/behaviours/syncronization.rb +20 -17
- data/lib/tdriver/base/test_object/behaviours/test_object.rb +159 -532
- data/lib/tdriver/base/test_object/cache.rb +1 -1
- data/lib/tdriver/base/test_object/factory.rb +254 -605
- data/lib/tdriver/base/test_object/identificator.rb +1 -1
- data/lib/tdriver/base/test_object/loader.rb +1 -1
- data/lib/tdriver/base/test_object/verification.rb +17 -17
- data/lib/tdriver/loader.rb +20 -9
- data/lib/tdriver/report/report.rb +5 -0
- data/lib/tdriver/report/report_creator.rb +2 -2
- data/lib/tdriver/report/report_cucumber_listener.rb +4 -4
- data/lib/tdriver/report/report_cucumber_reporter.rb +4 -4
- data/lib/tdriver/report/report_execution_statistics.rb +22 -22
- data/lib/tdriver/report/report_grouping.rb +2 -2
- data/lib/tdriver/report/report_javascript.rb +11 -4
- data/lib/tdriver/report/report_test_case_run.rb +2 -2
- data/lib/tdriver/report/report_test_run.rb +5 -5
- data/lib/tdriver/report/report_test_unit.rb +74 -26
- data/lib/tdriver/report/report_writer.rb +70 -13
- data/lib/tdriver/tdriver.rb +17 -8
- data/lib/tdriver/util/common/array.rb +1 -1
- data/lib/tdriver/util/common/crc16.rb +1 -1
- data/lib/tdriver/util/common/environment.rb +1 -1
- data/lib/tdriver/util/common/file.rb +18 -9
- data/lib/tdriver/util/common/gem.rb +1 -1
- data/lib/tdriver/util/common/hash.rb +21 -0
- data/lib/tdriver/util/common/kernel.rb +1 -1
- data/lib/tdriver/util/common/loader.rb +5 -2
- data/lib/tdriver/util/common/numeric.rb +54 -3
- data/lib/tdriver/util/common/retryable.rb +30 -12
- data/lib/tdriver/util/common/stackable.rb +185 -0
- data/lib/tdriver/util/common/string.rb +21 -5
- data/lib/tdriver/util/{dbaccess/dbaccess.rb → database/access.rb} +4 -1
- data/lib/tdriver/util/{dbaccess/dbconnection.rb → database/connection.rb} +3 -0
- data/lib/tdriver/util/{dbaccess → database}/error.rb +0 -1
- data/lib/tdriver/util/{dbaccess → database}/loader.rb +5 -6
- data/lib/tdriver/util/{dynamic_attribute_filter.rb → filters/dynamic_attributes.rb} +1 -1
- data/lib/tdriver/util/hooking/hooking.rb +477 -0
- data/lib/tdriver/util/loader.rb +35 -29
- data/lib/tdriver/util/localisation/error.rb +0 -1
- data/lib/tdriver/util/localisation/loader.rb +1 -4
- data/lib/tdriver/util/localisation/localisation.rb +30 -27
- data/lib/tdriver/util/{common.rb → logger/loader.rb} +2 -4
- data/lib/tdriver/util/logger/logger.rb +574 -0
- data/lib/tdriver/util/operator_data/loader.rb +4 -3
- data/lib/tdriver/util/operator_data/operator_data.rb +5 -5
- data/lib/tdriver/util/parameter/parameter.rb +7 -1
- data/lib/tdriver/util/parameter/parameter_hash.rb +1 -1
- data/lib/tdriver/util/parameter/parameter_template.rb +1 -1
- data/lib/tdriver/util/parameter/parameter_user_api.rb +28 -20
- data/lib/tdriver/util/parameter/parameter_xml.rb +1 -1
- data/lib/tdriver/util/plugin/abstract.rb +1 -1
- data/lib/tdriver/util/plugin/service.rb +1 -1
- data/lib/tdriver/util/{localisation.rb → recorder/loader.rb} +4 -3
- data/lib/tdriver/util/recorder/recorder.rb +66 -0
- data/lib/tdriver/util/recorder/scripter.rb +258 -0
- data/lib/tdriver/util/{stats.rb → statistics/statistics.rb} +7 -8
- data/lib/tdriver/util/user_data/error.rb +0 -1
- data/lib/tdriver/util/user_data/loader.rb +1 -2
- data/lib/tdriver/util/user_data/user_data.rb +6 -6
- data/lib/tdriver/util/video/camera.rb +67 -0
- data/lib/tdriver/util/video/camera_linux.rb +139 -0
- data/lib/tdriver/util/video/camera_windows.rb +174 -0
- data/lib/tdriver/util/video/loader.rb +31 -0
- data/lib/tdriver/util/video/video_utils.rb +139 -0
- data/lib/tdriver/util/xml/abstraction.rb +56 -5
- data/lib/tdriver/util/xml/builder.rb +2 -5
- data/lib/tdriver/util/{parameter.rb → xml/comment.rb} +10 -2
- data/lib/tdriver/util/xml/loader.rb +32 -22
- data/lib/tdriver/util/xml/nil_node.rb +2 -2
- data/lib/tdriver/util/xml/parsers/loader.rb +0 -1
- data/lib/tdriver/util/xml/parsers/nokogiri/abstraction.rb +18 -44
- data/lib/tdriver/util/xml/parsers/nokogiri/attribute.rb +9 -13
- data/lib/tdriver/util/xml/parsers/nokogiri/builder.rb +9 -3
- data/lib/tdriver/util/xml/parsers/nokogiri/comment.rb +39 -0
- data/lib/tdriver/util/xml/parsers/nokogiri/document.rb +6 -11
- data/lib/tdriver/util/xml/parsers/nokogiri/element.rb +2 -122
- data/lib/tdriver/util/xml/parsers/nokogiri/loader.rb +26 -16
- data/lib/tdriver/util/xml/parsers/nokogiri/node.rb +203 -0
- data/lib/tdriver/util/xml/parsers/nokogiri/nodeset.rb +1 -2
- data/lib/tdriver/util/xml/parsers/nokogiri/text.rb +2 -20
- data/lib/tdriver/util/xml/xml.rb +52 -20
- data/lib/tdriver/verify/verify.rb +238 -81
- data/xml/behaviours/generic.xml +12 -10
- metadata +156 -180
- data/lib/tdriver/base/test_object/factory_new.rb +0 -202
- data/lib/tdriver/util/hooking.rb +0 -434
- data/lib/tdriver/util/logger.rb +0 -506
- data/lib/tdriver/util/recorder.rb +0 -297
- data/lib/tdriver/util/video_utils.rb +0 -384
- data/lib/tdriver/util/xml/nil_element.rb +0 -89
|
@@ -92,7 +92,7 @@ module MobyBase
|
|
|
92
92
|
begin
|
|
93
93
|
|
|
94
94
|
# extend command_data with combinination of command data object name and module name to be extended
|
|
95
|
-
eval 'command_data.extend %s::%s' % [ @sut_controllers[ controller ], command_data.class.name.scan( /::(.+)/ ) ]
|
|
95
|
+
eval 'command_data.extend %s::%s' % [ @sut_controllers[ controller ].first.first, command_data.class.name.scan( /::(.+)/ ).first.first ]
|
|
96
96
|
|
|
97
97
|
# break if controller associated succesfully
|
|
98
98
|
break
|
|
@@ -111,7 +111,7 @@ module MobyBase
|
|
|
111
111
|
end
|
|
112
112
|
|
|
113
113
|
# enable hooking for performance measurement & debug logging
|
|
114
|
-
|
|
114
|
+
TDriver::Hooking.hook_methods( self ) if defined?( TDriver::Hooking )
|
|
115
115
|
|
|
116
116
|
|
|
117
117
|
end # SutController
|
|
@@ -23,224 +23,232 @@ module MobyBase
|
|
|
23
23
|
# Hides actual SUT object from the clients -> clients should be able to use the instantiated SUT object as if it was any SUT
|
|
24
24
|
class SUTFactory
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
include Singleton
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
# Initialize the singleton
|
|
29
|
+
def initialize()
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
reset
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
end
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
# Create/reset hash to store sut ids for all current suts
|
|
36
|
+
def reset
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
@_sut_list = {}
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
end
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
def mapped_sut?( sut_id )
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
$parameters[ :mappings, {} ].has_key?( sut_id.to_sym )
|
|
45
45
|
|
|
46
|
-
|
|
46
|
+
end
|
|
47
47
|
|
|
48
48
|
|
|
49
|
-
|
|
49
|
+
def get_mapped_sut( sut_id )
|
|
50
50
|
|
|
51
|
-
|
|
51
|
+
$parameters[ :mappings ][ sut_id.to_sym ].to_sym
|
|
52
52
|
|
|
53
|
-
|
|
53
|
+
end
|
|
54
54
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
55
|
+
# Function to create the actual SUT objects based on the 'sut' attribute.
|
|
56
|
+
# === params
|
|
57
|
+
# sut_type:: sut_type - sut type, supportes all types defined by SUTFactory constants
|
|
58
|
+
# id:: id - unique identifier for identifying particular SUT from each other. Is propagated to proper initializers.
|
|
59
|
+
# === returns
|
|
60
|
+
# return:: SUT object
|
|
61
|
+
# raise::
|
|
62
|
+
# ArgumentError:: SUT ID '%s' not found from tdriver_parameters.xml
|
|
63
|
+
def make( sut_attributes )
|
|
64
64
|
|
|
65
|
-
|
|
65
|
+
sut_id = retrieve_sut_id_from_hash( sut_attributes )
|
|
66
66
|
|
|
67
|
-
|
|
67
|
+
sut_id = get_mapped_sut( sut_id ) if mapped_sut?( sut_id )
|
|
68
68
|
|
|
69
|
-
|
|
70
|
-
|
|
69
|
+
# if sut is already connected, return existing sut
|
|
70
|
+
return get_sut_from_list( sut_id ) if sut_exists?( sut_id )
|
|
71
71
|
|
|
72
|
+
# retrieve sut from parameters
|
|
73
|
+
sut = $parameters[ sut_id, nil ]
|
|
72
74
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
+
# raise exception if sut was not found
|
|
76
|
+
Kernel::raise ArgumentError.new( "%s not defined in TDriver parameters XML" % [ sut_id ]) if sut.nil?
|
|
77
|
+
|
|
78
|
+
# retrieve sut type from parameters
|
|
79
|
+
sut_type = sut[ :type, nil ]
|
|
80
|
+
|
|
81
|
+
# raise exception if sut type was not found
|
|
82
|
+
Kernel::raise RuntimeError.new( "SUT parameter 'type' not defined for %s in TDriver parameters/templates XML" % [ sut_id ] ) if sut_type.nil?
|
|
75
83
|
|
|
76
|
-
|
|
77
|
-
Kernel::raise ArgumentError.new( "%s not defined in TDriver parameters XML" % [ sut_id ]) if sut.nil?
|
|
78
|
-
|
|
79
|
-
# retrieve sut type from parameters
|
|
80
|
-
sut_type = sut[ :type, nil ]
|
|
81
|
-
|
|
82
|
-
# raise exception if sut type was not found
|
|
83
|
-
Kernel::raise RuntimeError.new( "SUT parameter 'type' not defined for %s in TDriver parameters/templates XML" % [ sut_id ] ) if sut_type.nil?
|
|
84
|
+
sut_type_symbol = sut_type.downcase.to_sym
|
|
84
85
|
|
|
85
|
-
|
|
86
|
+
# retrieve plugin name that implements given sut
|
|
87
|
+
sut_plugin = sut[ :sut_plugin, nil ]
|
|
86
88
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
+
# retrieve enviroment value from sut, use '*' as default
|
|
90
|
+
sut_env = sut[ :env, '*' ]
|
|
89
91
|
|
|
90
|
-
|
|
92
|
+
# verify that sut plugin is defined in sut configuration
|
|
93
|
+
Kernel::raise RuntimeError.new( "SUT parameter 'sut_plugin' not defined for %s (%s)" % [ sut_id, sut_type ] ) if sut_plugin.nil?
|
|
94
|
+
|
|
95
|
+
# flag to determine that should exception be raised; allow one retry, then set flag to true if error still occures
|
|
96
|
+
raise_exception = false
|
|
91
97
|
|
|
92
|
-
|
|
93
|
-
Kernel::raise RuntimeError.new( "SUT parameter 'sut_plugin' not defined for %s (%s)" % [ sut_id, sut_type ] ) if sut_plugin.nil?
|
|
94
|
-
|
|
95
|
-
# flag to determine that should exception be raised; allow one retry, then set flag to true if error still occures
|
|
96
|
-
raise_exception = false
|
|
98
|
+
begin
|
|
97
99
|
|
|
98
|
-
|
|
100
|
+
# verify that sut plugin is registered
|
|
101
|
+
if MobyUtil::PluginService.instance.plugin_registered?( sut_plugin, :sut )
|
|
102
|
+
|
|
103
|
+
# create sut object
|
|
104
|
+
created_sut = MobyUtil::PluginService.instance.call_plugin_method( sut_plugin, :make_sut, sut_id )
|
|
99
105
|
|
|
100
|
-
|
|
101
|
-
if MobyUtil::PluginService.instance.plugin_registered?( sut_plugin, :sut )
|
|
102
|
-
|
|
103
|
-
# create sut object
|
|
104
|
-
created_sut = MobyUtil::PluginService.instance.call_plugin_method( sut_plugin, :make_sut, sut_id )
|
|
106
|
+
else
|
|
105
107
|
|
|
106
|
-
|
|
108
|
+
# raise error if sut was not registered
|
|
109
|
+
Kernel::raise NotImplementedError.new( "No plugin implementation found for SUT type: %s" % [ sut_type ] )
|
|
107
110
|
|
|
108
|
-
|
|
109
|
-
Kernel::raise NotImplementedError.new( "No plugin implementation found for SUT type: %s" % [ sut_type ] )
|
|
111
|
+
end
|
|
110
112
|
|
|
111
|
-
|
|
113
|
+
rescue Exception => exception
|
|
112
114
|
|
|
113
|
-
|
|
115
|
+
# if sut was not registered, try to load it
|
|
116
|
+
MobyUtil::PluginService.instance.load_plugin( sut_plugin ) if exception.kind_of?( NotImplementedError )
|
|
114
117
|
|
|
115
|
-
|
|
116
|
-
MobyUtil::PluginService.instance.load_plugin( sut_plugin ) if exception.kind_of?( NotImplementedError )
|
|
118
|
+
if !raise_exception
|
|
117
119
|
|
|
118
|
-
|
|
120
|
+
raise_exception = true
|
|
121
|
+
retry
|
|
122
|
+
|
|
123
|
+
else
|
|
119
124
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
else
|
|
125
|
+
# still errors, raise original exception
|
|
126
|
+
Kernel::raise exception
|
|
124
127
|
|
|
125
|
-
|
|
126
|
-
Kernel::raise exception
|
|
128
|
+
end
|
|
127
129
|
|
|
128
|
-
|
|
130
|
+
end
|
|
129
131
|
|
|
130
|
-
|
|
132
|
+
# store SUT type to sut object
|
|
133
|
+
created_sut.instance_variable_set( :@ui_type, sut_type )
|
|
131
134
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
@ui_type = sut_type;
|
|
135
|
-
@ui_version = MobyUtil::Parameter[ sut_id ][ :version, nil ];
|
|
136
|
-
@input = MobyUtil::Parameter[ sut_id ][ :input_type, nil ];
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
# add behaviours to sut
|
|
140
|
-
created_sut.extend( MobyBehaviour::ObjectBehaviourComposition )
|
|
135
|
+
# store SUT UI version to sut object
|
|
136
|
+
created_sut.instance_variable_set( :@ui_version, $parameters[ sut_id ][ :version, nil ] )
|
|
141
137
|
|
|
142
|
-
|
|
143
|
-
|
|
138
|
+
# store SUT input type to sut object
|
|
139
|
+
created_sut.instance_variable_set( :@input, $parameters[ sut_id ][ :input_type, nil ] )
|
|
144
140
|
|
|
145
|
-
|
|
146
|
-
|
|
141
|
+
=begin
|
|
142
|
+
# sut type version, default: nil
|
|
143
|
+
created_sut.instance_eval{
|
|
147
144
|
|
|
148
|
-
|
|
145
|
+
@ui_type = sut_type
|
|
146
|
+
@ui_version = $parameters[ sut_id ][ :version, nil ]
|
|
147
|
+
@input = $parameters[ sut_id ][ :input_type, nil ]
|
|
149
148
|
|
|
150
|
-
|
|
149
|
+
}
|
|
150
|
+
=end
|
|
151
|
+
|
|
152
|
+
# retrieve list of optional extension plugins
|
|
153
|
+
@extension_plugins = $parameters[ sut_id ][ :extension_plugins, "" ].split( ";" )
|
|
151
154
|
|
|
152
|
-
|
|
155
|
+
# load optional extension plugins
|
|
156
|
+
if @extension_plugins.count > 0
|
|
153
157
|
|
|
154
|
-
|
|
155
|
-
unless MobyUtil::PluginService.instance.plugin_registered?( plugin_name, :extension )
|
|
158
|
+
@extension_plugins.each{ | plugin_name |
|
|
156
159
|
|
|
157
|
-
|
|
158
|
-
Kernel::raise NotImplementedError.new( "Extension plugin not found %s" % [ plugin_name ] )
|
|
160
|
+
raise_exception = false
|
|
159
161
|
|
|
160
|
-
|
|
162
|
+
begin
|
|
161
163
|
|
|
162
|
-
|
|
164
|
+
# verify that extension plugin is registered
|
|
165
|
+
unless MobyUtil::PluginService.instance.plugin_registered?( plugin_name, :extension )
|
|
163
166
|
|
|
164
|
-
|
|
165
|
-
|
|
167
|
+
# raise error if sut was not registered
|
|
168
|
+
Kernel::raise NotImplementedError.new( "Extension plugin not found %s" % [ plugin_name ] )
|
|
166
169
|
|
|
167
|
-
|
|
170
|
+
end
|
|
168
171
|
|
|
169
|
-
|
|
170
|
-
retry
|
|
171
|
-
else
|
|
172
|
+
rescue Exception => exception
|
|
172
173
|
|
|
173
|
-
|
|
174
|
-
|
|
174
|
+
# if sut was not registered, try to load it
|
|
175
|
+
MobyUtil::PluginService.instance.load_plugin( plugin_name ) if exception.kind_of?( NotImplementedError )
|
|
175
176
|
|
|
176
|
-
|
|
177
|
+
if !raise_exception
|
|
177
178
|
|
|
178
|
-
|
|
179
|
+
raise_exception = true
|
|
180
|
+
retry
|
|
181
|
+
else
|
|
179
182
|
|
|
180
|
-
|
|
183
|
+
# still errors, raise original exception
|
|
184
|
+
Kernel::raise exception
|
|
181
185
|
|
|
182
|
-
|
|
186
|
+
end
|
|
183
187
|
|
|
184
|
-
|
|
185
|
-
created_sut.apply_behaviour!(
|
|
186
|
-
:object_type => [ 'sut' ],
|
|
187
|
-
# :sut_type => [ '*', sut_type.upcase ],
|
|
188
|
-
# :sut_type => [ '*', sut_type ],
|
|
189
|
-
:input_type => [ '*', created_sut.input.to_s ],
|
|
190
|
-
:env => [ '*', *sut_env.to_s.split(";") ],
|
|
191
|
-
:version => [ '*', created_sut.ui_version.to_s ]
|
|
192
|
-
)
|
|
188
|
+
end
|
|
193
189
|
|
|
194
|
-
|
|
190
|
+
}
|
|
195
191
|
|
|
196
|
-
|
|
192
|
+
end
|
|
197
193
|
|
|
198
|
-
|
|
194
|
+
# apply sut generic behaviours
|
|
195
|
+
MobyBase::BehaviourFactory.instance.apply_behaviour!(
|
|
199
196
|
|
|
200
|
-
|
|
197
|
+
:object => created_sut,
|
|
198
|
+
:object_type => [ 'sut' ],
|
|
199
|
+
:sut_type => [ '*', created_sut.ui_type ],
|
|
200
|
+
:input_type => [ '*', created_sut.input.to_s ],
|
|
201
|
+
:env => [ '*', *sut_env.to_s.split(";") ],
|
|
202
|
+
:version => [ '*', created_sut.ui_version.to_s ]
|
|
201
203
|
|
|
202
|
-
|
|
204
|
+
)
|
|
205
|
+
|
|
206
|
+
@_sut_list[ sut_id ] = { :sut => created_sut, :is_connected => true }
|
|
203
207
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
"Unable disconnect SUT due to %s is not connected" % [ sut_id ]
|
|
207
|
-
|
|
208
|
-
) unless sut_exists?( sut_id ) && @_sut_list[ sut_id ][ :is_connected ]
|
|
209
|
-
|
|
210
|
-
@_sut_list[ sut_id ][ :sut ].disconnect
|
|
211
|
-
|
|
212
|
-
@_sut_list[ sut_id ][ :is_connected ] = false
|
|
208
|
+
created_sut
|
|
213
209
|
|
|
214
|
-
|
|
210
|
+
end
|
|
215
211
|
|
|
216
|
-
|
|
212
|
+
def disconnect_sut( sut_attributes )
|
|
213
|
+
|
|
214
|
+
sut_id = retrieve_sut_id_from_hash( sut_attributes )
|
|
215
|
+
|
|
216
|
+
Kernel::raise RuntimeError.new( "Unable disconnect SUT due to #{ sut_id.to_s } is not connected" ) unless sut_exists?( sut_id ) && @_sut_list[ sut_id ][ :is_connected ]
|
|
217
|
+
|
|
218
|
+
@_sut_list[ sut_id ][ :sut ].disconnect
|
|
219
|
+
|
|
220
|
+
@_sut_list[ sut_id ][ :is_connected ] = false
|
|
221
|
+
|
|
222
|
+
end
|
|
223
|
+
|
|
224
|
+
def reboot_sut( sut_attributes )
|
|
217
225
|
|
|
218
226
|
sut_id = retrieve_sut_id_from_hash( sut_attributes )
|
|
219
227
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
228
|
+
Kernel::raise RuntimeError.new(
|
|
229
|
+
|
|
230
|
+
"Unable to reboot SUT due to %s is not connected" % [ sut_id ]
|
|
231
|
+
|
|
232
|
+
) unless sut_exists?( sut_id ) && @_sut_list[ sut_id ][ :is_connected ]
|
|
233
|
+
|
|
234
|
+
@_sut_list[ sut_id ][ :sut ].reboot
|
|
227
235
|
|
|
228
|
-
|
|
236
|
+
disconnect_sut( sut_id )
|
|
229
237
|
|
|
230
|
-
|
|
238
|
+
end
|
|
231
239
|
|
|
232
|
-
|
|
240
|
+
def connected_suts
|
|
233
241
|
|
|
234
|
-
|
|
242
|
+
@_sut_list
|
|
235
243
|
|
|
236
|
-
|
|
244
|
+
end
|
|
237
245
|
|
|
238
|
-
|
|
246
|
+
private
|
|
239
247
|
|
|
240
248
|
def retrieve_sut_id_from_hash( sut_attributes )
|
|
241
249
|
|
|
242
|
-
|
|
243
|
-
|
|
250
|
+
# usability improvement: threat sut_attribute as SUT id if it is type of Symbol or String
|
|
251
|
+
sut_attributes = { :id => sut_attributes.to_sym } if [ String, Symbol ].include?( sut_attributes.class )
|
|
244
252
|
|
|
245
253
|
# verify that sut_attributes is type of Hash
|
|
246
254
|
sut_attributes.check_type( [ Hash, Symbol, String ], "Wrong argument type $1 for 'sut_attributes' (expected $2)" )
|
|
@@ -254,68 +262,68 @@ module MobyBase
|
|
|
254
262
|
|
|
255
263
|
end
|
|
256
264
|
|
|
257
|
-
|
|
258
|
-
|
|
265
|
+
# gets sut from sut-factorys list - if not connected tries to reconnect first
|
|
266
|
+
def get_sut_from_list( id )
|
|
259
267
|
|
|
260
|
-
|
|
268
|
+
if !@_sut_list[ id ][ :is_connected ]
|
|
261
269
|
|
|
262
|
-
|
|
263
|
-
|
|
270
|
+
@_sut_list[ id ][ :sut ].connect( id )
|
|
271
|
+
@_sut_list[ id ][ :is_connected ] = true
|
|
264
272
|
|
|
265
|
-
|
|
273
|
+
end
|
|
266
274
|
|
|
267
|
-
|
|
268
|
-
|
|
275
|
+
@_sut_list[ id ][ :sut ]
|
|
276
|
+
end
|
|
269
277
|
|
|
270
|
-
|
|
278
|
+
def sut_exists?( sut_id )
|
|
271
279
|
|
|
272
|
-
|
|
280
|
+
@_sut_list.has_key?( sut_id )
|
|
273
281
|
|
|
274
|
-
|
|
282
|
+
end
|
|
275
283
|
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
284
|
+
# Finds the sut definition matching the id, either directly or via a mapping
|
|
285
|
+
#
|
|
286
|
+
# === params
|
|
287
|
+
# sut_id:: Symbol defining the id of the sut to search for
|
|
288
|
+
# === returns
|
|
289
|
+
# Symbol:: Either id if it was found in the parameter file or the id of a sut mapped to this id, or nil if no direct or mapped match was found
|
|
290
|
+
# === raises
|
|
291
|
+
# ArgumentError:: The id argument was not a Symbol
|
|
292
|
+
def find_sut_or_mapping( sut_id )
|
|
285
293
|
|
|
286
294
|
sut_id.check_type( Symbol, "Wrong argument type $1 for SUT id (expected $2)" )
|
|
287
295
|
|
|
288
|
-
|
|
296
|
+
#Kernel::raise ArgumentError.new( "The id argument was not a Symbol." ) unless sut_id.kind_of?( Symbol )
|
|
289
297
|
|
|
290
|
-
|
|
298
|
+
begin
|
|
291
299
|
|
|
292
|
-
|
|
293
|
-
|
|
300
|
+
# check if direct match exists
|
|
301
|
+
return sut_id if $parameters[ sut_id ]
|
|
294
302
|
|
|
295
|
-
|
|
303
|
+
rescue MobyUtil::ParameterNotFoundError
|
|
296
304
|
|
|
297
|
-
|
|
298
|
-
|
|
305
|
+
# check if a mapping is defined for the id
|
|
306
|
+
begin
|
|
299
307
|
|
|
300
|
-
|
|
301
|
-
|
|
308
|
+
# return nil if no mapping exists
|
|
309
|
+
return nil if ( mapped_id = $parameters[ :mappings ][ sut_id ] ).nil?
|
|
302
310
|
|
|
303
|
-
|
|
304
|
-
|
|
311
|
+
# check if the mapped to sut id exists
|
|
312
|
+
return mapped_id if $parameters[ ( mapped_id = mapped_id.to_sym ) ]
|
|
305
313
|
|
|
306
|
-
|
|
314
|
+
rescue MobyUtil::ParameterNotFoundError
|
|
307
315
|
|
|
308
|
-
|
|
309
|
-
|
|
316
|
+
# no mappings defined in tdriver_parameters.xml or the mapped to sut was not found
|
|
317
|
+
return nil
|
|
310
318
|
|
|
311
|
-
|
|
319
|
+
end # check if mapping exists
|
|
312
320
|
|
|
313
|
-
|
|
321
|
+
end # check if direct match exists
|
|
314
322
|
|
|
315
|
-
|
|
323
|
+
end
|
|
316
324
|
|
|
317
|
-
|
|
318
|
-
|
|
325
|
+
# enable hooking for performance measurement & debug logging
|
|
326
|
+
TDriver::Hooking.hook_methods( self ) if defined?( TDriver::Hooking )
|
|
319
327
|
|
|
320
328
|
end # SUTFactory
|
|
321
329
|
|