cucumber test for thin_check --super-block-only
This commit is contained in:
parent
7d3ab79789
commit
3629e1e2b5
13
features/step_definitions/thin_steps.rb
Normal file
13
features/step_definitions/thin_steps.rb
Normal file
@ -0,0 +1,13 @@
|
||||
Given(/^valid metadata$/) do
|
||||
in_current_dir do
|
||||
write_valid_xml(xml_file)
|
||||
end
|
||||
|
||||
run_simple("dd if=/dev/zero of=#{dev_file} bs=4k count=1024")
|
||||
run_simple("thin_restore -i #{xml_file} -o #{dev_file}")
|
||||
end
|
||||
|
||||
When(/^I run thin_check with (.*?)$/) do |opts|
|
||||
run "thin_check #{opts} #{dev_file}"
|
||||
end
|
||||
|
29
features/support/world_extensions.rb
Normal file
29
features/support/world_extensions.rb
Normal file
@ -0,0 +1,29 @@
|
||||
module ThinpWorld
|
||||
def tools_version
|
||||
"0.1.5+"
|
||||
end
|
||||
|
||||
def xml_file
|
||||
'metadata.xml'
|
||||
end
|
||||
|
||||
def dev_file
|
||||
'metadata.bin'
|
||||
end
|
||||
|
||||
# FIXME: we should really break out the xml stuff from
|
||||
# thinp-test-suite and put in a gem in this repo.
|
||||
def write_valid_xml(path)
|
||||
File.open(path, "w+") do |f|
|
||||
f.write <<EOF
|
||||
<superblock uuid="" time="0" transaction="0" data_block_size="128" nr_data_blocks="0">
|
||||
<device dev_id="0" mapped_blocks="2" transaction="0" creation_time="0" snap_time="0">
|
||||
<range_mapping origin_begin="0" data_begin="0" length="2" time="0"/>
|
||||
</device>
|
||||
</superblock>
|
||||
EOF
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
World(ThinpWorld)
|
@ -37,4 +37,11 @@ Feature: thin_check
|
||||
{-q|--quiet}
|
||||
{-h|--help}
|
||||
{-V|--version}
|
||||
{--super-block-only}
|
||||
"""
|
||||
|
||||
@announce
|
||||
Scenario: --super-block-only check passes on valid metadata
|
||||
Given valid metadata
|
||||
When I run thin_check with --super-block-only
|
||||
Then it should pass
|
@ -53,7 +53,8 @@ namespace {
|
||||
<< "Options:" << endl
|
||||
<< " {-q|--quiet}" << endl
|
||||
<< " {-h|--help}" << endl
|
||||
<< " {-V|--version}" << endl;
|
||||
<< " {-V|--version}" << endl
|
||||
<< " {--super-block-only}" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
@ -66,6 +67,7 @@ int main(int argc, char **argv)
|
||||
{ "quiet", no_argument, NULL, 'q'},
|
||||
{ "help", no_argument, NULL, 'h'},
|
||||
{ "version", no_argument, NULL, 'V'},
|
||||
{ "super-block-only", no_argument, NULL, 0},
|
||||
{ NULL, no_argument, NULL, 0 }
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user