diff options
author | Joe Thornber <thornber@redhat.com> | 2010-07-20 14:38:44 +0000 |
---|---|---|
committer | Joe Thornber <thornber@redhat.com> | 2010-07-20 14:38:44 +0000 |
commit | 1033d120404c0e41ced5f36361e412ac03a3461f (patch) | |
tree | 8776b2d0770ad642176c9e079987e621251f1e23 /report-generators/test | |
parent | 60f425d1b3508d71883ac1a4501f6ab7f3e32b08 (diff) | |
download | lvm2-1033d120404c0e41ced5f36361e412ac03a3461f.tar.gz lvm2-1033d120404c0e41ced5f36361e412ac03a3461f.tar.xz lvm2-1033d120404c0e41ced5f36361e412ac03a3461f.zip |
Report generators for unit tests and memory checks. Configure with
--enable-testing.
Diffstat (limited to 'report-generators/test')
-rw-r--r-- | report-generators/test/example.schedule | 4 | ||||
-rw-r--r-- | report-generators/test/strings/more_strings/test3.txt | 1 | ||||
-rw-r--r-- | report-generators/test/strings/test1.txt | 1 | ||||
-rw-r--r-- | report-generators/test/strings/test2 | 3 | ||||
-rw-r--r-- | report-generators/test/tc_log.rb | 26 | ||||
-rw-r--r-- | report-generators/test/tc_schedule_file.rb | 28 | ||||
-rw-r--r-- | report-generators/test/tc_string_store.rb | 19 | ||||
-rw-r--r-- | report-generators/test/ts.rb | 3 |
8 files changed, 85 insertions, 0 deletions
diff --git a/report-generators/test/example.schedule b/report-generators/test/example.schedule new file mode 100644 index 00000000..f617187a --- /dev/null +++ b/report-generators/test/example.schedule @@ -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
\ No newline at end of file diff --git a/report-generators/test/strings/more_strings/test3.txt b/report-generators/test/strings/more_strings/test3.txt new file mode 100644 index 00000000..3e9ffe06 --- /dev/null +++ b/report-generators/test/strings/more_strings/test3.txt @@ -0,0 +1 @@ +lorem diff --git a/report-generators/test/strings/test1.txt b/report-generators/test/strings/test1.txt new file mode 100644 index 00000000..af5626b4 --- /dev/null +++ b/report-generators/test/strings/test1.txt @@ -0,0 +1 @@ +Hello, world! diff --git a/report-generators/test/strings/test2 b/report-generators/test/strings/test2 new file mode 100644 index 00000000..54d55bf0 --- /dev/null +++ b/report-generators/test/strings/test2 @@ -0,0 +1,3 @@ +one +two +three
\ No newline at end of file diff --git a/report-generators/test/tc_log.rb b/report-generators/test/tc_log.rb new file mode 100644 index 00000000..a7e9023c --- /dev/null +++ b/report-generators/test/tc_log.rb @@ -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 diff --git a/report-generators/test/tc_schedule_file.rb b/report-generators/test/tc_schedule_file.rb new file mode 100644 index 00000000..ec4bc3ea --- /dev/null +++ b/report-generators/test/tc_schedule_file.rb @@ -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 diff --git a/report-generators/test/tc_string_store.rb b/report-generators/test/tc_string_store.rb new file mode 100644 index 00000000..5ff89dd8 --- /dev/null +++ b/report-generators/test/tc_string_store.rb @@ -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 diff --git a/report-generators/test/ts.rb b/report-generators/test/ts.rb new file mode 100644 index 00000000..0a8cc910 --- /dev/null +++ b/report-generators/test/ts.rb @@ -0,0 +1,3 @@ +require 'tc_log' +require 'tc_string_store' +require 'tc_schedule_file' |