2014-08-27 18:31:31 +05:30
|
|
|
Given(/^valid thin metadata$/) do
|
2013-04-11 18:10:47 +05:30
|
|
|
in_current_dir do
|
2013-06-19 16:04:01 +05:30
|
|
|
system("thinp_xml create --nr-thins uniform[4..9] --nr-mappings uniform[1000..10000] > #{xml_file}")
|
2014-08-28 18:30:08 +05:30
|
|
|
system("dd if=/dev/zero of=#{dev_file} bs=4k count=1024 > /dev/null")
|
2013-04-11 18:10:47 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
run_simple("thin_restore -i #{xml_file} -o #{dev_file}")
|
|
|
|
end
|
|
|
|
|
2013-09-16 18:11:55 +05:30
|
|
|
Given(/^the dev file metadata\.bin$/) do
|
|
|
|
run_simple("dd if=/dev/zero of=#{dev_file} bs=4k count=1024")
|
|
|
|
end
|
|
|
|
|
2013-04-23 19:51:44 +05:30
|
|
|
Given(/^a corrupt superblock$/) 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}")
|
|
|
|
|
|
|
|
in_current_dir do
|
|
|
|
corrupt_block(0)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-07-11 19:23:03 +05:30
|
|
|
Given(/^a tiny file$/) do
|
|
|
|
run_simple("rm -f tiny")
|
|
|
|
run_simple("fallocate -l 123 tiny")
|
|
|
|
end
|
|
|
|
|
2013-04-11 18:10:47 +05:30
|
|
|
When(/^I run thin_check with (.*?)$/) do |opts|
|
2013-04-23 19:51:44 +05:30
|
|
|
run_simple("thin_check #{opts} #{dev_file}", false)
|
2013-04-11 18:10:47 +05:30
|
|
|
end
|
|
|
|
|
2013-05-23 18:27:57 +05:30
|
|
|
When(/^I run thin_rmap with (.*?)$/) do |opts|
|
|
|
|
run_simple("thin_rmap #{opts} #{dev_file}", false)
|
|
|
|
end
|
|
|
|
|
2013-06-27 14:10:43 +05:30
|
|
|
When(/^I run thin_restore with (.*?)$/) do |opts|
|
|
|
|
run_simple("thin_restore #{opts}", false)
|
|
|
|
end
|
|
|
|
|
2013-06-19 19:06:09 +05:30
|
|
|
Then /^it should give no output$/ do
|
|
|
|
ps = only_processes.last
|
|
|
|
output = ps.stdout + ps.stderr
|
|
|
|
output.should == ""
|
|
|
|
end
|
2013-06-25 15:41:50 +05:30
|
|
|
|
|
|
|
Then(/^it should pass with version$/) do
|
|
|
|
only_processes.last.stdout.chomp.should == tools_version
|
|
|
|
end
|
2013-06-28 16:49:24 +05:30
|
|
|
|
|
|
|
When(/^I dump$/) do
|
2013-06-28 16:58:02 +05:30
|
|
|
run_simple("thin_dump #{dev_file} -o #{new_dump_file}", true)
|
2013-06-28 16:49:24 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
When(/^I restore$/) do
|
2013-06-28 16:58:02 +05:30
|
|
|
run_simple("thin_restore -i #{dump_files[-1]} -o #{dev_file}", true)
|
2013-06-28 16:49:24 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
Then(/^dumps ([0-9]+) and ([0-9]+) should be identical$/) do |d1, d2|
|
2013-06-28 16:58:02 +05:30
|
|
|
run_simple("diff -ub #{dump_files[d1.to_i]} #{dump_files[d2.to_i]}", true)
|
2013-06-28 16:49:24 +05:30
|
|
|
end
|
2013-07-09 17:36:18 +05:30
|
|
|
|
2014-08-27 18:31:31 +05:30
|
|
|
Given(/^small thin metadata$/) do
|
2013-07-09 17:36:18 +05:30
|
|
|
in_current_dir do
|
|
|
|
system("thinp_xml create --nr-thins 2 --nr-mappings 1 > #{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
|