import source from lvm2 2.02.79
[external/device-mapper.git] / report-generators / unit_test.rb
1 # Copyright (C) 2010 Red Hat, Inc. All rights reserved.
2 #
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.
6 #
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
10
11 # Reads the schedule files given on the command line.  Runs them and
12 # generates the reports.
13
14 require 'schedule_file'
15 require 'pathname'
16 require 'reports'
17 require 'erb'
18 require 'report_templates'
19
20 include ReportTemplates
21
22 schedules = ARGV.map do |f|
23   p = Pathname.new(f)
24   Schedule.read(p.dirname, p)
25 end
26
27 total_passed = 0
28 total_failed = 0
29
30 # We need to make sure the lvm shared libs are in the LD_LIBRARY_PATH
31 ENV['LD_LIBRARY_PATH'] = `pwd`.strip + "/libdm:" + (ENV['LD_LIBRARY_PATH'] || '')
32
33 schedules.each do |s|
34   s.run
35
36   s.schedules.each do |t|
37     if t.status.success?
38       total_passed += 1
39     else
40       total_failed += 1
41     end
42   end
43 end
44
45 def mangle(txt)
46   txt.gsub(/\s+/, '_')
47 end
48
49 generate_report(:unit_test, binding)
50
51 # now we generate a detail report for each schedule
52 schedules.each do |s|
53   s.schedules.each do |t|
54     generate_report(:unit_detail, binding, Pathname.new("reports/detail_#{mangle(t.desc)}.html"))
55   end
56 end