LVM2 ./Makefile.in ./configure.in ./make.tmpl. ...
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: thornber at sourceware.org 2010-07-20 14:38:45
Modified files:
. : Makefile.in configure.in make.tmpl.in
Added files:
report-generators: memcheck.rb title_page.rb unit_test.rb report-generators/lib: log.rb report_templates.rb reports.rb
schedule_file.rb string-store.rb
report-generators/templates: boiler_plate.rhtml index.rhtml
memcheck.rhtml unit_detail.rhtml unit_test.rhtml
report-generators/test: example.schedule tc_log.rb
tc_schedule_file.rb tc_string_store.rb ts.rb
report-generators/test/strings: test1.txt test2 report-generators/test/strings/more_strings: test3.txt
reports : stylesheet.css
Log message:
Report generators for unit tests and memory checks. Configure with --enable-testing.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/Makefile.in.diff?cvsroot=lvm2&r1=1.55&r2=1.56
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/configure.in.diff?cvsroot=lvm2&r1=1.146&r2=1.147
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/make.tmpl.in.diff?cvsroot=lvm2&r1=1.105&r2=1.106
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/report-generators/memcheck.rb.diff?cvsroot=lvm2&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/report-generators/title_page.rb.diff?cvsroot=lvm2&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/report-generators/unit_test.rb.diff?cvsroot=lvm2&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/report-generators/lib/log.rb.diff?cvsroot=lvm2&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/report-generators/lib/report_templates.rb.diff?cvsroot=lvm2&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/report-generators/lib/reports.rb.diff?cvsroot=lvm2&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/report-generators/lib/schedule_file.rb.diff?cvsroot=lvm2&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/report-generators/lib/string-store.rb.diff?cvsroot=lvm2&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/report-generators/templates/boiler_plate.rhtml.diff?cvsroot=lvm2&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/report-generators/templates/index.rhtml.diff?cvsroot=lvm2&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/report-generators/templates/memcheck.rhtml.diff?cvsroot=lvm2&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/report-generators/templates/unit_detail.rhtml.diff?cvsroot=lvm2&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/report-generators/templates/unit_test.rhtml.diff?cvsroot=lvm2&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/report-generators/test/example.schedule.diff?cvsroot=lvm2&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/report-generators/test/tc_log.rb.diff?cvsroot=lvm2&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/report-generators/test/tc_schedule_file.rb.diff?cvsroot=lvm2&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/report-generators/test/tc_string_store.rb.diff?cvsroot=lvm2&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/report-generators/test/ts.rb.diff?cvsroot=lvm2&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/report-generators/test/strings/test1.txt.diff?cvsroot=lvm2&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/report-generators/test/strings/test2.diff?cvsroot=lvm2&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/report-generators/test/strings/more_strings/test3.txt.diff?cvsroot=lvm2&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/reports/stylesheet.css.diff?cvsroot=lvm2&r1=NONE&r2=1.1
Makefile.in +20 -0
@@ -127,3 +127,23 @@ endif endif + +ifeq ("$(TESTING)", "yes") +# testing and report generation +RUBY=ruby1.9 -Ireport-generators/lib -Ireport-generators/test + +.PHONEY: unit-test ruby-test test-programs + +test-programs: + +unit-test: test-programs + $(RUBY) report-generators/unit_test.rb $(shell find . -name TESTS) + $(RUBY) report-generators/title_page.rb + +memcheck: test-programs + $(RUBY) report-generators/memcheck.rb $(shell find . -name TESTS) + $(RUBY) report-generators/title_page.rb + +ruby-test: + $(RUBY) report-generators/test/ts.rb +endif
configure.in +17 -0
@@ -701,6 +701,22 @@ fi ################################################################################ +dnl -- Enable testing +AC_MSG_CHECKING(whether to enable unit testing) +AC_ARG_ENABLE(testing, + AC_HELP_STRING(--enable-testing, [enable testing targets in the makefile]), + TESTING=$enableval, TESTING=no) +AC_MSG_RESULT($TESTING) + +if test "$TESTING" = yes; then + AC_PATH_PROG(RUBY19, ruby1.9) + AC_PATH_PROG(VALGRIND, valgrind) + if test -z "$RUBY19" -o -z "$VALGRIND"; then + AC_MSG_ERROR([ruby1.9 and valgrind are required for testing]) + fi +fi + +################################################################################ dnl -- Disable devmapper AC_MSG_CHECKING(whether to use device-mapper) AC_ARG_ENABLE(devmapper,
@@ -1260,6 +1276,7 @@ AC_SUBST(SNAPSHOTS) AC_SUBST(STATICDIR) AC_SUBST(STATIC_LINK) +AC_SUBST(TESTING) AC_SUBST(UDEV_LIBS) AC_SUBST(UDEV_PC) AC_SUBST(UDEV_RULES)
make.tmpl.in +1 -0
@@ -45,6 +45,7 @@ READLINE_LIBS = @READLINE_LIBS@ SELINUX_LIBS = @SELINUX_LIBS@ UDEV_LIBS = @UDEV_LIBS@ +TESTING = @TESTING@ # Setup directory variables prefix = @prefix@
/cvs/lvm2/LVM2/report-generators/memcheck.rb,v --> standard output revision 1.1
- renamed from report-generators/memcheck.rb +76 -0
76 lines not on this page · raw message
/cvs/lvm2/LVM2/report-generators/title_page.rb,v --> standard output revision 1.1
- renamed from report-generators/title_page.rb +32 -0
@@ -0,0 +1,32 @@ +# This generates the index for the reports, including generation +# times. + +require 'log' +require 'string-store' +require 'reports' +require 'erb' +require 'report_templates' + +include Reports + +reports = ReportRegister.new + +def safe_mtime(r) + r.path.file? ? r.path.mtime.to_s : "not generated" +end + +template_store = TemplateStringStore.new + +# FIXME: use generate_report() method +erb = ERB.new(template_store.lookup("index.rhtml")) +body = erb.result(binding) +title = "Generation times" + +erb = ERB.new(template_store.lookup("boiler_plate.rhtml")) +txt = erb.result(binding) + +Pathname.new("reports/index.html").open("w") do |f| + f.puts txt +end + +
/cvs/lvm2/LVM2/report-generators/unit_test.rb,v --> standard output revision 1.1
- renamed from report-generators/unit_test.rb +46 -0
46 lines not on this page · raw message
/cvs/lvm2/LVM2/report-generators/lib/log.rb,v --> standard output revision 1.1
- renamed from report-generators/lib/log.rb +30 -0
@@ -0,0 +1,30 @@ +# Merely wraps the logger library with a bit of standard policy. +require 'logger' + +module Log + $log = Logger.new(STDERR) + + def init(io_) + $log = Logger.new(io_) + end +end + +def fatal(*args) + $log.fatal(*args) +end + +def error(*args) + $log.error(*args) +end + +def info(*args) + $log.info(*args) +end + +def warning(*args) + $log.warn(*args) +end + +def debug(*args) + $log.debug(*args) +end
/cvs/lvm2/LVM2/report-generators/lib/report_templates.rb,v --> standard output revision 1.1
- renamed from report-generators/lib/report_templates.rb +28 -0
@@ -0,0 +1,28 @@ +# Policy for the location of report templates +require 'string-store' + +class TemplateStringStore < StringStore + def initialize() + super(['report-generators/templates']) + end +end + +module ReportTemplates + def generate_report(report, bs, dest_path = nil) + include Reports + reports = ReportRegister.new + template_store = TemplateStringStore.new + report = reports.get_report(report) + erb = ERB.new(template_store.lookup(report.template)) + body = erb.result(bs) + title = report.short_desc + + erb = ERB.new(template_store.lookup("boiler_plate.rhtml")) + txt = erb.result(binding) + + dest_path = dest_path.nil? ? report.path : dest_path + dest_path.open("w") do |out| + out.puts txt + end + end +end
/cvs/lvm2/LVM2/report-generators/lib/reports.rb,v --> standard output revision 1.1
- renamed from report-generators/lib/reports.rb +48 -0
48 lines not on this page · raw message
/cvs/lvm2/LVM2/report-generators/lib/schedule_file.rb,v --> standard output revision 1.1
- renamed from report-generators/lib/schedule_file.rb +46 -0
46 lines not on this page · raw message
/cvs/lvm2/LVM2/report-generators/lib/string-store.rb,v --> standard output revision 1.1
- renamed from report-generators/lib/string-store.rb +32 -0
@@ -0,0 +1,32 @@ +# Provides a simple way of accessing the contents of files by a symbol +# name. Useful for erb templates. + +require 'pathname' + +class StringStore + attr_accessor :path + + def initialize(p) + @paths = p.nil? ? Array.new : p # FIXME: do we need to copy p ? + end + + def lookup(sym) + files = expansions(sym) + + @paths.each do |p| + files.each do |f| + pn = Pathname.new("#{p}/#{f}") + if pn.file? + return pn.read + end + end + end + + raise RuntimeError, "unknown string entry: #{sym}" + end + + private + def expansions(sym) + ["#{sym}", "#{sym}.txt"] + end +end
/cvs/lvm2/LVM2/report-generators/templates/boiler_plate.rhtml,v --> standard output revision 1.1
- renamed from report-generators/templates/boiler_plate.rhtml +25 -0
@@ -0,0 +1,25 @@ +<html> +<head> +<META http-equiv="Content-Type" content="text/html; charset=US-ASCII"> +<title><%= title %></title> +<link title="Style" type="text/css" rel="stylesheet" href="stylesheet.css"> +</head> + +<body> +<div id="banner"> +<h2><%= title %></h2> +</div> +<div id="main"> + <div id="controls"> + <table> + <tr><td><a href="index.html">Generation times</a></td></tr> + <tr><td><a href="unit.html">Unit tests</a></td></tr> + <tr><td><a href="memcheck.html">Memory tests</a></td></tr> + </table> + </div> + + <div id="body"> + <%= body %> + </div> +</div> +</body>
/cvs/lvm2/LVM2/report-generators/templates/index.rhtml,v --> standard output revision 1.1
- renamed from report-generators/templates/index.rhtml +17 -0
@@ -0,0 +1,17 @@ +<table width="95%" cellspacing="2" cellpadding="5" border="0" class="stripes"> +<tr><th>Report</th><th>Generation time</th></tr> +<% [:unit_test, :memcheck].each do |sym| %> +<% r = reports.get_report(sym) %> +<tr> + <td> + <% if r.path.file? %> + <a href="<%= r.path.to_s.gsub(/^reports\//, '') %>"><%= r.short_desc %></a> + <% else %> + <%= r.short_desc %> + <% end %> + </td> + <td><%= safe_mtime(r) %></td> +</tr> +<% end %> +</table> +
/cvs/lvm2/LVM2/report-generators/templates/memcheck.rhtml,v --> standard output revision 1.1
- renamed from report-generators/templates/memcheck.rhtml +30 -0
@@ -0,0 +1,30 @@ +<table width="95%" cellspacing="2" cellpadding="5" border="0" class="stripes"> + <tr><th>Tests passed</th><th>Tests failed</th></tr> + <tr><td class="pass"><%= total_passed %></td><td <%= total_failed == 0 ? "" : "class=\"fail\""%>><%= total_failed %></td></tr> +</table> + +<% schedules.each do |s| %> +<h3><%= s.dir.sub('./unit-tests/', '') %></h3> +<table width="95%" cellspacing="2" cellpadding="5" border="0" class="stripes"> +<tr><th>Test</th><th>Result</th><th>Definitely lost</th><th>indirectly lost</th><th>possibly lost</th><th>still reachable</th><tr> + +<% s.schedules.each do |t| %> +<tr> + <td> + <a href="memcheck_<%= mangle(t.desc) %>.html"><%= t.desc %></a> + </td> + <% if t.status.success? %> + <td class="pass">pass</td> + <% else %> + <td class="fail">fail</td> + <% end %> + + <% stats = extract_stats(t) %> + <td><%= stats.definitely_lost %></td> + <td><%= stats.indirectly_lost %></td> + <td><%= stats.possibly_lost %></td> + <td><%= stats.reachable %></td> +</tr> +<% end %> +</table> +<% end %>
/cvs/lvm2/LVM2/report-generators/templates/unit_detail.rhtml,v --> standard output revision 1.1
- renamed from report-generators/templates/unit_detail.rhtml +37 -0
@@ -0,0 +1,37 @@ +<table width="95%" cellspacing="2" cellpadding="5" border="0" class="stripes"> +<tr><th>Test</th><th>Result</th></tr> +<tr> + <td> + <%= t.desc %> + </td> + <% if t.status.success? %> + <td class="pass">pass</td> + <% else %> + <td class="fail">fail</td> + <% end %> +</tr> +</table> + +<table width="95%" cellspacing="2" cellpadding="5" border="0" class="stripes"> +<tr><th>Command line</th></tr> +<tr> + <td> + <pre> +<%= t.command_line %> + </pre> + </td> +</tr> +</table> + + +<table width="95%" cellspacing="2" cellpadding="5" border="0" class="stripes"> +<tr><th>Output</th></tr> +<tr> + <td> + <pre> +<%= t.output %> + </pre> + </td> +</tr> +</table> +
/cvs/lvm2/LVM2/report-generators/templates/unit_test.rhtml,v --> standard output revision 1.1
- renamed from report-generators/templates/unit_test.rhtml +23 -0
@@ -0,0 +1,23 @@ +<table width="95%" cellspacing="2" cellpadding="5" border="0" class="stripes"> + <tr><th>Tests passed</th><th>Tests failed</th></tr> + <tr><td class="pass"><%= total_passed %></td><td <%= total_failed == 0 ? "" : "class=\"fail\""%>><%= total_failed %></td></tr> +</table> + +<% schedules.each do |s| %> +<h3><%= s.dir.sub('./unit-tests/', '') %></h3> +<table width="95%" cellspacing="2" cellpadding="5" border="0" class="stripes"> +<tr><th>Test</th><th>Result</th></tr> +<% s.schedules.each do |t| %> +<tr> + <td> + <a href="detail_<%= mangle(t.desc) %>.html"><%= t.desc %></a> + </td> + <% if t.status.success? %> + <td class="pass">pass</td> + <% else %> + <td class="fail">fail</td> + <% end %> +</tr> +<% end %> +</table> +<% end %>
/cvs/lvm2/LVM2/report-generators/test/example.schedule,v --> standard output revision 1.1
- renamed from report-generators/test/example.schedule +4 -0
@@ -0,0 +1,4 @@ +# This is a comment +description number 1:$TEST_TOOL ls +foo bar: $TEST_TOOL du -hs . + this comment is prefixed with whitespace: $TEST_TOOL date
/cvs/lvm2/LVM2/report-generators/test/tc_log.rb,v --> standard output revision 1.1
- renamed from report-generators/test/tc_log.rb +26 -0
@@ -0,0 +1,26 @@ +require 'test/unit' +require 'stringio' +require 'log' + +class TestLog < Test::Unit::TestCase + include Log + + private + def remove_timestamps(l) + l.gsub(/\[[^\]]*\]/, '') + end + + public + def test_log + StringIO.open do |out| + init(out) + + info("msg1") + warning("msg2") + debug("msg3") + + assert_equal("I, INFO -- : msg1\nW, WARN -- : msg2\nD, DEBUG -- : msg3\n", + remove_timestamps(out.string)) + end + end +end
/cvs/lvm2/LVM2/report-generators/test/tc_schedule_file.rb,v --> standard output revision 1.1
- renamed from report-generators/test/tc_schedule_file.rb +28 -0
@@ -0,0 +1,28 @@ +require 'test/unit' +require 'pathname' +require 'schedule_file' + +class TestScheduleFile < Test::Unit::TestCase + def test_reading + p = Pathname.new("report-generators/test/example.schedule") + p.open do |f| + s = Schedule.read(p.dirname, f) + + assert_equal(3, s.schedules.size) + assert_equal(s.schedules[2].desc, "this comment is prefixed with whitespace") + assert_equal(s.schedules[0].command_line, "$TEST_TOOL ls") + end + end + + def test_running + p = Pathname.new("report-generators/test/example.schedule") + p.open do |f| + s = Schedule.read(p.dirname, f) + s.run + + s.schedules.each do |t| + assert(t.status.success?) + end + end + end +end
/cvs/lvm2/LVM2/report-generators/test/tc_string_store.rb,v --> standard output revision 1.1
- renamed from report-generators/test/tc_string_store.rb +19 -0
@@ -0,0 +1,19 @@ +require 'string-store' +require 'test/unit' + +class TestStringStore < Test::Unit::TestCase + def setup + @ss = StringStore.new(['report-generators/test/strings', + 'report-generators/test/strings/more_strings']) + end + + def test_lookup + assert_equal("Hello, world!\n", @ss.lookup(:test1)) + assert_equal("one\ntwo\nthree", @ss.lookup(:test2)) + assert_equal("lorem\n", @ss.lookup(:test3)) + + assert_raises(RuntimeError) do + @ss.lookup(:unlikely_name) + end + end +end
/cvs/lvm2/LVM2/report-generators/test/ts.rb,v --> standard output revision 1.1
- renamed from report-generators/test/ts.rb +3 -0
@@ -0,0 +1,3 @@ +require 'tc_log' +require 'tc_string_store' +require 'tc_schedule_file'
/cvs/lvm2/LVM2/report-generators/test/strings/test1.txt,v --> standard output revision 1.1
- renamed from report-generators/test/strings/test1.txt +1 -0
@@ -0,0 +1 @@ +Hello, world!
/cvs/lvm2/LVM2/report-generators/test/strings/test2,v --> standard output revision 1.1
- renamed from report-generators/test/strings/test2 +3 -0
@@ -0,0 +1,3 @@ +one +two +three
/cvs/lvm2/LVM2/report-generators/test/strings/more_strings/test3.txt,v --> standard output revision 1.1
- renamed from report-generators/test/strings/more_strings/test3.txt +1 -0
@@ -0,0 +1 @@ +lorem
/cvs/lvm2/LVM2/reports/stylesheet.css,v --> standard output revision 1.1
- renamed from reports/stylesheet.css +264 -0
264 lines not on this page · raw message