master - [unit-test] Push the new unit test framwork.
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=ea34dad66fe4a46a2f7ec51c4358144f6cb3ed67 Commit: ea34dad66fe4a46a2f7ec51c4358144f6cb3ed67 Parent: c7fdacbc5001f3bdfaa441fedb7da120af5d8af9 Author: Joe Thornber <[email protected]> AuthorDate: Thu Apr 26 11:59:39 2018 +0100 Committer: Joe Thornber <[email protected]> CommitterDate: Thu Apr 26 11:59:39 2018 +0100
[unit-test] Push the new unit test framwork.
See doc/unit-test.txt for details.
Some bcache tests failing. Probably due to dct changing semantics, will fix in follow up patch.
--- .gitignore | 2 + Makefile.in | 7 +- configure | 175 +---- configure.in | 7 +- doc/unit-tests.txt | 257 +++++ report-generators/lib/log.rb | 40 - report-generators/lib/report_templates.rb | 38 - report-generators/lib/reports.rb | 58 -- report-generators/lib/schedule_file.rb | 56 -- report-generators/lib/string-store.rb | 42 - report-generators/memcheck.rb | 86 -- report-generators/templates/boiler_plate.rhtml | 25 - report-generators/templates/index.rhtml | 17 - report-generators/templates/memcheck.rhtml | 30 - report-generators/templates/unit_detail.rhtml | 37 - report-generators/templates/unit_test.rhtml | 23 - report-generators/test/example.schedule | 4 - .../test/strings/more_strings/test3.txt | 1 - report-generators/test/strings/test1.txt | 1 - report-generators/test/strings/test2 | 3 - report-generators/test/tc_log.rb | 36 - report-generators/test/tc_schedule_file.rb | 38 - report-generators/test/tc_string_store.rb | 29 - report-generators/test/ts.rb | 13 - report-generators/title_page.rb | 42 - report-generators/unit_test.rb | 56 -- reports/stylesheet.css | 77 -- test/unit/Makefile.in | 39 - test/unit/bcache_t.c | 636 ------------ test/unit/bitset_t.c | 129 --- test/unit/config_t.c | 152 --- test/unit/dmlist_t.c | 49 - test/unit/dmstatus_t.c | 72 -- test/unit/matcher_data.h | 1013 -------------------- test/unit/matcher_t.c | 70 -- test/unit/percent_t.c | 101 -- test/unit/run.c | 39 - test/unit/string_t.c | 78 -- test/unit/units.h | 35 - unit-test/Makefile.in | 40 + unit-test/bcache_t.c | 783 +++++++++++++++ unit-test/bitset_t.c | 148 +++ unit-test/config_t.c | 167 ++++ unit-test/dmlist_t.c | 49 + unit-test/dmstatus_t.c | 84 ++ unit-test/framework.c | 66 ++ unit-test/framework.h | 49 + unit-test/matcher_data.h | 1013 ++++++++++++++++++++ unit-test/matcher_t.c | 89 ++ unit-test/percent_t.c | 102 ++ unit-test/run.c | 309 ++++++ unit-test/string_t.c | 91 ++ unit-test/units.h | 46 + 53 files changed, 3301 insertions(+), 3348 deletions(-)
.gitignore +2 -0
@@ -79,3 +79,5 @@ test/lib/vgrename test/lib/vgs test/lib/vgscan test/lib/vgsplit + +unit-test/unit-test
Makefile.in +3 -4
@@ -43,8 +43,7 @@ endif ifeq ($(MAKECMDGOALS),distclean) SUBDIRS = conf include man test scripts \ libdaemon lib tools daemons libdm \ - udev po liblvm python \ - unit-tests/datastruct unit-tests/mm unit-tests/regex + udev po liblvm python tools.distclean: test.distclean endif DISTCLEAN_DIRS += lcov_reports*
@@ -97,7 +96,7 @@ endif DISTCLEAN_TARGETS += cscope.out CLEAN_DIRS += autom4te.cache -check check_system check_cluster check_local check_lvmetad check_lvmpolld check_lvmlockd_test check_lvmlockd_dlm check_lvmlockd_sanlock unit: all +check check_system check_cluster check_local check_lvmetad check_lvmpolld check_lvmlockd_test check_lvmlockd_dlm check_lvmlockd_sanlock unit-test: all $(MAKE) -C test $(@) conf.generate man.generate: tools
@@ -212,7 +211,7 @@ endif endif ifeq ("$(TESTING)", "yes") -include test/unit/Makefile +include unit-test/Makefile endif ifneq ($(shell which ctags),)
configure +1 -172
241 lines not on this page · raw message
at.socket scripts/lvm2_lvmlockd_systemd_red_hat.service scripts/lvm2_lvmlocking_systemd_red_hat.service scripts/lvm2_monitoring_init_red_hat scripts/lvm2_monitoring_systemd_red_hat.service scripts/lvm2_pvscan_systemd_red_hat at .service scripts/lvm2_tmpfiles_red_hat.conf scripts/lvmdump.sh scripts/Makefile test/Makefile test/api/Makefile unit-test/Makefile tools/Makefile udev/Makefile"
cat >confcache <<\_ACEOF
# This file is a shell script that caches the results of configure
@@ -16634,7 +16463,7 @@ do
"scripts/Makefile") CONFIG_FILES="$CONFIG_FILES scripts/Makefile" ;;
"test/Makefile") CONFIG_FILES="$CONFIG_FILES test/Makefile" ;;
"test/api/Makefile") CONFIG_FILES="$CONFIG_FILES test/api/Makefile" ;;
- "test/unit/Makefile") CONFIG_FILES="$CONFIG_FILES test/unit/Makefile" ;;
+ "unit-test/Makefile") CONFIG_FILES="$CONFIG_FILES unit-test/Makefile" ;;
"tools/Makefile") CONFIG_FILES="$CONFIG_FILES tools/Makefile" ;;
"udev/Makefile") CONFIG_FILES="$CONFIG_FILES udev/Makefile" ;;configure.in +1 -6
@@ -1076,11 +1076,6 @@ AC_ARG_ENABLE(testing, TESTING=$enableval, TESTING=no) AC_MSG_RESULT($TESTING) -if test "$TESTING" = yes; then - pkg_config_init - PKG_CHECK_MODULES(CUNIT, cunit >= 2.0) -fi - ################################################################################ dnl -- Set LVM2 testsuite data TESTSUITE_DATA='${datarootdir}/lvm2-testsuite'
@@ -2251,7 +2246,7 @@ scripts/lvmdump.sh scripts/Makefile test/Makefile test/api/Makefile -test/unit/Makefile +unit-test/Makefile tools/Makefile udev/Makefile ])
doc/unit-tests.txt new file +257 -0
257 lines not on this page · raw message
report-generators/lib/log.rb deleted +0 -40
@@ -1,40 +0,0 @@ -# Copyright (C) 2010 Red Hat, Inc. All rights reserved. -# -# This copyrighted material is made available to anyone wishing to use, -# modify, copy, or redistribute it subject to the terms and conditions -# of the GNU General Public License v.2. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software Foundation, -# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -# 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
report-generators/lib/report_templates.rb deleted +0 -38
@@ -1,38 +0,0 @@ -# Copyright (C) 2010 Red Hat, Inc. All rights reserved. -# -# This copyrighted material is made available to anyone wishing to use, -# modify, copy, or redistribute it subject to the terms and conditions -# of the GNU General Public License v.2. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software Foundation, -# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -# 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
report-generators/lib/reports.rb deleted +0 -58
58 lines not on this page · raw message
report-generators/lib/schedule_file.rb deleted +0 -56
56 lines not on this page · raw message
report-generators/lib/string-store.rb deleted +0 -42
42 lines not on this page · raw message
report-generators/memcheck.rb deleted +0 -86
86 lines not on this page · raw message
report-generators/templates/boiler_plate.rhtml deleted +0 -25
@@ -1,25 +0,0 @@ -<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>
report-generators/templates/index.rhtml deleted +0 -17
@@ -1,17 +0,0 @@ -<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> -
report-generators/templates/memcheck.rhtml deleted +0 -30
@@ -1,30 +0,0 @@ -<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 %>
report-generators/templates/unit_detail.rhtml deleted +0 -37
@@ -1,37 +0,0 @@ -<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> -
report-generators/templates/unit_test.rhtml deleted +0 -23
@@ -1,23 +0,0 @@ -<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 %>
report-generators/test/example.schedule deleted +0 -4
@@ -1,4 +0,0 @@ -# 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
report-generators/test/strings/more_strings/test3.txt deleted +0 -1
@@ -1 +0,0 @@ -lorem
report-generators/test/strings/test1.txt deleted +0 -1
@@ -1 +0,0 @@ -Hello, world!
report-generators/test/strings/test2 deleted +0 -3
@@ -1,3 +0,0 @@ -one -two -three
report-generators/test/tc_log.rb deleted +0 -36
@@ -1,36 +0,0 @@ -# Copyright (C) 2010 Red Hat, Inc. All rights reserved. -# -# This copyrighted material is made available to anyone wishing to use, -# modify, copy, or redistribute it subject to the terms and conditions -# of the GNU General Public License v.2. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software Foundation, -# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -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
report-generators/test/tc_schedule_file.rb deleted +0 -38
@@ -1,38 +0,0 @@ -# Copyright (C) 2010 Red Hat, Inc. All rights reserved. -# -# This copyrighted material is made available to anyone wishing to use, -# modify, copy, or redistribute it subject to the terms and conditions -# of the GNU General Public License v.2. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software Foundation, -# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -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
report-generators/test/tc_string_store.rb deleted +0 -29
@@ -1,29 +0,0 @@ -# Copyright (C) 2010 Red Hat, Inc. All rights reserved. -# -# This copyrighted material is made available to anyone wishing to use, -# modify, copy, or redistribute it subject to the terms and conditions -# of the GNU General Public License v.2. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software Foundation, -# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -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
report-generators/test/ts.rb deleted +0 -13
@@ -1,13 +0,0 @@ -# Copyright (C) 2010 Red Hat, Inc. All rights reserved. -# -# This copyrighted material is made available to anyone wishing to use, -# modify, copy, or redistribute it subject to the terms and conditions -# of the GNU General Public License v.2. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software Foundation, -# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -require 'tc_log' -require 'tc_string_store' -require 'tc_schedule_file'
report-generators/title_page.rb deleted +0 -42
42 lines not on this page · raw message
report-generators/unit_test.rb deleted +0 -56
56 lines not on this page · raw message
reports/stylesheet.css deleted +0 -77
77 lines not on this page · raw message
test/unit/Makefile.in deleted +0 -39
@@ -1,39 +0,0 @@ -# Copyright (C) 2011-2018 Red Hat, Inc. All rights reserved. -# -# This file is part of LVM2. -# -# This copyrighted material is made available to anyone wishing to use, -# modify, copy, or redistribute it subject to the terms and conditions -# of the GNU General Public License v.2. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software Foundation, -# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -UNIT_SOURCE=\ - test/unit/bcache_t.c \ - - -# test/unit/run.c - -# test/unit/bitset_t.c\ -# test/unit/config_t.c\ -# test/unit/dmlist_t.c\ -# test/unit/dmstatus_t.c\ -# test/unit/matcher_t.c\ -# test/unit/percent_t.c\ -# test/unit/string_t.c\ - -UNIT_OBJECTS=$(UNIT_SOURCE:%.c=%.o) - -UNIT_LDLIBS += $(LVMINTERNAL_LIBS) -ldevmapper -laio - -test/unit/run: $(UNIT_OBJECTS) libdm/libdevmapper.$(LIB_SUFFIX) lib/liblvm-internal.a - @echo " [LD] $@" - $(Q) $(CC) $(CFLAGS) $(LDFLAGS) $(EXTRA_EXEC_LDFLAGS) -L$(top_builddir)/libdm \ - -o $@ $(UNIT_OBJECTS) $(UNIT_LDLIBS) - -.PHONEY: unit-test -unit-test: test/unit/run - @echo Running unit tests - LD_LIBRARY_PATH=libdm test/unit/run
test/unit/bcache_t.c deleted +0 -636
636 lines not on this page · raw message
test/unit/bitset_t.c deleted +0 -129
129 lines not on this page · raw message
test/unit/config_t.c deleted +0 -152
152 lines not on this page · raw message
test/unit/dmlist_t.c deleted +0 -49
49 lines not on this page · raw message
test/unit/dmstatus_t.c deleted +0 -72
72 lines not on this page · raw message
test/unit/matcher_data.h deleted +0 -1013
622 lines not on this page · raw message
test/unit/matcher_t.c deleted +0 -70
70 lines not on this page · raw message
test/unit/percent_t.c deleted +0 -101
101 lines not on this page · raw message
test/unit/string_t.c deleted +0 -78
78 lines not on this page · raw message
unit-test/bcache_t.c new file +783 -0
783 lines not on this page · raw message
unit-test/bitset_t.c new file +148 -0
148 lines not on this page · raw message
unit-test/config_t.c new file +167 -0
167 lines not on this page · raw message
unit-test/dmlist_t.c new file +49 -0
49 lines not on this page · raw message
unit-test/dmstatus_t.c new file +84 -0
84 lines not on this page · raw message
unit-test/framework.c new file +66 -0
66 lines not on this page · raw message
unit-test/framework.h new file +49 -0
49 lines not on this page · raw message
unit-test/matcher_data.h new file +1013 -0
1,013 lines not on this page · raw message
unit-test/matcher_t.c new file +89 -0
89 lines not on this page · raw message
unit-test/percent_t.c new file +102 -0
102 lines not on this page · raw message
unit-test/run.c new file +309 -0
309 lines not on this page · raw message
unit-test/string_t.c new file +91 -0
91 lines not on this page · raw message
unit-test/units.h new file +46 -0
46 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Part of the diff is not shown here. View the raw message.