diff --git a/features/step_definitions/thin_steps.rb b/features/step_definitions/thin_steps.rb new file mode 100644 index 0000000..b430da7 --- /dev/null +++ b/features/step_definitions/thin_steps.rb @@ -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 + diff --git a/features/support/world_extensions.rb b/features/support/world_extensions.rb new file mode 100644 index 0000000..23a5b76 --- /dev/null +++ b/features/support/world_extensions.rb @@ -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 + end + end +end + +World(ThinpWorld) diff --git a/features/thin_check.feature b/features/thin_check.feature index ee61e06..34de8ba 100644 --- a/features/thin_check.feature +++ b/features/thin_check.feature @@ -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 \ No newline at end of file diff --git a/thin-provisioning/thin_check.cc b/thin-provisioning/thin_check.cc index a930d52..ffc2894 100644 --- a/thin-provisioning/thin_check.cc +++ b/thin-provisioning/thin_check.cc @@ -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 } };