testability-driver 1.2.1 → 1.3.0
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/bin/tdriver-devtools +0 -0
- data/ext/native_extensions.c +165 -6
- data/lib/tdriver-devtools/behaviour/old/xml/update +0 -0
- data/lib/tdriver-devtools/behaviour/xml/generate.rb +0 -0
- data/lib/tdriver-devtools/behaviour/xml/rdoc_behaviour_xml_generator.rb +15 -1
- data/lib/tdriver-devtools/doc/update +0 -0
- data/lib/tdriver-devtools/doc/xslt/template.xsl +24 -14
- data/lib/tdriver-devtools/doc/xslt/update +0 -0
- data/lib/tdriver-devtools/tdriver-devtools.rb +0 -0
- data/lib/tdriver-devtools/tests/feature_tests/update +0 -0
- data/lib/tdriver/base/behaviour/{behaviour.rb → abstract.rb} +3 -6
- data/lib/tdriver/base/behaviour/behaviours/object_abstract.rb +107 -0
- data/lib/tdriver/base/behaviour/behaviours/object_behaviour_composition.rb +2 -2
- data/lib/tdriver/base/behaviour/behaviours/object_behaviour_description.rb +47 -37
- data/lib/tdriver/base/behaviour/factory.rb +260 -382
- data/lib/tdriver/base/behaviour/loader.rb +22 -4
- data/lib/tdriver/base/controller/abstraction.rb +56 -0
- data/lib/tdriver/base/controller/loader.rb +21 -0
- data/lib/tdriver/base/loader.rb +3 -1
- data/lib/tdriver/base/sut/controller.rb +91 -74
- data/lib/tdriver/base/sut/factory.rb +8 -8
- data/lib/tdriver/base/sut/generic/behaviours/agent.rb +77 -0
- data/lib/tdriver/base/sut/generic/behaviours/sut.rb +116 -96
- data/lib/tdriver/base/sut/generic/commands/agent.rb +43 -0
- data/lib/tdriver/base/sut/sut.rb +10 -8
- data/lib/tdriver/base/test_object/abstract.rb +25 -24
- data/lib/tdriver/base/test_object/adapter.rb +67 -44
- data/lib/tdriver/base/test_object/behaviours/test_object.rb +79 -20
- data/lib/tdriver/base/test_object/factory.rb +45 -15
- data/lib/tdriver/base/test_object/xml/adapter.rb +80 -57
- data/lib/tdriver/env.rb +0 -0
- data/lib/tdriver/loader.rb +0 -0
- data/lib/tdriver/matti.rb +0 -0
- data/lib/tdriver/report/error_recovery/tdriver_error_recovery.rb +1 -0
- data/lib/tdriver/report/report.rb +2 -1
- data/lib/tdriver/report/report_crash_file_capture.rb +12 -0
- data/lib/tdriver/report/report_creator.rb +6 -2
- data/lib/tdriver/report/report_execution_statistics.rb +27 -11
- data/lib/tdriver/report/report_graph_generator.rb +59 -0
- data/lib/tdriver/report/report_test_case_run.rb +34 -2
- data/lib/tdriver/report/report_writer.rb +12 -0
- data/lib/tdriver/tdriver.rb +12 -1
- data/lib/tdriver/util/agent/loader.rb +22 -0
- data/lib/tdriver/util/agent/service.rb +107 -0
- data/lib/tdriver/util/common/crc16.rb +17 -10
- data/lib/tdriver/util/common/hash.rb +4 -1
- data/lib/tdriver/util/common/kernel.rb +11 -0
- data/lib/tdriver/util/common/numeric.rb +48 -0
- data/lib/tdriver/util/common/object.rb +5 -2
- data/lib/tdriver/util/common/string.rb +8 -1
- data/lib/tdriver/util/filters/attribute_filter.rb +121 -0
- data/lib/tdriver/util/filters/loader.rb +29 -0
- data/lib/tdriver/util/fixture/loader.rb +22 -0
- data/lib/tdriver/util/fixture/service.rb +157 -0
- data/lib/tdriver/util/loader.rb +8 -2
- data/lib/tdriver/util/logger/logger.rb +12 -6
- data/lib/tdriver/util/other/config.rb +0 -0
- data/lib/tdriver/util/parameter/parameter.rb +221 -152
- data/lib/tdriver/util/plugin/error.rb +0 -0
- data/lib/tdriver/util/video/camera_linux.rb +36 -22
- data/lib/tdriver/util/xml/parsers/nokogiri/abstraction.rb +3 -13
- data/lib/tdriver/util/xml/parsers/nokogiri/node.rb +13 -8
- data/lib/tdriver/util/xml/parsers/nokogiri/nodeset.rb +51 -9
- data/lib/tdriver/util/xml/xml.rb +4 -2
- data/lib/tdriver/verify/verify.rb +280 -621
- data/lib/tdriver/version.rb +1 -1
- data/xml/behaviours/generic.xml +34 -0
- data/xml/templates/generic.xml +20 -3
- metadata +168 -240
- data/lib/tdriver-devtools/tests/feature_tests/output/application_closable_0x3f.feature +0 -10
- data/lib/tdriver-devtools/tests/feature_tests/output/application_close.feature +0 -15
- data/lib/tdriver-devtools/tests/feature_tests/output/application_environment.feature +0 -10
- data/lib/tdriver-devtools/tests/feature_tests/output/application_executable_name.feature +0 -10
- data/lib/tdriver-devtools/tests/feature_tests/output/application_uid.feature +0 -10
- data/lib/tdriver-devtools/tests/feature_tests/output/created.rid +0 -1
- data/lib/tdriver-devtools/tests/feature_tests/output/find_find.feature +0 -15
- data/lib/tdriver-devtools/tests/feature_tests/output/flash_behaviour_flash.feature +0 -10
- data/lib/tdriver-devtools/tests/feature_tests/output/flash_behaviour_flash_images.feature +0 -15
- data/lib/tdriver-devtools/tests/feature_tests/output/sut_application.feature +0 -15
- data/lib/tdriver-devtools/tests/feature_tests/output/sut_capture_screen.feature +0 -10
- data/lib/tdriver-devtools/tests/feature_tests/output/sut_child.feature +0 -10
- data/lib/tdriver-devtools/tests/feature_tests/output/sut_clear_verify_blocks.feature +0 -10
- data/lib/tdriver-devtools/tests/feature_tests/output/sut_connect.feature +0 -10
- data/lib/tdriver-devtools/tests/feature_tests/output/sut_controller_execution_order.feature +0 -10
- data/lib/tdriver-devtools/tests/feature_tests/output/sut_controller_execution_order_0x3d.feature +0 -10
- data/lib/tdriver-devtools/tests/feature_tests/output/sut_current_application_id.feature +0 -15
- data/lib/tdriver-devtools/tests/feature_tests/output/sut_disconnect.feature +0 -10
- data/lib/tdriver-devtools/tests/feature_tests/output/sut_dump_count.feature +0 -15
- data/lib/tdriver-devtools/tests/feature_tests/output/sut_freeze.feature +0 -10
- data/lib/tdriver-devtools/tests/feature_tests/output/sut_frozen.feature +0 -10
- data/lib/tdriver-devtools/tests/feature_tests/output/sut_get_application_id.feature +0 -10
- data/lib/tdriver-devtools/tests/feature_tests/output/sut_get_object.feature +0 -10
- data/lib/tdriver-devtools/tests/feature_tests/output/sut_get_operator_data.feature +0 -10
- data/lib/tdriver-devtools/tests/feature_tests/output/sut_get_ui_dump.feature +0 -15
- data/lib/tdriver-devtools/tests/feature_tests/output/sut_get_user_information.feature +0 -10
- data/lib/tdriver-devtools/tests/feature_tests/output/sut_input.feature +0 -15
- data/lib/tdriver-devtools/tests/feature_tests/output/sut_parameter.feature +0 -15
- data/lib/tdriver-devtools/tests/feature_tests/output/sut_press_key.feature +0 -10
- data/lib/tdriver-devtools/tests/feature_tests/output/sut_received_data.feature +0 -10
- data/lib/tdriver-devtools/tests/feature_tests/output/sut_refresh.feature +0 -20
- data/lib/tdriver-devtools/tests/feature_tests/output/sut_refresh_timeout.feature +0 -15
- data/lib/tdriver-devtools/tests/feature_tests/output/sut_refresh_tries.feature +0 -15
- data/lib/tdriver-devtools/tests/feature_tests/output/sut_refresh_ui_dump.feature +0 -20
- data/lib/tdriver-devtools/tests/feature_tests/output/sut_run.feature +0 -10
- data/lib/tdriver-devtools/tests/feature_tests/output/sut_sent_data.feature +0 -10
- data/lib/tdriver-devtools/tests/feature_tests/output/sut_state.feature +0 -10
- data/lib/tdriver-devtools/tests/feature_tests/output/sut_translate.feature +0 -30
- data/lib/tdriver-devtools/tests/feature_tests/output/sut_ui_type.feature +0 -10
- data/lib/tdriver-devtools/tests/feature_tests/output/sut_ui_version.feature +0 -10
- data/lib/tdriver-devtools/tests/feature_tests/output/sut_unfreeze.feature +0 -10
- data/lib/tdriver-devtools/tests/feature_tests/output/sut_update.feature +0 -10
- data/lib/tdriver-devtools/tests/feature_tests/output/sut_verify_always.feature +0 -20
- data/lib/tdriver-devtools/tests/feature_tests/output/sut_verify_blocks.feature +0 -10
- data/lib/tdriver-devtools/tests/feature_tests/output/sut_x_path.feature +0 -10
- data/lib/tdriver-devtools/tests/feature_tests/output/sut_xml_data.feature +0 -10
- data/lib/tdriver-devtools/tests/feature_tests/output/sut_xml_data_0x3d.feature +0 -10
- data/lib/tdriver-devtools/tests/feature_tests/output/sut_xml_data_crc.feature +0 -10
- data/lib/tdriver-devtools/tests/feature_tests/output/switchbox_behaviour_power_down.feature +0 -10
- data/lib/tdriver-devtools/tests/feature_tests/output/switchbox_behaviour_power_status.feature +0 -10
- data/lib/tdriver-devtools/tests/feature_tests/output/switchbox_behaviour_power_up.feature +0 -10
- data/lib/tdriver-devtools/tests/feature_tests/output/switchbox_behaviour_reset.feature +0 -10
- data/lib/tdriver-devtools/tests/feature_tests/output/verification_test_object_exists_0x3f.feature +0 -15
- data/lib/tdriver/base/behaviour/factory_new.rb +0 -409
- data/lib/tdriver/base/test_object/identificator.rb +0 -518
- data/lib/tdriver/util/filters/dynamic_attributes.rb +0 -189
|
Binary file
|
|
@@ -17,6 +17,8 @@
|
|
|
17
17
|
##
|
|
18
18
|
############################################################################
|
|
19
19
|
|
|
20
|
+
require 'open3'
|
|
21
|
+
|
|
20
22
|
module MobyUtil
|
|
21
23
|
|
|
22
24
|
# Linux streamer webcam implementation
|
|
@@ -25,7 +27,7 @@ module MobyUtil
|
|
|
25
27
|
|
|
26
28
|
STARTUP_TIMEOUT = 60
|
|
27
29
|
|
|
28
|
-
DEFAULT_OPTIONS = { :device => '/dev/video0', :width => 320, :height => 240, :fps => 5 }
|
|
30
|
+
DEFAULT_OPTIONS = { :device => '/dev/video0', :width => 320, :height => 240, :fps => 5, :max_time => '99:00:00' }
|
|
29
31
|
|
|
30
32
|
# TODO: document me
|
|
31
33
|
def self.new_cam( *args )
|
|
@@ -51,6 +53,7 @@ module MobyUtil
|
|
|
51
53
|
@_video_file = video_file
|
|
52
54
|
@_rec_options = DEFAULT_OPTIONS.merge user_options
|
|
53
55
|
|
|
56
|
+
@rec_app = 'streamer'
|
|
54
57
|
end
|
|
55
58
|
|
|
56
59
|
# Starts recording based on options given during initialization
|
|
@@ -67,15 +70,13 @@ module MobyUtil
|
|
|
67
70
|
# no reaction to failed file ops, unless recording fails
|
|
68
71
|
end
|
|
69
72
|
end
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
raise RuntimeError.new( "An error was encountered while launching streamer:\n" << e.inspect )
|
|
78
|
-
end
|
|
73
|
+
|
|
74
|
+
rec_opts = ' -q -c ' + @_rec_options[ :device ].to_s + ' -f rgb24 -r ' + @_rec_options[ :fps ].to_s + ' -t ' +
|
|
75
|
+
@_rec_options[:max_time] + ' -o ' + @_video_file.to_s + ' -s ' + @_rec_options[ :width ].to_s + 'x' + @_rec_options[ :height ].to_s
|
|
76
|
+
begin
|
|
77
|
+
@stdin, @stdout, @stderr = Open3.popen3(@rec_app + rec_opts)
|
|
78
|
+
rescue => e
|
|
79
|
+
raise RuntimeError.new( "An error was encountered while launching streamer:\n" << e.inspect )
|
|
79
80
|
end
|
|
80
81
|
|
|
81
82
|
file_timed_out = false
|
|
@@ -94,11 +95,8 @@ module MobyUtil
|
|
|
94
95
|
if file_timed_out
|
|
95
96
|
|
|
96
97
|
# make sure recording is not initializing, clean up any failed file
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
rescue
|
|
100
|
-
end
|
|
101
|
-
|
|
98
|
+
stop_recording
|
|
99
|
+
|
|
102
100
|
if File.exists?( @_video_file )
|
|
103
101
|
begin
|
|
104
102
|
File.delete( @_video_file )
|
|
@@ -113,8 +111,9 @@ module MobyUtil
|
|
|
113
111
|
@_recording = true
|
|
114
112
|
|
|
115
113
|
nil
|
|
116
|
-
|
|
117
114
|
end
|
|
115
|
+
|
|
116
|
+
|
|
118
117
|
|
|
119
118
|
# Stops ongoing recording
|
|
120
119
|
def stop_recording
|
|
@@ -122,14 +121,29 @@ module MobyUtil
|
|
|
122
121
|
if @_recording
|
|
123
122
|
|
|
124
123
|
@_recording = false
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
124
|
+
|
|
125
|
+
begin
|
|
126
|
+
@stdin.close unless @stdin.closed?
|
|
127
|
+
@stdout.close unless @stdout.closed?
|
|
128
|
+
@stderr.close unless @stderr.closed?
|
|
129
|
+
|
|
130
|
+
sleep 10 # allow some time to close (yes, it can take up to 10 seconds)
|
|
131
|
+
pid = `pidof #{@rec_app}`.to_i
|
|
132
|
+
begin
|
|
133
|
+
if pid != 0
|
|
134
|
+
Process.kill(9,pid)
|
|
135
|
+
end
|
|
136
|
+
rescue => e
|
|
137
|
+
puts "Got error " + e.inspect
|
|
138
|
+
end
|
|
139
|
+
rescue => e
|
|
140
|
+
raise RuntimeError.new( "Failed to end recording. Errror:\n " << e.inspect)
|
|
141
|
+
end
|
|
128
142
|
end
|
|
129
|
-
|
|
143
|
+
|
|
130
144
|
nil
|
|
131
|
-
|
|
132
|
-
end
|
|
145
|
+
|
|
146
|
+
end
|
|
133
147
|
|
|
134
148
|
# enable hooking for performance measurement & debug logging
|
|
135
149
|
TDriver::Hooking.hook_methods( self ) if defined?( TDriver::Hooking )
|
|
@@ -44,10 +44,6 @@ module MobyUtil
|
|
|
44
44
|
# TODO: document me
|
|
45
45
|
def cache( key, value )
|
|
46
46
|
|
|
47
|
-
yield
|
|
48
|
-
|
|
49
|
-
# JKo: disable xml caching for now, need more investigation why tests starts to fail
|
|
50
|
-
=begin
|
|
51
47
|
if @options[ :cache_enabled ] == true
|
|
52
48
|
|
|
53
49
|
@cache[ key ].fetch( value ){
|
|
@@ -61,7 +57,6 @@ module MobyUtil
|
|
|
61
57
|
yield
|
|
62
58
|
|
|
63
59
|
end
|
|
64
|
-
=end
|
|
65
60
|
|
|
66
61
|
end
|
|
67
62
|
|
|
@@ -78,13 +73,6 @@ module MobyUtil
|
|
|
78
73
|
|
|
79
74
|
include Cache
|
|
80
75
|
|
|
81
|
-
# TODO: Documentation
|
|
82
|
-
def empty?
|
|
83
|
-
|
|
84
|
-
cache( :is_nil, :value ){ @xml.nil? }
|
|
85
|
-
|
|
86
|
-
end
|
|
87
|
-
|
|
88
76
|
# TODO: Documentation
|
|
89
77
|
def name
|
|
90
78
|
|
|
@@ -95,10 +83,12 @@ module MobyUtil
|
|
|
95
83
|
# TODO: Documentation
|
|
96
84
|
def nil?
|
|
97
85
|
|
|
98
|
-
cache( :
|
|
86
|
+
cache( :nil?, :value ){ @xml.nil? }
|
|
99
87
|
|
|
100
88
|
end
|
|
101
89
|
|
|
90
|
+
alias :empty? :nil?
|
|
91
|
+
|
|
102
92
|
# TODO: Documentation
|
|
103
93
|
def size
|
|
104
94
|
|
|
@@ -30,7 +30,7 @@ module MobyUtil
|
|
|
30
30
|
# TODO: document me
|
|
31
31
|
def []( value )
|
|
32
32
|
|
|
33
|
-
cache(
|
|
33
|
+
cache( :[], value ){ @xml[ value ] }
|
|
34
34
|
|
|
35
35
|
end
|
|
36
36
|
|
|
@@ -46,7 +46,7 @@ module MobyUtil
|
|
|
46
46
|
# TODO: document me
|
|
47
47
|
def ==( object )
|
|
48
48
|
|
|
49
|
-
cache(
|
|
49
|
+
cache( :==, object.object_id ){ @xml.content == object.xml.content }
|
|
50
50
|
|
|
51
51
|
end
|
|
52
52
|
|
|
@@ -56,7 +56,7 @@ module MobyUtil
|
|
|
56
56
|
# TODO: document me
|
|
57
57
|
def <=>( object )
|
|
58
58
|
|
|
59
|
-
cache(
|
|
59
|
+
cache( :<=>, object.object_id ){ @xml <=> object.xml }
|
|
60
60
|
|
|
61
61
|
end
|
|
62
62
|
|
|
@@ -80,10 +80,15 @@ module MobyUtil
|
|
|
80
80
|
def attributes
|
|
81
81
|
|
|
82
82
|
cache( :attributes, :value ){
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
]
|
|
83
|
+
|
|
84
|
+
# return hash of attributes
|
|
85
|
+
#Hash[ @xml.attribute_nodes.collect{ | node |
|
|
86
|
+
# [ node.node_name, node.value.to_s ] }
|
|
87
|
+
#]
|
|
88
|
+
|
|
89
|
+
# approx. 20% faster
|
|
90
|
+
@xml.attribute_nodes.inject({}){ | result, node | result[ node.node_name ] = node.value; result }
|
|
91
|
+
|
|
87
92
|
}
|
|
88
93
|
|
|
89
94
|
end
|
|
@@ -91,7 +96,7 @@ module MobyUtil
|
|
|
91
96
|
# TODO: document me
|
|
92
97
|
def blank?
|
|
93
98
|
|
|
94
|
-
cache( :
|
|
99
|
+
cache( :blank?, :value ){ @xml.blank? }
|
|
95
100
|
|
|
96
101
|
end
|
|
97
102
|
|
|
@@ -35,7 +35,7 @@ module MobyUtil
|
|
|
35
35
|
|
|
36
36
|
def first
|
|
37
37
|
|
|
38
|
-
cache( :first, :
|
|
38
|
+
cache( :first, :value ){ node_object( @xml.first ) }
|
|
39
39
|
|
|
40
40
|
end
|
|
41
41
|
|
|
@@ -47,13 +47,26 @@ module MobyUtil
|
|
|
47
47
|
|
|
48
48
|
def each( &block )
|
|
49
49
|
|
|
50
|
-
|
|
50
|
+
#@xml.each{ | node |
|
|
51
|
+
# yield( cache( :each, node ){ node_object( node ) } )
|
|
52
|
+
#}
|
|
51
53
|
|
|
52
|
-
|
|
54
|
+
# approx. 3,5% faster
|
|
55
|
+
cache( :each, :cached_nodes ){
|
|
53
56
|
|
|
54
|
-
|
|
57
|
+
@xml.collect{ | node |
|
|
55
58
|
|
|
56
|
-
|
|
59
|
+
cache( :each, node ){ node_object( node ) }
|
|
60
|
+
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
}.each{ | node |
|
|
64
|
+
|
|
65
|
+
yield( node )
|
|
66
|
+
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
self
|
|
57
70
|
|
|
58
71
|
end
|
|
59
72
|
|
|
@@ -87,7 +100,7 @@ module MobyUtil
|
|
|
87
100
|
|
|
88
101
|
def compact
|
|
89
102
|
|
|
90
|
-
cache( :compact, :value ){
|
|
103
|
+
cache( :compact, :value ){ node_object( @xml.compact ) }
|
|
91
104
|
|
|
92
105
|
end
|
|
93
106
|
|
|
@@ -99,9 +112,23 @@ module MobyUtil
|
|
|
99
112
|
|
|
100
113
|
end
|
|
101
114
|
|
|
115
|
+
def inject( result, &block )
|
|
116
|
+
|
|
117
|
+
cache( :each, :cached_nodes ){
|
|
118
|
+
|
|
119
|
+
@xml.collect{ | node |
|
|
120
|
+
|
|
121
|
+
cache( :each, node ){ node_object( node ) }
|
|
122
|
+
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
}.__send__( :inject, result, &block )
|
|
126
|
+
|
|
127
|
+
end
|
|
128
|
+
|
|
102
129
|
def sort( &block )
|
|
103
130
|
|
|
104
|
-
|
|
131
|
+
node_object( _sort( &block ) )
|
|
105
132
|
|
|
106
133
|
end
|
|
107
134
|
|
|
@@ -117,7 +144,7 @@ module MobyUtil
|
|
|
117
144
|
|
|
118
145
|
def empty?
|
|
119
146
|
|
|
120
|
-
cache( :
|
|
147
|
+
cache( :empty?, :value ){ @xml.empty? }
|
|
121
148
|
|
|
122
149
|
end
|
|
123
150
|
|
|
@@ -161,7 +188,22 @@ module MobyUtil
|
|
|
161
188
|
|
|
162
189
|
def _collect( &block )
|
|
163
190
|
|
|
164
|
-
|
|
191
|
+
#@xml.collect{ | node | yield( cache( :each, node ){ node_object( node ) } ) }
|
|
192
|
+
|
|
193
|
+
# approx. 3.5% faster
|
|
194
|
+
cache( :each, :cached_nodes ){
|
|
195
|
+
|
|
196
|
+
@xml.collect{ | node |
|
|
197
|
+
|
|
198
|
+
cache( :each, node ){ node_object( node ) }
|
|
199
|
+
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
}.collect{ | node |
|
|
203
|
+
|
|
204
|
+
yield( node )
|
|
205
|
+
|
|
206
|
+
}
|
|
165
207
|
|
|
166
208
|
end
|
|
167
209
|
|
data/lib/tdriver/util/xml/xml.rb
CHANGED
|
@@ -141,6 +141,7 @@ module MobyUtil
|
|
|
141
141
|
|
|
142
142
|
begin
|
|
143
143
|
|
|
144
|
+
=begin
|
|
144
145
|
unless crc.nil?
|
|
145
146
|
|
|
146
147
|
[ Document.new( xml_string ), false ]
|
|
@@ -150,9 +151,10 @@ module MobyUtil
|
|
|
150
151
|
Document.new( xml_string )
|
|
151
152
|
|
|
152
153
|
end
|
|
154
|
+
=end
|
|
153
155
|
|
|
154
156
|
# JKo: disable xml caching for now, need more investigation why tests starts to fail
|
|
155
|
-
|
|
157
|
+
#=begin
|
|
156
158
|
unless crc.nil?
|
|
157
159
|
|
|
158
160
|
if @document_cache[ :cache ].include?( crc )
|
|
@@ -202,7 +204,7 @@ module MobyUtil
|
|
|
202
204
|
Document.new( xml_string )
|
|
203
205
|
|
|
204
206
|
end
|
|
205
|
-
|
|
207
|
+
#=end
|
|
206
208
|
rescue
|
|
207
209
|
|
|
208
210
|
if $TDRIVER_INITIALIZED == true
|
|
@@ -47,7 +47,7 @@ module TDriverVerify
|
|
|
47
47
|
|
|
48
48
|
rescue Exception
|
|
49
49
|
|
|
50
|
-
raise
|
|
50
|
+
raise $!.class, "Exception was raised while executing on_error_verify_block. Reason: #{ $!.message.to_s }"
|
|
51
51
|
|
|
52
52
|
end
|
|
53
53
|
|
|
@@ -83,18 +83,21 @@ module TDriverVerify
|
|
|
83
83
|
# disable behaviour logging
|
|
84
84
|
$logger.enabled = false
|
|
85
85
|
|
|
86
|
-
# ensure that code block was given
|
|
87
|
-
raise ArgumentError, "No block was given." unless block_given?
|
|
88
|
-
|
|
89
86
|
# ensure that timeout is either nil or type of integer
|
|
90
|
-
|
|
87
|
+
timeout.check_type [ Integer, NilClass ], 'wrong argument type $1 for timeout (expected $2)'
|
|
91
88
|
|
|
92
89
|
# ensure that message is either nil or type of string
|
|
93
|
-
|
|
90
|
+
message.check_type [ String, NilClass ], 'wrong argument type $1 for exception message (expected $2)'
|
|
91
|
+
|
|
92
|
+
# verify that block was given
|
|
93
|
+
raise LocalJumpError, 'unable to verify due to no code block was given' unless block_given?
|
|
94
94
|
|
|
95
95
|
# convert timeout to integer, nil will be zero
|
|
96
96
|
timeout = get_timeout( timeout )
|
|
97
97
|
|
|
98
|
+
# verify that timeout is valid
|
|
99
|
+
timeout.not_negative 'timeout value cannot be negative'
|
|
100
|
+
|
|
98
101
|
# calculate the time when timeout exceeds
|
|
99
102
|
timeout_end_time = Time.now + timeout
|
|
100
103
|
|
|
@@ -127,7 +130,7 @@ module TDriverVerify
|
|
|
127
130
|
raise if $!.kind_of?( MobyBase::ContinuousVerificationError )
|
|
128
131
|
|
|
129
132
|
# refresh and retry unless timeout exceeded
|
|
130
|
-
raise $! if Time.
|
|
133
|
+
raise $! if Time.now > timeout_end_time
|
|
131
134
|
|
|
132
135
|
# retry interval
|
|
133
136
|
sleep TIMEOUT_CYCLE_SECONDS
|
|
@@ -204,18 +207,21 @@ module TDriverVerify
|
|
|
204
207
|
# disable behaviour logging
|
|
205
208
|
$logger.enabled = false
|
|
206
209
|
|
|
207
|
-
# ensure that code block was given
|
|
208
|
-
raise ArgumentError, "No block was given." unless block_given?
|
|
209
|
-
|
|
210
210
|
# ensure that timeout is either nil or type of integer
|
|
211
|
-
|
|
211
|
+
timeout.check_type [ Integer, NilClass ], 'wrong argument type $1 for timeout (expected $2)'
|
|
212
212
|
|
|
213
213
|
# ensure that message is either nil or type of string
|
|
214
|
-
|
|
214
|
+
message.check_type [ String, NilClass ], 'wrong argument type $1 for exception message (expected $2)'
|
|
215
|
+
|
|
216
|
+
# verify that block was given
|
|
217
|
+
raise LocalJumpError, 'unable to verify due to no code block was given' unless block_given?
|
|
215
218
|
|
|
216
219
|
# convert timeout to integer, nil will be zero
|
|
217
220
|
timeout = get_timeout( timeout )
|
|
218
221
|
|
|
222
|
+
# verify that timeout is valid
|
|
223
|
+
timeout.not_negative 'timeout value cannot be negative'
|
|
224
|
+
|
|
219
225
|
# calculate the time when timeout exceeds
|
|
220
226
|
timeout_end_time = Time.now + timeout
|
|
221
227
|
|
|
@@ -253,7 +259,7 @@ module TDriverVerify
|
|
|
253
259
|
end
|
|
254
260
|
|
|
255
261
|
# refresh and retry unless timeout exceeded
|
|
256
|
-
raise $! if Time.
|
|
262
|
+
raise $! if Time.now > timeout_end_time
|
|
257
263
|
|
|
258
264
|
# retry interval
|
|
259
265
|
sleep TIMEOUT_CYCLE_SECONDS
|
|
@@ -337,18 +343,21 @@ module TDriverVerify
|
|
|
337
343
|
# disable behaviour logging
|
|
338
344
|
$logger.enabled = false
|
|
339
345
|
|
|
340
|
-
# ensure that code block was given
|
|
341
|
-
raise ArgumentError, "No block was given." unless block_given?
|
|
342
|
-
|
|
343
346
|
# ensure that timeout is either nil or type of integer
|
|
344
|
-
|
|
347
|
+
timeout.check_type [ Integer, NilClass ], 'wrong argument type $1 for timeout (expected $2)'
|
|
345
348
|
|
|
346
349
|
# ensure that message is either nil or type of string
|
|
347
|
-
|
|
350
|
+
message.check_type [ String, NilClass ], 'wrong argument type $1 for exception message (expected $2)'
|
|
351
|
+
|
|
352
|
+
# verify that block was given
|
|
353
|
+
raise LocalJumpError, 'unable to verify due to no code block was given' unless block_given?
|
|
348
354
|
|
|
349
355
|
# convert timeout to integer, nil will be zero
|
|
350
356
|
timeout = get_timeout( timeout )
|
|
351
357
|
|
|
358
|
+
# verify that timeout is valid
|
|
359
|
+
timeout.not_negative 'timeout value cannot be negative'
|
|
360
|
+
|
|
352
361
|
# calculate the time when timeout exceeds
|
|
353
362
|
timeout_end_time = Time.now + timeout
|
|
354
363
|
|
|
@@ -387,7 +396,7 @@ module TDriverVerify
|
|
|
387
396
|
raise if $!.kind_of?( MobyBase::ContinuousVerificationError )
|
|
388
397
|
|
|
389
398
|
# refresh and retry unless timeout exceeded
|
|
390
|
-
raise $! if Time.
|
|
399
|
+
raise $! if Time.now > timeout_end_time
|
|
391
400
|
|
|
392
401
|
# retry interval
|
|
393
402
|
sleep TIMEOUT_CYCLE_SECONDS
|
|
@@ -473,18 +482,21 @@ module TDriverVerify
|
|
|
473
482
|
# disable behaviour logging
|
|
474
483
|
$logger.enabled = false
|
|
475
484
|
|
|
476
|
-
# ensure that code block was given
|
|
477
|
-
raise ArgumentError, "No block was given." unless block_given?
|
|
478
|
-
|
|
479
485
|
# ensure that timeout is either nil or type of integer
|
|
480
|
-
|
|
486
|
+
timeout.check_type [ Integer, NilClass ], 'wrong argument type $1 for timeout (expected $2)'
|
|
481
487
|
|
|
482
488
|
# ensure that message is either nil or type of string
|
|
483
|
-
|
|
489
|
+
message.check_type [ String, NilClass ], 'wrong argument type $1 for exception message (expected $2)'
|
|
490
|
+
|
|
491
|
+
# verify that block was given
|
|
492
|
+
raise LocalJumpError, 'unable to verify due to no code block was given' unless block_given?
|
|
484
493
|
|
|
485
494
|
# convert timeout to integer, nil will be zero
|
|
486
495
|
timeout = get_timeout( timeout )
|
|
487
496
|
|
|
497
|
+
# verify that timeout is valid
|
|
498
|
+
timeout.not_negative 'timeout value cannot be negative'
|
|
499
|
+
|
|
488
500
|
# calculate the time when timeout exceeds
|
|
489
501
|
timeout_end_time = Time.now + timeout
|
|
490
502
|
|
|
@@ -523,7 +535,7 @@ module TDriverVerify
|
|
|
523
535
|
raise if $!.kind_of?( MobyBase::ContinuousVerificationError )
|
|
524
536
|
|
|
525
537
|
# refresh and retry unless timeout exceeded
|
|
526
|
-
raise $! if Time.
|
|
538
|
+
raise $! if Time.now > timeout_end_time
|
|
527
539
|
|
|
528
540
|
# retry interval
|
|
529
541
|
sleep TIMEOUT_CYCLE_SECONDS
|
|
@@ -581,7 +593,7 @@ module TDriverVerify
|
|
|
581
593
|
|
|
582
594
|
end
|
|
583
595
|
|
|
584
|
-
# Verifies that
|
|
596
|
+
# Verifies that result of given block equals to expected value. Verification is synchronized with all connected suts.
|
|
585
597
|
# If this method is called for a sut, synchronization is only done with that sut.
|
|
586
598
|
#
|
|
587
599
|
# === params
|
|
@@ -607,18 +619,21 @@ module TDriverVerify
|
|
|
607
619
|
# disable behaviour logging
|
|
608
620
|
$logger.enabled = false
|
|
609
621
|
|
|
610
|
-
# ensure that code block was given
|
|
611
|
-
raise ArgumentError, "No block was given." unless block_given?
|
|
612
|
-
|
|
613
622
|
# ensure that timeout is either nil or type of integer
|
|
614
|
-
|
|
623
|
+
timeout.check_type [ Integer, NilClass ], 'wrong argument type $1 for timeout (expected $2)'
|
|
615
624
|
|
|
616
625
|
# ensure that message is either nil or type of string
|
|
617
|
-
|
|
626
|
+
message.check_type [ String, NilClass ], 'wrong argument type $1 for exception message (expected $2)'
|
|
627
|
+
|
|
628
|
+
# verify that block was given
|
|
629
|
+
raise LocalJumpError, 'unable to verify due to no code block was given' unless block_given?
|
|
618
630
|
|
|
619
631
|
# convert timeout to integer, nil will be zero
|
|
620
632
|
timeout = get_timeout( timeout )
|
|
621
633
|
|
|
634
|
+
# verify that timeout is valid
|
|
635
|
+
timeout.not_negative 'timeout value cannot be negative'
|
|
636
|
+
|
|
622
637
|
# calculate the time when timeout exceeds
|
|
623
638
|
timeout_end_time = Time.now + timeout
|
|
624
639
|
|
|
@@ -657,7 +672,7 @@ module TDriverVerify
|
|
|
657
672
|
raise if $!.kind_of?( MobyBase::ContinuousVerificationError )
|
|
658
673
|
|
|
659
674
|
# refresh and retry unless timeout exceeded
|
|
660
|
-
raise $! if Time.
|
|
675
|
+
raise $! if Time.now > timeout_end_time
|
|
661
676
|
|
|
662
677
|
# retry interval
|
|
663
678
|
sleep TIMEOUT_CYCLE_SECONDS
|
|
@@ -715,21 +730,20 @@ module TDriverVerify
|
|
|
715
730
|
|
|
716
731
|
end
|
|
717
732
|
|
|
718
|
-
# Verifies that the
|
|
733
|
+
# Verifies that result of the given block is less than expected value. Verification is synchronized with all connected suts.
|
|
719
734
|
# If this method is called for a sut, synchronization is only done with that sut.
|
|
720
735
|
#
|
|
721
736
|
# === params
|
|
722
|
-
# expected::
|
|
737
|
+
# expected:: Expected result value of the block
|
|
723
738
|
# timeout:: (optional) Integer defining the amount of seconds during which the verification must pass.
|
|
724
739
|
# message:: (optional) A String that is displayed as additional information if the verification fails.
|
|
725
740
|
# === returns
|
|
726
741
|
# nil
|
|
727
742
|
# === raises
|
|
728
743
|
# ArgumentError:: message was not a String or timeout an integer, or no block was given.
|
|
729
|
-
# TypeError:: if block result not type of String.
|
|
730
744
|
# VerificationError:: The verification failed.
|
|
731
745
|
# RuntimeError:: An unexpected error was encountered during verification.
|
|
732
|
-
def
|
|
746
|
+
def verify_less( expected_value, timeout = nil, message = nil, &block )
|
|
733
747
|
|
|
734
748
|
begin
|
|
735
749
|
|
|
@@ -742,20 +756,21 @@ module TDriverVerify
|
|
|
742
756
|
# disable behaviour logging
|
|
743
757
|
$logger.enabled = false
|
|
744
758
|
|
|
745
|
-
# ensure that code block was given
|
|
746
|
-
raise ArgumentError, "No block was given." unless block_given?
|
|
747
|
-
|
|
748
759
|
# ensure that timeout is either nil or type of integer
|
|
749
|
-
|
|
760
|
+
timeout.check_type [ Integer, NilClass ], 'wrong argument type $1 for timeout (expected $2)'
|
|
750
761
|
|
|
751
762
|
# ensure that message is either nil or type of string
|
|
752
|
-
|
|
763
|
+
message.check_type [ String, NilClass ], 'wrong argument type $1 for exception message (expected $2)'
|
|
753
764
|
|
|
754
|
-
|
|
765
|
+
# verify that block was given
|
|
766
|
+
raise LocalJumpError, 'unable to verify due to no code block was given' unless block_given?
|
|
755
767
|
|
|
756
768
|
# convert timeout to integer, nil will be zero
|
|
757
769
|
timeout = get_timeout( timeout )
|
|
758
770
|
|
|
771
|
+
# verify that timeout is valid
|
|
772
|
+
timeout.not_negative 'timeout value cannot be negative'
|
|
773
|
+
|
|
759
774
|
# calculate the time when timeout exceeds
|
|
760
775
|
timeout_end_time = Time.now + timeout
|
|
761
776
|
|
|
@@ -783,8 +798,8 @@ module TDriverVerify
|
|
|
783
798
|
# execute code block
|
|
784
799
|
result = yield
|
|
785
800
|
|
|
786
|
-
# raise exception if result of yield
|
|
787
|
-
raise MobyBase::VerificationError unless result
|
|
801
|
+
# raise exception if result of yield is less than expected value
|
|
802
|
+
raise MobyBase::VerificationError unless result < expected_value
|
|
788
803
|
|
|
789
804
|
# break loop if no exceptions thrown
|
|
790
805
|
break
|
|
@@ -794,7 +809,7 @@ module TDriverVerify
|
|
|
794
809
|
raise if $!.kind_of?( MobyBase::ContinuousVerificationError )
|
|
795
810
|
|
|
796
811
|
# refresh and retry unless timeout exceeded
|
|
797
|
-
raise $! if Time.
|
|
812
|
+
raise $! if Time.now > timeout_end_time
|
|
798
813
|
|
|
799
814
|
# retry interval
|
|
800
815
|
sleep TIMEOUT_CYCLE_SECONDS
|
|
@@ -822,7 +837,7 @@ module TDriverVerify
|
|
|
822
837
|
elsif $!.kind_of?( MobyBase::VerificationError )
|
|
823
838
|
|
|
824
839
|
error_message = "Verification #{ message }at #{ verify_caller } failed: #{ MobyUtil::KernelHelper.find_source( verify_caller ) }"
|
|
825
|
-
error_message << "The block did not return #{ expected_value
|
|
840
|
+
error_message << "The block did not return #{ expected_value }. It returned: #{ result.inspect }"
|
|
826
841
|
|
|
827
842
|
else
|
|
828
843
|
|
|
@@ -831,7 +846,7 @@ module TDriverVerify
|
|
|
831
846
|
|
|
832
847
|
end
|
|
833
848
|
|
|
834
|
-
$logger.behaviour "FAIL;Verification #{ message }failed: #{ $!.to_s }.\n #{ timeout.nil? ? '' : ' using timeout ' + timeout.to_s }.;#{ self.kind_of?( MobyBase::SUT ) ? self.id.to_s + ';sut' : ';' };{};
|
|
849
|
+
$logger.behaviour "FAIL;Verification #{ message }failed: #{ $!.to_s }.\n #{ timeout.nil? ? '' : ' using timeout ' + timeout.to_s }.;#{ self.kind_of?( MobyBase::SUT ) ? self.id.to_s + ';sut' : ';' };{};verify_less;"
|
|
835
850
|
|
|
836
851
|
# raise the exception
|
|
837
852
|
raise MobyBase::VerificationError, error_message
|
|
@@ -846,725 +861,365 @@ module TDriverVerify
|
|
|
846
861
|
|
|
847
862
|
end
|
|
848
863
|
|
|
849
|
-
$logger.behaviour "PASS;Verification #{ message }at #{ verify_caller } was successful#{ timeout.nil? ? '' : ' using timeout ' + timeout.to_s }.;#{ self.kind_of?( MobyBase::SUT ) ? self.id.to_s + ';sut' : ';' };{};
|
|
864
|
+
$logger.behaviour "PASS;Verification #{ message }at #{ verify_caller } was successful#{ timeout.nil? ? '' : ' using timeout ' + timeout.to_s }.;#{ self.kind_of?( MobyBase::SUT ) ? self.id.to_s + ';sut' : ';' };{};verify_less;"
|
|
850
865
|
|
|
851
866
|
nil
|
|
852
867
|
|
|
853
868
|
end
|
|
854
869
|
|
|
855
|
-
# Verifies that the given
|
|
856
|
-
#
|
|
857
|
-
# === params
|
|
858
|
-
# timeout:: Integer, defining the amount of seconds during which the verification must pass.
|
|
859
|
-
# signal_name:: String, name of the signal
|
|
860
|
-
# message:: (optional) A String that is displayed as additional information if the verification fails.
|
|
861
|
-
# block:: code to execute while listening signals
|
|
862
|
-
# === returns
|
|
863
|
-
# nil
|
|
864
|
-
# === raises
|
|
865
|
-
# ArgumentError:: message or signal_name was not a String or timeout a non negative Integer
|
|
866
|
-
# VerificationError:: The verification failed.
|
|
867
|
-
def verify_signal( timeout, signal_name, message = nil, &block )
|
|
868
|
-
|
|
869
|
-
logging_enabled = $logger.enabled
|
|
870
|
-
verify_caller = caller(1).first.to_s
|
|
871
|
-
|
|
872
|
-
begin
|
|
873
|
-
|
|
874
|
-
$logger.enabled = false
|
|
875
|
-
|
|
876
|
-
raise ArgumentError, "Argument timeout was not a non negative Integer." unless (timeout.kind_of?(Integer) && timeout >= 0)
|
|
877
|
-
raise ArgumentError, "Argument message was not a non empty String." unless (message.nil? || (message.kind_of?(String) && !message.empty?))
|
|
878
|
-
|
|
879
|
-
# wait for the signal
|
|
880
|
-
begin
|
|
881
|
-
|
|
882
|
-
self.wait_for_signal( timeout, signal_name, &block )
|
|
883
|
-
|
|
884
|
-
rescue
|
|
885
|
-
|
|
886
|
-
error_msg = "Verification #{message.nil? ? '' : '"' << message.to_s << '" '}at #{verify_caller} failed:"
|
|
887
|
-
error_msg << MobyUtil::KernelHelper.find_source(verify_caller)
|
|
888
|
-
error_msg << "The signal #{signal_name} was not emitted in #{timeout} seconds.\nNested exception:\n" << $!.inspect
|
|
889
|
-
|
|
890
|
-
raise MobyBase::VerificationError, error_msg
|
|
891
|
-
|
|
892
|
-
end
|
|
893
|
-
|
|
894
|
-
rescue
|
|
895
|
-
|
|
896
|
-
execute_on_error_verify_block unless @@on_error_verify_block.nil?
|
|
897
|
-
|
|
898
|
-
$logger.enabled = logging_enabled
|
|
899
|
-
|
|
900
|
-
$logger.behaviour "FAIL;Verification #{message.nil? ? '' : '\"' << message << '\" '}failed: #{$!.to_s} using timeout '#{timeout}.;#{self.kind_of?(MobyBase::SUT) ? self.id.to_s + ';sut' : ';'};{};verify_signal;#{signal_name}"
|
|
901
|
-
|
|
902
|
-
raise
|
|
903
|
-
|
|
904
|
-
ensure
|
|
905
|
-
|
|
906
|
-
$logger.enabled = logging_enabled
|
|
907
|
-
|
|
908
|
-
end
|
|
909
|
-
|
|
910
|
-
$logger.behaviour "PASS;Verification #{message.nil? ? '' : '\"' << message << '\" '}at #{verify_caller} was successful#{timeout.nil? ? '' : ' using timeout ' + timeout.to_s}.;#{self.kind_of?(MobyBase::SUT) ? self.id.to_s + ';sut' : ';'};{};verify_signal;#{signal_name}"
|
|
911
|
-
|
|
912
|
-
nil
|
|
913
|
-
|
|
914
|
-
end
|
|
915
|
-
|
|
916
|
-
=begin
|
|
917
|
-
|
|
918
|
-
# old implementation:
|
|
919
|
-
|
|
920
|
-
# Verifies that the block given to return value matches with expected regular expression pattern. Verification is synchronized with all connected suts.
|
|
870
|
+
# Verifies that result of the given block is greater than expected value. Verification is synchronized with all connected suts.
|
|
921
871
|
# If this method is called for a sut, synchronization is only done with that sut.
|
|
922
872
|
#
|
|
923
873
|
# === params
|
|
924
|
-
# expected::
|
|
874
|
+
# expected:: Expected result value of the block
|
|
925
875
|
# timeout:: (optional) Integer defining the amount of seconds during which the verification must pass.
|
|
926
876
|
# message:: (optional) A String that is displayed as additional information if the verification fails.
|
|
927
877
|
# === returns
|
|
928
878
|
# nil
|
|
929
879
|
# === raises
|
|
930
880
|
# ArgumentError:: message was not a String or timeout an integer, or no block was given.
|
|
931
|
-
# TypeError:: if block result not type of String.
|
|
932
881
|
# VerificationError:: The verification failed.
|
|
933
882
|
# RuntimeError:: An unexpected error was encountered during verification.
|
|
934
|
-
def
|
|
935
|
-
|
|
936
|
-
logging_enabled = $logger.enabled
|
|
937
|
-
|
|
938
|
-
verify_caller = caller( 1 ).first.to_s
|
|
939
|
-
|
|
883
|
+
def verify_greater( expected_value, timeout = nil, message = nil, &block )
|
|
884
|
+
|
|
940
885
|
begin
|
|
941
886
|
|
|
942
|
-
|
|
887
|
+
# determine name of caller method
|
|
888
|
+
verify_caller = caller( 1 ).first.to_s
|
|
943
889
|
|
|
944
|
-
#
|
|
945
|
-
|
|
946
|
-
message.check_type [ String, NilClass ], "wrong argument type $1 for message (expected $2)"
|
|
947
|
-
expected.check_type Regexp, "wrong argument type $1 for expected result (expected $2)"
|
|
890
|
+
# store orignal logging state
|
|
891
|
+
logging_enabled = $logger.enabled
|
|
948
892
|
|
|
893
|
+
# disable behaviour logging
|
|
949
894
|
$logger.enabled = false
|
|
950
895
|
|
|
951
|
-
#
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
MobyBase::TestObjectFactory.instance.timeout = 0
|
|
896
|
+
# ensure that timeout is either nil or type of integer
|
|
897
|
+
timeout.check_type [ Integer, NilClass ], 'wrong argument type $1 for timeout (expected $2)'
|
|
955
898
|
|
|
956
|
-
|
|
899
|
+
# ensure that message is either nil or type of string
|
|
900
|
+
message.check_type [ String, NilClass ], 'wrong argument type $1 for exception message (expected $2)'
|
|
957
901
|
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
counter = ref_counter
|
|
961
|
-
|
|
962
|
-
# catch errors thrown due to verification results
|
|
963
|
-
begin
|
|
964
|
-
|
|
965
|
-
# catch errors thrown in the provided block
|
|
966
|
-
begin
|
|
967
|
-
|
|
968
|
-
# execute block
|
|
969
|
-
result = yield
|
|
902
|
+
# verify that block was given
|
|
903
|
+
raise LocalJumpError, 'unable to verify due to no code block was given' unless block_given?
|
|
970
904
|
|
|
971
|
-
|
|
905
|
+
# convert timeout to integer, nil will be zero
|
|
906
|
+
timeout = get_timeout( timeout )
|
|
972
907
|
|
|
973
|
-
|
|
908
|
+
# verify that timeout is valid
|
|
909
|
+
timeout.not_negative 'timeout value cannot be negative'
|
|
974
910
|
|
|
975
|
-
|
|
911
|
+
# calculate the time when timeout exceeds
|
|
912
|
+
timeout_end_time = Time.now + timeout
|
|
976
913
|
|
|
977
|
-
|
|
914
|
+
# convert message to string, nil will be empty string
|
|
915
|
+
message = message.to_s
|
|
978
916
|
|
|
979
|
-
|
|
917
|
+
# add double quotation and trailing whitespace if not empty string
|
|
918
|
+
message = "#{ message.inspect } " if message.length > 0
|
|
980
919
|
|
|
981
|
-
|
|
920
|
+
# store original timeout value
|
|
921
|
+
original_timeout_value = MobyBase::TestObjectFactory.instance.timeout
|
|
982
922
|
|
|
983
|
-
|
|
923
|
+
# set the testobject timeout to 0 for the duration of the verify call
|
|
924
|
+
MobyBase::TestObjectFactory.instance.timeout = 0
|
|
984
925
|
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
# result verification
|
|
989
|
-
unless result =~ expected
|
|
926
|
+
# result container
|
|
927
|
+
result = nil
|
|
990
928
|
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
929
|
+
loop do
|
|
930
|
+
|
|
931
|
+
begin
|
|
932
|
+
|
|
933
|
+
counter = ref_counter
|
|
996
934
|
|
|
997
|
-
|
|
935
|
+
# execute code block
|
|
936
|
+
result = yield
|
|
998
937
|
|
|
999
|
-
|
|
938
|
+
# raise exception if result of yield is greater than expected value
|
|
939
|
+
raise MobyBase::VerificationError unless result > expected_value
|
|
1000
940
|
|
|
1001
941
|
# break loop if no exceptions thrown
|
|
1002
942
|
break
|
|
1003
943
|
|
|
1004
|
-
rescue
|
|
1005
|
-
|
|
1006
|
-
# refresh and retry unless timeout reached
|
|
944
|
+
rescue
|
|
1007
945
|
|
|
1008
|
-
raise
|
|
946
|
+
raise if $!.kind_of?( MobyBase::ContinuousVerificationError )
|
|
1009
947
|
|
|
948
|
+
# refresh and retry unless timeout exceeded
|
|
949
|
+
raise $! if Time.now > timeout_end_time
|
|
950
|
+
|
|
951
|
+
# retry interval
|
|
1010
952
|
sleep TIMEOUT_CYCLE_SECONDS
|
|
1011
953
|
|
|
954
|
+
# refresh suts
|
|
1012
955
|
refresh_suts if counter == ref_counter
|
|
1013
|
-
|
|
1014
|
-
rescue MobyBase::ContinuousVerificationError
|
|
1015
|
-
|
|
1016
|
-
raise
|
|
1017
|
-
|
|
1018
|
-
rescue TypeError
|
|
1019
956
|
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
957
|
+
end # begin
|
|
958
|
+
|
|
959
|
+
end # do loop
|
|
1023
960
|
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
# an unexpected error has occurred
|
|
1027
|
-
raise RuntimeError, "An unexpected error was encountered during verification:\n#{ $!.inspect }"
|
|
1028
|
-
|
|
1029
|
-
end # begin, catch any VerificationErrors
|
|
1030
|
-
|
|
1031
|
-
end # do
|
|
1032
|
-
|
|
1033
|
-
rescue Exception
|
|
1034
|
-
|
|
1035
|
-
execute_on_error_verify_block unless @@on_error_verify_block.nil?
|
|
1036
|
-
|
|
1037
|
-
raise if $!.kind_of?( MobyBase::ContinuousVerificationError )
|
|
961
|
+
rescue
|
|
1038
962
|
|
|
963
|
+
# restore logger state
|
|
1039
964
|
$logger.enabled = logging_enabled
|
|
1040
|
-
|
|
1041
|
-
$logger.behaviour "FAIL;Verification #{message.nil? ? '' : '\"' << message << '\" '}failed:#{ $!.to_s }.\n#{ timeout.nil? ? '' : ' using timeout ' + timeout.to_s }.;#{ self.kind_of?( MobyBase::SUT ) ? "#{ self.id.to_s };sut" : ';' };{};verify_regexp;#{ expected.inspect }"
|
|
1042
965
|
|
|
1043
|
-
|
|
966
|
+
# execute on verification error code block
|
|
967
|
+
execute_on_error_verify_block unless @@on_error_verify_block.nil?
|
|
1044
968
|
|
|
1045
|
-
|
|
969
|
+
# process the exception
|
|
970
|
+
if $!.kind_of?( MobyBase::ContinuousVerificationError )
|
|
971
|
+
|
|
972
|
+
raise
|
|
1046
973
|
|
|
1047
|
-
MobyBase::
|
|
1048
|
-
|
|
1049
|
-
$logger.enabled = logging_enabled
|
|
974
|
+
elsif $!.kind_of?( MobyBase::VerificationError )
|
|
1050
975
|
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
nil
|
|
1056
|
-
|
|
1057
|
-
end
|
|
1058
|
-
|
|
1059
|
-
# Verifies that the block given to this method evaluates without throwing any exceptions. Verification is synchronized with all connected suts.
|
|
1060
|
-
# If this method is called for a sut, synchronization is only done with that sut.
|
|
1061
|
-
#
|
|
1062
|
-
# === params
|
|
1063
|
-
# timeout:: (optional) Integer defining the amount of seconds during which the verification must pass.
|
|
1064
|
-
# message:: (optional) A String that is displayed as additional information if the verification fails.
|
|
1065
|
-
# === returns
|
|
1066
|
-
# nil
|
|
1067
|
-
# === raises
|
|
1068
|
-
# ArgumentError:: message was not a String or timeout an integer, or no block was given.
|
|
1069
|
-
# VerificationError:: The verification failed.
|
|
1070
|
-
def verify( timeout = nil, message = nil, &block )
|
|
1071
|
-
|
|
1072
|
-
logging_enabled = $logger.enabled
|
|
1073
|
-
|
|
1074
|
-
verify_caller = caller(1).first.to_s
|
|
1075
|
-
|
|
1076
|
-
begin
|
|
1077
|
-
|
|
1078
|
-
$logger.enabled = false
|
|
976
|
+
error_message = "Verification #{ message }at #{ verify_caller } failed: #{ MobyUtil::KernelHelper.find_source( verify_caller ) }"
|
|
977
|
+
error_message << "The block did not return #{ expected_value }. It returned: #{ result.inspect }"
|
|
978
|
+
|
|
979
|
+
else
|
|
1079
980
|
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
#Set the testobject timeout to 0 for the duration of the verify call
|
|
1085
|
-
original_sync_timeout = MobyBase::TestObjectFactory.instance.timeout
|
|
1086
|
-
MobyBase::TestObjectFactory.instance.timeout = 0
|
|
1087
|
-
|
|
1088
|
-
timeout_time = get_end_time(timeout)
|
|
1089
|
-
#TIMEOUT_CYCLE_SECONDS
|
|
1090
|
-
|
|
1091
|
-
loop do
|
|
1092
|
-
|
|
1093
|
-
counter = ref_counter
|
|
1094
|
-
|
|
1095
|
-
begin # catch errors thrown in the provided block
|
|
1096
|
-
|
|
1097
|
-
yield
|
|
1098
|
-
|
|
1099
|
-
# no error => verification ok
|
|
1100
|
-
break
|
|
1101
|
-
|
|
1102
|
-
rescue Exception => e
|
|
1103
|
-
|
|
1104
|
-
raise if e.kind_of? MobyBase::ContinuousVerificationError
|
|
1105
|
-
|
|
1106
|
-
source_contents = ""
|
|
1107
|
-
error_msg = ""
|
|
1108
|
-
|
|
1109
|
-
if Time.new > timeout_time
|
|
1110
|
-
|
|
1111
|
-
error_msg = "Verification #{message.nil? ? '' : '"' << message.to_s << '" '}at #{verify_caller} failed\n"
|
|
1112
|
-
|
|
1113
|
-
begin
|
|
1114
|
-
|
|
1115
|
-
source_contents = MobyUtil::KernelHelper.find_source(verify_caller)
|
|
1116
|
-
|
|
1117
|
-
rescue Exception
|
|
1118
|
-
# failed to load line from file, do nothing
|
|
1119
|
-
$logger.enabled = logging_enabled
|
|
1120
|
-
$logger.behaviour "WARNING;Failed to load source line: #{e.backtrace.inspect}.;#{self.kind_of?(MobyBase::SUT) ? self.id.to_s + ';sut' : ';'};{};verify;"
|
|
1121
|
-
end
|
|
1122
|
-
|
|
1123
|
-
if !source_contents.empty?
|
|
1124
|
-
error_msg << source_contents
|
|
1125
|
-
end
|
|
1126
|
-
|
|
1127
|
-
error_msg << "\nNested exception:" << e.message << "\n"
|
|
1128
|
-
|
|
1129
|
-
Kernel::raise MobyBase::VerificationError.new(error_msg)
|
|
1130
|
-
|
|
1131
|
-
end
|
|
1132
|
-
|
|
1133
|
-
end
|
|
1134
|
-
|
|
1135
|
-
sleep TIMEOUT_CYCLE_SECONDS
|
|
1136
|
-
|
|
1137
|
-
refresh_suts if counter == ref_counter
|
|
1138
|
-
|
|
1139
|
-
end # do
|
|
1140
|
-
|
|
1141
|
-
rescue Exception => e
|
|
1142
|
-
|
|
1143
|
-
execute_on_error_verify_block unless @@on_error_verify_block.nil?
|
|
1144
|
-
|
|
1145
|
-
raise if e.kind_of? MobyBase::ContinuousVerificationError
|
|
981
|
+
error_message = "Verification #{ message }at #{ verify_caller } failed as an exception was thrown when the verification block was executed"
|
|
982
|
+
error_message << "#{ MobyUtil::KernelHelper.find_source( verify_caller ) }\nDetails: \n#{ $!.inspect }"
|
|
983
|
+
|
|
984
|
+
end
|
|
1146
985
|
|
|
1147
|
-
$logger.
|
|
1148
|
-
$logger.behaviour "FAIL;Verification #{message.nil? ? '' : '\"' << message << '\" '}failed: #{e.to_s}#{timeout.nil? ? '' : ' using timeout ' + timeout.to_s}.;#{self.kind_of?(MobyBase::SUT) ? self.id.to_s + ';sut' : ';'};{};verify;"
|
|
1149
|
-
Kernel::raise e
|
|
986
|
+
$logger.behaviour "FAIL;Verification #{ message }failed: #{ $!.to_s }.\n #{ timeout.nil? ? '' : ' using timeout ' + timeout.to_s }.;#{ self.kind_of?( MobyBase::SUT ) ? self.id.to_s + ';sut' : ';' };{};verify_greater;"
|
|
1150
987
|
|
|
988
|
+
# raise the exception
|
|
989
|
+
raise MobyBase::VerificationError, error_message
|
|
990
|
+
|
|
1151
991
|
ensure
|
|
1152
992
|
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
end
|
|
1156
|
-
|
|
1157
|
-
$logger.enabled = logging_enabled
|
|
1158
|
-
$logger.behaviour "PASS;Verification #{message.nil? ? '' : '\"' << message << '\" '}at #{verify_caller} was successful#{timeout.nil? ? '' : ' using timeout ' + timeout.to_s}.;#{self.kind_of?(MobyBase::SUT) ? self.id.to_s + ';sut' : ';'};{};verify;"
|
|
1159
|
-
|
|
1160
|
-
return nil
|
|
1161
|
-
|
|
1162
|
-
end
|
|
1163
|
-
|
|
1164
|
-
# Verifies that the block given to this method throws an exception while being evaluated. Verification is synchronized with all connected suts.
|
|
1165
|
-
# If this method is called for a sut, synchronization is only done with that sut.
|
|
1166
|
-
#
|
|
1167
|
-
# === params
|
|
1168
|
-
# timeout:: (optional) Integer defining the amount of seconds during which the verification must pass.
|
|
1169
|
-
# message:: (optional) A String that is displayed as additional information if the verification fails.
|
|
1170
|
-
# === returns
|
|
1171
|
-
# nil
|
|
1172
|
-
# === raises
|
|
1173
|
-
# ArgumentError:: message was not a String or timeout an integer, or no block was given.
|
|
1174
|
-
# VerificationError:: The verification failed.
|
|
1175
|
-
def verify_not( timeout = nil, message = nil, &block )
|
|
1176
|
-
|
|
1177
|
-
logging_enabled = $logger.enabled
|
|
1178
|
-
verify_caller = caller(1).first.to_s
|
|
1179
|
-
begin
|
|
1180
|
-
|
|
1181
|
-
$logger.enabled = false
|
|
1182
|
-
Kernel::raise ArgumentError.new("No block was given.") unless block_given?
|
|
1183
|
-
Kernel::raise ArgumentError.new("Argument timeout was not an Integer.") unless timeout.nil? or timeout.kind_of?(Integer)
|
|
1184
|
-
Kernel::raise ArgumentError.new("Argument message was not a String.") unless message.nil? or message.kind_of?(String)
|
|
1185
|
-
|
|
1186
|
-
#Set the testobject timeout to 0 for the duration of the verify call
|
|
1187
|
-
original_sync_timeout = MobyBase::TestObjectFactory.instance.timeout
|
|
1188
|
-
MobyBase::TestObjectFactory.instance.timeout = 0
|
|
1189
|
-
|
|
1190
|
-
timeout_time = get_end_time(timeout)
|
|
1191
|
-
#TIMEOUT_CYCLE_SECONDS
|
|
1192
|
-
|
|
1193
|
-
loop do
|
|
1194
|
-
counter = ref_counter
|
|
1195
|
-
artificial_exception_raised = false
|
|
1196
|
-
begin # catch errors thrown in the provided block
|
|
1197
|
-
|
|
1198
|
-
yield
|
|
1199
|
-
artificial_exception_raised = true
|
|
1200
|
-
Kernel::raise "test"
|
|
1201
|
-
rescue Exception => e
|
|
1202
|
-
raise if e.kind_of? MobyBase::ContinuousVerificationError
|
|
1203
|
-
|
|
1204
|
-
source_contents = ""
|
|
1205
|
-
error_msg = ""
|
|
1206
|
-
|
|
1207
|
-
if (!artificial_exception_raised)
|
|
1208
|
-
# an error was encountered => verification ok
|
|
1209
|
-
break
|
|
1210
|
-
end
|
|
1211
|
-
|
|
1212
|
-
if Time.new > timeout_time
|
|
1213
|
-
|
|
1214
|
-
error_msg = "Verification #{message.nil? ? '' : '"' << message.to_s << '" '}at #{verify_caller} failed\n"
|
|
1215
|
-
|
|
1216
|
-
source_contents = MobyUtil::KernelHelper.find_source(verify_caller)
|
|
1217
|
-
|
|
1218
|
-
if !source_contents.empty?
|
|
1219
|
-
error_msg << source_contents
|
|
1220
|
-
end
|
|
1221
|
-
|
|
1222
|
-
Kernel::raise MobyBase::VerificationError.new(error_msg)
|
|
1223
|
-
|
|
1224
|
-
end
|
|
1225
|
-
|
|
1226
|
-
sleep TIMEOUT_CYCLE_SECONDS
|
|
1227
|
-
|
|
1228
|
-
refresh_suts if counter == ref_counter
|
|
1229
|
-
|
|
1230
|
-
end
|
|
1231
|
-
|
|
1232
|
-
end # do
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
rescue Exception => e
|
|
1236
|
-
|
|
1237
|
-
execute_on_error_verify_block unless @@on_error_verify_block.nil?
|
|
1238
|
-
|
|
1239
|
-
raise if e.kind_of? MobyBase::ContinuousVerificationError
|
|
993
|
+
# restore original test object factory timeout value
|
|
994
|
+
MobyBase::TestObjectFactory.instance.timeout = original_timeout_value
|
|
1240
995
|
|
|
996
|
+
# restore logger state
|
|
1241
997
|
$logger.enabled = logging_enabled
|
|
1242
|
-
|
|
1243
|
-
Kernel::raise e
|
|
1244
|
-
|
|
1245
|
-
ensure
|
|
1246
|
-
|
|
1247
|
-
MobyBase::TestObjectFactory.instance.timeout = original_sync_timeout unless original_sync_timeout.nil?
|
|
1248
|
-
|
|
998
|
+
|
|
1249
999
|
end
|
|
1250
1000
|
|
|
1251
|
-
$logger.
|
|
1252
|
-
$logger.behaviour "PASS;Verification #{message.nil? ? '' : '\"' << message << '\" '}at #{verify_caller} was successful#{timeout.nil? ? '' : ' using timeout ' + timeout.to_s}.;#{self.kind_of?(MobyBase::SUT) ? self.id.to_s + ';sut' : ';'};{};verify_not;"
|
|
1253
|
-
return nil
|
|
1001
|
+
$logger.behaviour "PASS;Verification #{ message }at #{ verify_caller } was successful#{ timeout.nil? ? '' : ' using timeout ' + timeout.to_s }.;#{ self.kind_of?( MobyBase::SUT ) ? self.id.to_s + ';sut' : ';' };{};verify_greater;"
|
|
1254
1002
|
|
|
1003
|
+
nil
|
|
1004
|
+
|
|
1255
1005
|
end
|
|
1256
1006
|
|
|
1257
|
-
# Verifies that the block given to
|
|
1007
|
+
# Verifies that the block given to return value matches with expected regular expression pattern. Verification is synchronized with all connected suts.
|
|
1258
1008
|
# If this method is called for a sut, synchronization is only done with that sut.
|
|
1259
1009
|
#
|
|
1260
1010
|
# === params
|
|
1261
|
-
# expected::
|
|
1011
|
+
# expected:: Regular expression
|
|
1262
1012
|
# timeout:: (optional) Integer defining the amount of seconds during which the verification must pass.
|
|
1263
1013
|
# message:: (optional) A String that is displayed as additional information if the verification fails.
|
|
1264
1014
|
# === returns
|
|
1265
1015
|
# nil
|
|
1266
1016
|
# === raises
|
|
1267
1017
|
# ArgumentError:: message was not a String or timeout an integer, or no block was given.
|
|
1018
|
+
# TypeError:: if block result not type of String.
|
|
1268
1019
|
# VerificationError:: The verification failed.
|
|
1269
1020
|
# RuntimeError:: An unexpected error was encountered during verification.
|
|
1270
|
-
def
|
|
1271
|
-
logging_enabled = $logger.enabled
|
|
1272
|
-
verify_caller = caller(1).first.to_s
|
|
1273
|
-
begin
|
|
1274
|
-
$logger.enabled = false
|
|
1275
|
-
Kernel::raise ArgumentError.new("No block was given.") unless block_given?
|
|
1276
|
-
Kernel::raise ArgumentError.new("Argument timeout was not an Integer.") unless timeout.nil? or timeout.kind_of?(Integer)
|
|
1277
|
-
Kernel::raise ArgumentError.new("Argument message was not a String.") unless message.nil? or message.kind_of?(String)
|
|
1278
|
-
|
|
1279
|
-
#Set the testobject timeout to 0 for the duration of the verify call
|
|
1280
|
-
original_sync_timeout = MobyBase::TestObjectFactory.instance.timeout
|
|
1281
|
-
MobyBase::TestObjectFactory.instance.timeout = 0
|
|
1282
|
-
|
|
1283
|
-
timeout_time = get_end_time(timeout)
|
|
1284
|
-
|
|
1285
|
-
#TIMEOUT_CYCLE_SECONDS
|
|
1286
|
-
|
|
1287
|
-
loop do
|
|
1288
|
-
counter = ref_counter
|
|
1289
|
-
begin # catch errors thrown due to verification results
|
|
1290
|
-
|
|
1291
|
-
begin # catch errors thrown in the provided block
|
|
1292
|
-
result = yield
|
|
1293
|
-
|
|
1294
|
-
rescue Exception => e
|
|
1295
|
-
raise if e.kind_of? MobyBase::ContinuousVerificationError
|
|
1296
|
-
error_msg = "Verification #{message.nil? ? '' : '"' << message.to_s << '" '}at #{verify_caller} failed as an exception was thrown when the verification block was executed."
|
|
1297
|
-
error_msg << MobyUtil::KernelHelper.find_source(verify_caller)
|
|
1298
|
-
error_msg << "\nDetails: "
|
|
1299
|
-
error_msg << "\n" << e.inspect
|
|
1300
|
-
raise MobyBase::VerificationError.new(error_msg)
|
|
1301
|
-
end
|
|
1302
|
-
if result != expected
|
|
1303
|
-
error_msg = "Verification #{message.nil? ? '' : '"' << message.to_s << '" '}at #{verify_caller} failed:"
|
|
1304
|
-
error_msg << MobyUtil::KernelHelper.find_source(verify_caller)
|
|
1305
|
-
error_msg << "\nThe block did not return #{expected.inspect}. It returned: " << result.inspect
|
|
1306
|
-
raise MobyBase::VerificationError.new(error_msg)
|
|
1307
|
-
end
|
|
1308
|
-
# break loop if no exceptions thrown
|
|
1309
|
-
break
|
|
1310
|
-
|
|
1311
|
-
rescue MobyBase::VerificationError => ve
|
|
1312
|
-
|
|
1313
|
-
# refresh and retry unless timeout reached
|
|
1314
|
-
|
|
1315
|
-
if Time.new > timeout_time
|
|
1316
|
-
Kernel::raise ve
|
|
1317
|
-
end
|
|
1318
|
-
|
|
1319
|
-
sleep TIMEOUT_CYCLE_SECONDS
|
|
1021
|
+
def verify_regexp( expected_value, timeout = nil, message = nil, &block )
|
|
1320
1022
|
|
|
1321
|
-
|
|
1322
|
-
rescue MobyBase::ContinuousVerificationError
|
|
1323
|
-
raise
|
|
1324
|
-
rescue Exception => e
|
|
1325
|
-
raise if e.kind_of? MobyBase::ContinuousVerificationError
|
|
1326
|
-
# an unexpected error has occurred
|
|
1327
|
-
Kernel::raise RuntimeError.new("An unexpected error was encountered during verification:\n" << e.inspect )
|
|
1023
|
+
begin
|
|
1328
1024
|
|
|
1329
|
-
|
|
1025
|
+
# store original timeout value
|
|
1026
|
+
original_timeout_value = MobyBase::TestObjectFactory.instance.timeout
|
|
1027
|
+
|
|
1028
|
+
# determine name of caller method
|
|
1029
|
+
verify_caller = caller( 1 ).first.to_s
|
|
1330
1030
|
|
|
1331
|
-
|
|
1031
|
+
# store orignal logging state
|
|
1032
|
+
logging_enabled = $logger.enabled
|
|
1332
1033
|
|
|
1333
|
-
|
|
1034
|
+
# disable behaviour logging
|
|
1035
|
+
$logger.enabled = false
|
|
1334
1036
|
|
|
1335
|
-
|
|
1037
|
+
# verify that arguments was given in correct format
|
|
1038
|
+
expected_value.check_type Regexp, "wrong argument type $1 for expected result (expected $2)"
|
|
1336
1039
|
|
|
1337
|
-
|
|
1040
|
+
# ensure that timeout is either nil or type of integer
|
|
1041
|
+
timeout.check_type [ Integer, NilClass ], 'wrong argument type $1 for timeout (expected $2)'
|
|
1338
1042
|
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
end
|
|
1043
|
+
# ensure that message is either nil or type of string
|
|
1044
|
+
message.check_type [ String, NilClass ], 'wrong argument type $1 for exception message (expected $2)'
|
|
1045
|
+
|
|
1046
|
+
# verify that block was given
|
|
1047
|
+
raise LocalJumpError, 'unable to verify due to no code block was given' unless block_given?
|
|
1345
1048
|
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
return nil
|
|
1049
|
+
# convert timeout to integer, nil will be zero
|
|
1050
|
+
timeout = get_timeout( timeout )
|
|
1349
1051
|
|
|
1350
|
-
|
|
1052
|
+
# verify that timeout is valid
|
|
1053
|
+
timeout.not_negative 'timeout value cannot be negative'
|
|
1351
1054
|
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
#
|
|
1355
|
-
# === params
|
|
1356
|
-
# timeout:: (optional) Integer defining the amount of seconds during which the verification must pass.
|
|
1357
|
-
# message:: (optional) A String that is displayed as additional information if the verification fails.
|
|
1358
|
-
# === returns
|
|
1359
|
-
# nil
|
|
1360
|
-
# === raises
|
|
1361
|
-
# ArgumentError:: message was not a String or timeout an integer, or no block was given.
|
|
1362
|
-
# VerificationError:: The verification failed.
|
|
1363
|
-
# RuntimeError:: An unexpected error was encountered during verification.
|
|
1364
|
-
def verify_true( timeout = nil, message = nil, &block )
|
|
1055
|
+
# calculate the time when timeout exceeds
|
|
1056
|
+
timeout_end_time = Time.now + timeout
|
|
1365
1057
|
|
|
1366
|
-
|
|
1367
|
-
|
|
1058
|
+
# convert message to string, nil will be empty string
|
|
1059
|
+
message = message.to_s
|
|
1368
1060
|
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
Kernel::raise ArgumentError.new("No block was given.") unless block_given?
|
|
1372
|
-
Kernel::raise ArgumentError.new("Argument timeout was not an Integer.") unless timeout.nil? or timeout.kind_of?(Integer)
|
|
1373
|
-
Kernel::raise ArgumentError.new("Argument message was not a String.") unless message.nil? or message.kind_of?(String)
|
|
1061
|
+
# add double quotation and trailing whitespace if not empty string
|
|
1062
|
+
message = "#{ message.inspect } " if message.length > 0
|
|
1374
1063
|
|
|
1375
|
-
#
|
|
1376
|
-
original_sync_timeout = MobyBase::TestObjectFactory.instance.timeout
|
|
1064
|
+
# set the testobject timeout to 0 for the duration of the verify call
|
|
1377
1065
|
MobyBase::TestObjectFactory.instance.timeout = 0
|
|
1378
1066
|
|
|
1379
|
-
|
|
1380
|
-
|
|
1067
|
+
# result container
|
|
1068
|
+
result = nil
|
|
1381
1069
|
|
|
1382
1070
|
loop do
|
|
1071
|
+
|
|
1072
|
+
begin
|
|
1073
|
+
|
|
1074
|
+
counter = ref_counter
|
|
1383
1075
|
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
begin # catch errors thrown due to verification results
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
begin # catch errors thrown in the provided block
|
|
1390
|
-
|
|
1391
|
-
result = yield
|
|
1392
|
-
|
|
1393
|
-
rescue Exception => e
|
|
1394
|
-
|
|
1395
|
-
#@@on_error_verify_block.call unless @@on_error_verify_block.nil?
|
|
1396
|
-
|
|
1397
|
-
raise if e.kind_of? MobyBase::ContinuousVerificationError
|
|
1398
|
-
|
|
1399
|
-
error_msg = "Verification #{message.nil? ? '' : '"' << message.to_s << '" '}at #{verify_caller} failed as an exception was thrown when the verification block was executed."
|
|
1400
|
-
error_msg << MobyUtil::KernelHelper.find_source(verify_caller)
|
|
1401
|
-
error_msg << "\nDetails: "
|
|
1402
|
-
error_msg << "\n" << e.inspect
|
|
1403
|
-
|
|
1404
|
-
raise MobyBase::VerificationError.new( error_msg )
|
|
1405
|
-
|
|
1406
|
-
end
|
|
1407
|
-
|
|
1408
|
-
unless result == true
|
|
1409
|
-
|
|
1410
|
-
error_msg = "Verification #{message.nil? ? '' : '"' << message.to_s << '" '}at #{verify_caller} failed."
|
|
1411
|
-
error_msg << MobyUtil::KernelHelper.find_source(verify_caller)
|
|
1412
|
-
|
|
1413
|
-
error_msg << "\nThe block did not return true. It returned: " << result.inspect
|
|
1414
|
-
|
|
1415
|
-
raise MobyBase::VerificationError.new( error_msg )
|
|
1076
|
+
# execute code block
|
|
1077
|
+
result = yield
|
|
1416
1078
|
|
|
1417
|
-
|
|
1079
|
+
# raise exception if result of yield does not match with expected value regexp
|
|
1080
|
+
raise MobyBase::VerificationError unless result =~ expected_value
|
|
1418
1081
|
|
|
1419
1082
|
# break loop if no exceptions thrown
|
|
1420
1083
|
break
|
|
1421
1084
|
|
|
1422
|
-
rescue
|
|
1423
|
-
|
|
1424
|
-
# refresh and retry unless timeout reached
|
|
1425
|
-
|
|
1426
|
-
if ( Time.new > timeout_time )
|
|
1427
|
-
|
|
1428
|
-
execute_on_error_verify_block unless @@on_error_verify_block.nil?
|
|
1429
|
-
|
|
1430
|
-
Kernel::raise ve
|
|
1085
|
+
rescue
|
|
1431
1086
|
|
|
1432
|
-
|
|
1087
|
+
raise if $!.kind_of?( MobyBase::ContinuousVerificationError )
|
|
1433
1088
|
|
|
1089
|
+
# refresh and retry unless timeout exceeded
|
|
1090
|
+
raise $! if Time.now > timeout_end_time
|
|
1091
|
+
|
|
1092
|
+
# retry interval
|
|
1434
1093
|
sleep TIMEOUT_CYCLE_SECONDS
|
|
1435
1094
|
|
|
1095
|
+
# refresh suts
|
|
1436
1096
|
refresh_suts if counter == ref_counter
|
|
1097
|
+
|
|
1098
|
+
end # begin
|
|
1099
|
+
|
|
1100
|
+
end # do loop
|
|
1101
|
+
|
|
1102
|
+
rescue
|
|
1437
1103
|
|
|
1438
|
-
|
|
1104
|
+
# restore logger state
|
|
1105
|
+
$logger.enabled = logging_enabled
|
|
1439
1106
|
|
|
1440
|
-
|
|
1107
|
+
# execute on verification error code block
|
|
1108
|
+
execute_on_error_verify_block unless @@on_error_verify_block.nil?
|
|
1441
1109
|
|
|
1442
|
-
|
|
1110
|
+
# process the exception
|
|
1111
|
+
if $!.kind_of?( MobyBase::ContinuousVerificationError )
|
|
1112
|
+
|
|
1113
|
+
raise
|
|
1114
|
+
|
|
1115
|
+
elsif $!.kind_of?( MobyBase::VerificationError )
|
|
1116
|
+
|
|
1117
|
+
error_message = "Verification #{ message }at #{ verify_caller } failed: #{ MobyUtil::KernelHelper.find_source( verify_caller ) }"
|
|
1118
|
+
error_message << "The return value of block did not match with #{ expected_value.inspect } pattern. Block returned: #{ result.inspect }"
|
|
1119
|
+
|
|
1120
|
+
else
|
|
1121
|
+
|
|
1122
|
+
error_message = "Verification #{ message }at #{ verify_caller } failed as an exception was thrown when the verification block was executed"
|
|
1123
|
+
error_message << "#{ MobyUtil::KernelHelper.find_source( verify_caller ) }\nDetails: \n#{ $!.inspect }"
|
|
1124
|
+
|
|
1125
|
+
end
|
|
1443
1126
|
|
|
1444
|
-
|
|
1445
|
-
Kernel::raise RuntimeError.new("An unexpected error was encountered during verification:\n" << e.inspect )
|
|
1127
|
+
$logger.behaviour "FAIL;Verification #{ message }failed: #{ $!.to_s }.\n #{ timeout.nil? ? '' : ' using timeout ' + timeout.to_s }.;#{ self.kind_of?( MobyBase::SUT ) ? self.id.to_s + ';sut' : ';' };{};verify_regexp;"
|
|
1446
1128
|
|
|
1447
|
-
|
|
1129
|
+
# raise the exception
|
|
1130
|
+
raise MobyBase::VerificationError, error_message
|
|
1131
|
+
|
|
1132
|
+
ensure
|
|
1448
1133
|
|
|
1449
|
-
|
|
1134
|
+
# restore original test object factory timeout value
|
|
1135
|
+
MobyBase::TestObjectFactory.instance.timeout = original_timeout_value
|
|
1450
1136
|
|
|
1451
|
-
|
|
1452
|
-
raise if e.kind_of? MobyBase::ContinuousVerificationError
|
|
1137
|
+
# restore logger state
|
|
1453
1138
|
$logger.enabled = logging_enabled
|
|
1454
|
-
|
|
1455
|
-
Kernel::raise e
|
|
1456
|
-
ensure
|
|
1457
|
-
MobyBase::TestObjectFactory.instance.timeout = original_sync_timeout unless original_sync_timeout.nil?
|
|
1139
|
+
|
|
1458
1140
|
end
|
|
1459
1141
|
|
|
1460
|
-
$logger.
|
|
1461
|
-
$logger.behaviour "PASS;Verification #{message.nil? ? '' : '\"' << message << '\" '}at #{verify_caller} was successful#{timeout.nil? ? '' : ' using timeout ' + timeout.to_s}.;#{self.kind_of?(MobyBase::SUT) ? self.id.to_s + ';sut' : ';'};{};verify_true;"
|
|
1462
|
-
return nil
|
|
1142
|
+
$logger.behaviour "PASS;Verification #{ message }at #{ verify_caller } was successful#{ timeout.nil? ? '' : ' using timeout ' + timeout.to_s }.;#{ self.kind_of?( MobyBase::SUT ) ? self.id.to_s + ';sut' : ';' };{};verify_regexp;"
|
|
1463
1143
|
|
|
1144
|
+
nil
|
|
1145
|
+
|
|
1464
1146
|
end
|
|
1465
1147
|
|
|
1466
|
-
# Verifies that the
|
|
1467
|
-
# If this method is called for a sut, synchronization is only done with that sut.
|
|
1148
|
+
# Verifies that the given signal is emitted.
|
|
1468
1149
|
#
|
|
1469
1150
|
# === params
|
|
1470
|
-
# timeout::
|
|
1151
|
+
# timeout:: Integer, defining the amount of seconds during which the verification must pass.
|
|
1152
|
+
# signal_name:: String, name of the signal
|
|
1471
1153
|
# message:: (optional) A String that is displayed as additional information if the verification fails.
|
|
1154
|
+
# block:: code to execute while listening signals
|
|
1472
1155
|
# === returns
|
|
1473
1156
|
# nil
|
|
1474
1157
|
# === raises
|
|
1475
|
-
# ArgumentError:: message was not a String or timeout
|
|
1158
|
+
# ArgumentError:: message or signal_name was not a String or timeout a non negative Integer
|
|
1476
1159
|
# VerificationError:: The verification failed.
|
|
1477
|
-
|
|
1478
|
-
def verify_false( timeout = nil, message = nil, &block )
|
|
1479
|
-
|
|
1480
|
-
logging_enabled = $logger.enabled
|
|
1481
|
-
|
|
1482
|
-
verify_caller = caller(1).first.to_s
|
|
1160
|
+
def verify_signal( timeout, signal_name, message = nil, &block )
|
|
1483
1161
|
|
|
1484
1162
|
begin
|
|
1485
1163
|
|
|
1486
|
-
$logger.enabled
|
|
1487
|
-
|
|
1488
|
-
Kernel::raise ArgumentError.new("No block was given.") unless block_given?
|
|
1164
|
+
logging_enabled = $logger.enabled
|
|
1489
1165
|
|
|
1490
|
-
|
|
1491
|
-
Kernel::raise ArgumentError.new("Argument message was not a String.") unless message.nil? or message.kind_of?(String)
|
|
1166
|
+
$logger.enabled = false
|
|
1492
1167
|
|
|
1493
|
-
#
|
|
1494
|
-
|
|
1495
|
-
MobyBase::TestObjectFactory.instance.timeout = 0
|
|
1168
|
+
# ensure that timeout is either nil or type of integer
|
|
1169
|
+
timeout.check_type Integer, 'wrong argument type $1 for timeout (expected $2)'
|
|
1496
1170
|
|
|
1497
|
-
|
|
1498
|
-
|
|
1171
|
+
# ensure that message is either nil or type of string
|
|
1172
|
+
message.check_type [ String, NilClass ], 'wrong argument type $1 for exception message (expected $2)'
|
|
1499
1173
|
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
begin # catch errors thrown due to verification results
|
|
1503
|
-
|
|
1504
|
-
begin # catch errors thrown in the provided block
|
|
1505
|
-
result = yield
|
|
1506
|
-
rescue Exception => e
|
|
1507
|
-
raise if e.kind_of? MobyBase::ContinuousVerificationError
|
|
1508
|
-
error_msg = "Verification #{message.nil? ? '' : '"' << message.to_s << '" '}at #{verify_caller} failed as an exception was thrown when the verification block was executed."
|
|
1509
|
-
error_msg << MobyUtil::KernelHelper.find_source(verify_caller)
|
|
1510
|
-
error_msg << "\nDetails: "
|
|
1511
|
-
error_msg << "\n" << e.inspect
|
|
1512
|
-
raise MobyBase::VerificationError.new(error_msg)
|
|
1513
|
-
end
|
|
1174
|
+
# verify that block was given
|
|
1175
|
+
raise LocalJumpError, 'unable to verify due to no code block was given' unless block_given?
|
|
1514
1176
|
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
error_msg << "The block did not return false. It returned: " << result.inspect
|
|
1518
|
-
raise MobyBase::VerificationError.new(error_msg) unless result == false
|
|
1177
|
+
# verify that timeout is valid
|
|
1178
|
+
timeout.not_negative 'timeout value cannot be negative'
|
|
1519
1179
|
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
rescue MobyBase::VerificationError => ve
|
|
1180
|
+
# convert message to string, nil will be empty string
|
|
1181
|
+
message = message.to_s
|
|
1524
1182
|
|
|
1525
|
-
|
|
1183
|
+
# add double quotation and trailing whitespace if not empty string
|
|
1184
|
+
message = "#{ message.inspect } " if message.length > 0
|
|
1526
1185
|
|
|
1527
|
-
|
|
1528
|
-
Kernel::raise ve
|
|
1529
|
-
end
|
|
1186
|
+
verify_caller = caller(1).first.to_s
|
|
1530
1187
|
|
|
1531
|
-
|
|
1188
|
+
# wait for the signal
|
|
1189
|
+
begin
|
|
1532
1190
|
|
|
1533
|
-
|
|
1191
|
+
self.wait_for_signal( timeout, signal_name, &block )
|
|
1534
1192
|
|
|
1193
|
+
rescue
|
|
1535
1194
|
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
# an unexpected error has occurred
|
|
1539
|
-
$logger.enabled = logging_enabled
|
|
1540
|
-
Kernel::raise RuntimeError.new("An unexpected error was encountered during verification:\n" << e.inspect )
|
|
1195
|
+
error_msg = "Verification #{ message }at #{ verify_caller } failed: #{ MobyUtil::KernelHelper.find_source(verify_caller) }"
|
|
1196
|
+
error_msg << "The signal #{ signal_name } was not emitted in #{ timeout } seconds.\nNested exception:\n#{ $!.inspect }"
|
|
1541
1197
|
|
|
1542
|
-
|
|
1198
|
+
raise MobyBase::VerificationError, error_msg
|
|
1543
1199
|
|
|
1544
|
-
end
|
|
1200
|
+
end
|
|
1545
1201
|
|
|
1546
|
-
rescue
|
|
1202
|
+
rescue
|
|
1547
1203
|
|
|
1548
1204
|
execute_on_error_verify_block unless @@on_error_verify_block.nil?
|
|
1549
1205
|
|
|
1550
|
-
raise if e.kind_of? MobyBase::ContinuousVerificationError
|
|
1551
|
-
|
|
1552
1206
|
$logger.enabled = logging_enabled
|
|
1553
|
-
$logger.behaviour "FAIL;Verification #{message.nil? ? '' : '\"' << message << '\" '}failed:#{e.to_s}.\n #{timeout.nil? ? '' : ' using timeout ' + timeout.to_s}.;#{self.kind_of?(MobyBase::SUT) ? self.id.to_s + ';sut' : ';'};{};verify_false;"
|
|
1554
1207
|
|
|
1555
|
-
|
|
1208
|
+
$logger.behaviour "FAIL;Verification #{ message }failed: #{ $!.to_s } using timeout '#{ timeout }.;#{ self.kind_of?(MobyBase::SUT) ? self.id.to_s + ';sut' : ';' };{};verify_signal;#{ signal_name }"
|
|
1209
|
+
|
|
1210
|
+
raise
|
|
1556
1211
|
|
|
1557
1212
|
ensure
|
|
1558
|
-
|
|
1213
|
+
|
|
1214
|
+
$logger.enabled = logging_enabled
|
|
1215
|
+
|
|
1559
1216
|
end
|
|
1560
1217
|
|
|
1561
|
-
$logger.
|
|
1562
|
-
|
|
1563
|
-
|
|
1218
|
+
$logger.behaviour "PASS;Verification #{ message }at #{ verify_caller } was successful#{ timeout.nil? ? '' : ' using timeout ' + timeout.to_s }.;#{ self.kind_of?( MobyBase::SUT ) ? self.id.to_s + ';sut' : ';' };{};verify_signal;#{ signal_name }"
|
|
1219
|
+
|
|
1220
|
+
nil
|
|
1564
1221
|
|
|
1565
1222
|
end
|
|
1566
|
-
|
|
1567
|
-
=end
|
|
1568
1223
|
|
|
1569
1224
|
private
|
|
1570
1225
|
|
|
@@ -1572,11 +1227,11 @@ module TDriverVerify
|
|
|
1572
1227
|
|
|
1573
1228
|
if self.kind_of?( MobyBase::SUT )
|
|
1574
1229
|
|
|
1575
|
-
Time.
|
|
1230
|
+
Time.now + ( timeout.nil? ? $parameters[ self.sut ][ :synchronization_timeout, '10' ].to_i : timeout.to_i )
|
|
1576
1231
|
|
|
1577
1232
|
else
|
|
1578
1233
|
|
|
1579
|
-
Time.
|
|
1234
|
+
Time.now + ( timeout.nil? ? $parameters[ :synchronization_timeout, '10' ].to_i : timeout.to_i )
|
|
1580
1235
|
|
|
1581
1236
|
end
|
|
1582
1237
|
|
|
@@ -1584,15 +1239,19 @@ module TDriverVerify
|
|
|
1584
1239
|
|
|
1585
1240
|
def get_timeout( timeout )
|
|
1586
1241
|
|
|
1587
|
-
if
|
|
1242
|
+
#if timeout.nil?
|
|
1243
|
+
|
|
1244
|
+
if self.kind_of?( MobyBase::SUT )
|
|
1588
1245
|
|
|
1589
|
-
|
|
1246
|
+
timeout = $parameters[ self.sut ][ :synchronization_timeout, '10' ].to_i if timeout.nil?
|
|
1590
1247
|
|
|
1591
|
-
|
|
1248
|
+
else
|
|
1592
1249
|
|
|
1593
|
-
|
|
1250
|
+
timeout = $parameters[ :synchronization_timeout, '10' ].to_i if timeout.nil?
|
|
1594
1251
|
|
|
1595
|
-
|
|
1252
|
+
end
|
|
1253
|
+
|
|
1254
|
+
#end
|
|
1596
1255
|
|
|
1597
1256
|
timeout.to_i
|
|
1598
1257
|
|