Class: TDriverReportCrashFileCapture
Overview
Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. Contact: Nokia Corporation ([email protected])
This file is part of Testability Driver.
If you have questions regarding the use of this file, please contact Nokia at [email protected] .
This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1 as published by the Free Software Foundation and appearing in the file LICENSE.LGPL included in the packaging of this file.
Instance Method Summary
collapse
#capture_files, #check_if_files_exist, #clean_files_from_sut, #delete_file, #download_file, #download_files, #list_sut_files, #read_file_monitor_settings
Constructor Details
Returns a new instance of TDriverReportCrashFileCapture.
22
23
24
25
26
27
28
29
30
|
# File 'lib/tdriver/report/report_crash_file_capture.rb', line 22
def initialize
@crash_file_locations=Array.new
@crash_file_suts=Array.new
@crash_file_names=Array.new
@crash_file_count=0
@monitor_crash_files='false'
read_crash_monitor_settings()
read_file_monitor_settings()
end
|
Instance Method Details
#capture_crash_files ⇒ Object
162
163
164
165
166
167
168
169
170
171
172
173
174
|
# File 'lib/tdriver/report/report_crash_file_capture.rb', line 162
def capture_crash_files()
if @monitor_crash_files == 'true'
begin
dump_folder=@test_case_folder+'/crash_files'
if File::directory?(dump_folder)==false
FileUtils.mkdir_p dump_folder
end
download_crash_files(dump_folder)
rescue Exception => e
@test_case_execution_log=@test_case_execution_log.to_s + '<br />' + "Unable to capture crash files: " + e.message
end
end
end
|
#check_if_crash_files_exist ⇒ Object
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
|
# File 'lib/tdriver/report/report_crash_file_capture.rb', line 124
def check_if_crash_files_exist()
sut_crash_files=Array.new
if @monitor_crash_files == 'true'
TDriver::SUTFactory.connected_suts.each do |sut_id, sut_attributes|
if sut_attributes[:is_connected]
@crash_file_suts.each do |monitored_sut|
if monitored_sut == sut_id.to_s
sut_crash_files << list_sut_crash_files(sut_attributes[:sut])
end
end
end
end
@crash_file_count
else
@crash_file_count
end
end
|
#clean_crash_files_from_sut ⇒ Object
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/tdriver/report/report_crash_file_capture.rb', line 46
def clean_crash_files_from_sut()
if @monitor_crash_files == 'true'
TDriver::SUTFactory.connected_suts.each do |sut_id, sut_attributes|
if sut_attributes[:is_connected]
@crash_file_suts.each do |monitored_sut|
if monitored_sut == sut_id.to_s
sut_crash_files=Array.new
sut_crash_files=list_sut_crash_files(sut_attributes[:sut])
sut_crash_files.each do |crash_file|
delete_crash_file(sut_attributes[:sut],crash_file[0])
end
end
end
end
end
end
end
|
#confirm_crash_notes ⇒ Object
64
65
66
67
68
69
70
71
72
73
74
|
# File 'lib/tdriver/report/report_crash_file_capture.rb', line 64
def confirm_crash_notes
TDriver::SUTFactory.connected_suts.each do |sut_id, sut_attributes|
if sut_attributes[:is_connected]
@crash_file_suts.each do |monitored_sut|
if monitored_sut == sut_id.to_s
sut_attributes[:sut].clear_crash_notes(5)
end
end
end
end
end
|
#delete_crash_file(current_sut, file_name) ⇒ Object
106
107
108
109
110
111
112
|
# File 'lib/tdriver/report/report_crash_file_capture.rb', line 106
def delete_crash_file(current_sut,file_name)
begin
current_sut.ftp( :Command => :Delete, :Remote_filename => file_name )
rescue => ex
end
end
|
#download_crash_file(current_sut, file_name, download_folder, download_file) ⇒ Object
98
99
100
101
102
103
104
|
# File 'lib/tdriver/report/report_crash_file_capture.rb', line 98
def download_crash_file(current_sut,file_name,download_folder,download_file)
begin
current_sut.ftp( :Command => :Download, :Local_filename => download_folder+download_file, :Remote_filename => file_name )
rescue => ex
end
end
|
#download_crash_files(download_folder) ⇒ Object
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
|
# File 'lib/tdriver/report/report_crash_file_capture.rb', line 142
def download_crash_files(download_folder)
if @monitor_crash_files == 'true'
TDriver::SUTFactory.connected_suts.each do |sut_id, sut_attributes|
if sut_attributes[:is_connected]
@crash_file_suts.each do |monitored_sut|
if monitored_sut == sut_id.to_s
sut_crash_files=Array.new
sut_crash_files=list_sut_crash_files(sut_attributes[:sut])
sut_crash_files.each do |crash_file|
download_crash_file(sut_attributes[:sut],crash_file[0],download_folder.gsub("/",'\\')+'\\',crash_file[1])
delete_crash_file(sut_attributes[:sut],crash_file[0])
end
sut_attributes[:sut].clear_crash_notes(5)
end
end
end
end
end
end
|
#file_is_crash_file(file_name) ⇒ Object
114
115
116
117
118
119
120
121
122
|
# File 'lib/tdriver/report/report_crash_file_capture.rb', line 114
def file_is_crash_file(file_name)
is_crash_file=false
@crash_file_names.each do |crash_file_identity|
if file_name.to_s.include? crash_file_identity.to_s
is_crash_file=true
end
end
is_crash_file
end
|
#list_sut_crash_files(current_sut) ⇒ Object
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
# File 'lib/tdriver/report/report_crash_file_capture.rb', line 76
def list_sut_crash_files(current_sut)
crash_file_arr=Array.new
@crash_file_count=0
@crash_file_locations.each do |location|
begin
current_location_files = current_sut.ftp( :Command => :List_files, :Remote_dir => location )
current_location_files.each do |sut_file|
if file_is_crash_file(sut_file)
crash_file_arr << [location.gsub("/",'\\')+'\\'+sut_file.to_s,sut_file.to_s]
@crash_file_count+=1
end
end
rescue => ex
end
end
crash_file_arr
end
|
#read_crash_monitor_settings ⇒ Object
39
40
41
42
43
44
|
# File 'lib/tdriver/report/report_crash_file_capture.rb', line 39
def read_crash_monitor_settings()
@crash_file_locations=return_settings_value_array( $parameters[ :report_crash_file_locations, nil ])
@crash_file_suts=return_settings_value_array( $parameters[ :report_crash_file_monitored_sut_ids, nil ])
@crash_file_names=return_settings_value_array( $parameters[ :report_crash_file_names, nil ])
@monitor_crash_files = $parameters[ :report_crash_file_monitor, 'false' ]
end
|
#return_settings_value_array(setting) ⇒ Object
32
33
34
35
36
37
|
# File 'lib/tdriver/report/report_crash_file_capture.rb', line 32
def return_settings_value_array(setting)
setting_value=setting
setting_arr=Array.new
setting_arr=setting_value.split(',')
setting_arr
end
|