64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
|
# File 'lib/trace-component.rb', line 64
def run(command, start, lines, statusIndicator = false, ref = "" )
audit = Audit.new false
@log.info(" [#{ref}] HANDLING: " + command)
File.foreach(command) { |l|
if ( l.start_with?('## ') )
@log.info "#{lines + 1} Label: " + l
elsif ( l.start_with?('#') )
elsif ( /\S/ !~ l )
elsif ( l.chomp.end_with?(".sh") && !l.chomp.end_with?(".atomic.sh") && !l.include?("cp ") && !l.include?("chmod") )
@log.info(" [#{ref}] RECURSE: " + l)
workingDir = "#{Pathname.new(Canzea::config[:catalog_location]).realpath}"
Dir.chdir(workingDir){
newCommand = "#{Pathname.new(l.chomp).realpath}"
lines = run newCommand, start, lines
}
else
if ( (lines + 1) < start )
@log.info(" [#{ref}] Skipping : #{lines + 1} #{l}")
lines += 1
next
end
audit.start( "#{lines + 1 }", l.chomp)
@log.info(" [#{ref}] #{(lines + 1).to_s.rjust(2, "0")} : " + l)
if @test == false
t1 = Time.now
begin
workingDir = "#{Pathname.new(Canzea::config[:catalog_location]).realpath}"
puts "-- Executing [#{workingDir}] #{l}"
Dir.chdir(workingDir){
Open3.popen3(l) {|stdin, stdout, stderr, wait_thr|
pid = wait_thr.pid
log_w = StringIO.new
stillOpen = [stdout, stderr]
while !stillOpen.empty?
fhs = select(stillOpen, nil, nil, nil)
handleIO(stillOpen, fhs[0], stdout, log_w)
handleIO(stillOpen, fhs[0], stderr, log_w)
end
exit_status = wait_thr.value
log_w.close_write
output = log_w.string
begin
output.split(/\n/).each do | line |
puts "-- #{line}"
end
rescue => exception
puts "-- WARNING : Unable to parse output, exception: #{exception.to_s}"
end
puts "-- Exit Status = #{exit_status}"
@log.info("STDOUT #{output}")
@log.info("Exit Status = #{exit_status}")
t2 = Time.now
msecs = time_diff_milli t1, t2
audit.complete("#{lines + 1}", l.chomp, exit_status.exitstatus, msecs, output)
if (statusIndicator)
audit.status("#{lines + 1}", l.chomp, exit_status.exitstatus, msecs, output)
end
if exit_status.exitstatus != 0
abort()
end
}
}
rescue => exception
msecs = time_diff_milli t1, Time.now
audit.complete("#{lines + 1}", l.chomp, "-1", msecs, exception.to_s)
raise
end
else
puts "-- TEST [#{lines + 1}] FOUND: " + l
end
end
lines += 1
}
return lines
end
|