1 # Copyright (C) 2010 Red Hat, Inc. All rights reserved.
3 # This copyrighted material is made available to anyone wishing to use,
4 # modify, copy, or redistribute it subject to the terms and conditions
5 # of the GNU General Public License v.2.
7 # You should have received a copy of the GNU General Public License
8 # along with this program; if not, write to the Free Software Foundation,
9 # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
11 # Reads the schedule files given on the command line. Runs them and
12 # generates the reports.
14 # FIXME: a lot of duplication with unit_test.rb
16 require 'schedule_file'
20 require 'report_templates'
22 include ReportTemplates
24 schedules = ARGV.map do |f|
26 Schedule.read(p.dirname, p)
32 # We need to make sure the lvm shared libs are in the LD_LIBRARY_PATH
33 ENV['LD_LIBRARY_PATH'] = `pwd`.strip + "/libdm:" + (ENV['LD_LIBRARY_PATH'] || '')
35 ENV['TEST_TOOL'] = "valgrind --leak-check=full --show-reachable=yes"
40 s.schedules.each do |t|
53 MemcheckStats = Struct.new(:definitely_lost, :indirectly_lost, :possibly_lost, :reachable)
55 def format(bytes, blocks)
56 "#{bytes} bytes, #{blocks} blocks"
59 # Examines the output for details of leaks
63 t.output.split("\n").each do |l|
65 when /==\d+== definitely lost: ([0-9,]+) bytes in ([0-9,]+) blocks/
67 when /==\d+== indirectly lost: ([0-9,]+) bytes in ([0-9,]+) blocks/
69 when /==\d+== possibly lost: ([0-9,]+) bytes in ([0-9,]+) blocks/
71 when /==\d+== still reachable: ([0-9,]+) bytes in ([0-9,]+) blocks/
76 MemcheckStats.new(d, i, p, r)
79 generate_report(:memcheck, binding)
81 # now we generate a detail report for each schedule
83 s.schedules.each do |t|
84 generate_report(:unit_detail, binding, Pathname.new("reports/memcheck_#{mangle(t.desc)}.html"))