diff --git a/.ruby-version b/.ruby-version deleted file mode 100644 index 005119b..0000000 --- a/.ruby-version +++ /dev/null @@ -1 +0,0 @@ -2.4.1 diff --git a/Gemfile b/Gemfile deleted file mode 100644 index fb45034..0000000 --- a/Gemfile +++ /dev/null @@ -1,7 +0,0 @@ -source 'https://rubygems.org' - -group :test do - gem 'cucumber', '~> 2.4.0' - gem 'aruba' - gem 'thinp_xml', :path => "/home/ejt/work/RedHat/thinp_xml" -end diff --git a/Gemfile.lock b/Gemfile.lock deleted file mode 100644 index 08e49eb..0000000 --- a/Gemfile.lock +++ /dev/null @@ -1,53 +0,0 @@ -PATH - remote: /home/ejt/work/RedHat/thinp_xml - specs: - thinp_xml (0.0.22) - ejt_command_line (>= 0.0.2) - -GEM - remote: https://rubygems.org/ - specs: - aruba (0.14.2) - childprocess (~> 0.5.6) - contracts (~> 0.9) - cucumber (>= 1.3.19) - ffi (~> 1.9.10) - rspec-expectations (>= 2.99) - thor (~> 0.19) - builder (3.2.3) - childprocess (0.5.9) - ffi (~> 1.0, >= 1.0.11) - contracts (0.16.0) - cucumber (2.4.0) - builder (>= 2.1.2) - cucumber-core (~> 1.5.0) - cucumber-wire (~> 0.0.1) - diff-lcs (>= 1.1.3) - gherkin (~> 4.0) - multi_json (>= 1.7.5, < 2.0) - multi_test (>= 0.1.2) - cucumber-core (1.5.0) - gherkin (~> 4.0) - cucumber-wire (0.0.1) - diff-lcs (1.3) - ejt_command_line (0.0.4) - ffi (1.9.18) - gherkin (4.1.3) - multi_json (1.12.1) - multi_test (0.1.2) - rspec-expectations (3.6.0) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.6.0) - rspec-support (3.6.0) - thor (0.19.4) - -PLATFORMS - ruby - -DEPENDENCIES - aruba - cucumber (~> 2.4.0) - thinp_xml! - -BUNDLED WITH - 1.15.3 diff --git a/features/step_definitions/cache_steps.rb b/features/step_definitions/cache_steps.rb deleted file mode 100644 index c9d3841..0000000 --- a/features/step_definitions/cache_steps.rb +++ /dev/null @@ -1,111 +0,0 @@ -DEFAULT_INPUT = 'input' -BLOCK_SIZE = 4096 - -Given /^a directory called (.*)\s*$/ do |dir| - create_dir(dir) -end - -Given /^input without read permissions$/ do - write_file(DEFAULT_INPUT, "\0" * 4096) - cd(".") do - f = File.new(DEFAULT_INPUT) - f.chmod(0000) - end -end - -Given(/^input file$/) do - write_file(DEFAULT_INPUT, "\0" * BLOCK_SIZE * 1024) -end - -Given(/^block (\d+) is zeroed$/) do |b| - cd(".") do - File.open(DEFAULT_INPUT, 'w') do |f| - f.seek(BLOCK_SIZE * b.to_i, IO::SEEK_SET) - f.write("\0" * BLOCK_SIZE) - end - end -end - -Then /^it should pass$/ do - expect(last_command_started).to be_successfully_executed -end - -Then /^it should fail$/ do - expect(last_command_started).to_not be_successfully_executed -end - -CACHE_USAGE =< #{xml_file}") - system("dd if=/dev/zero of=#{dev_file} bs=4k count=1024 > /dev/null") - end - - run_simple("cache_restore -i #{xml_file} -o #{dev_file}") -end - -Then(/^cache dumps (\d+) and (\d+) should be identical$/) do |d1, d2| - run_simple("diff -ub #{dump_files[d1.to_i]} #{dump_files[d2.to_i]}", true) -end - -Given(/^a small xml file$/) do - cd(".") do - system("cache_xml create --nr-cache-blocks 3 --nr-mappings 3 --layout linear --dirty-percent 100 > #{xml_file}") - end -end - -Given(/^an empty dev file$/) do - run_simple("dd if=/dev/zero of=#{dev_file} bs=4k count=1024") -end - -When(/^I cache dump$/) do - run_simple("cache_dump #{dev_file} -o #{new_dump_file}", true) -end - -When(/^I cache restore$/) do - run_simple("cache_restore -i #{dump_files[-1]} -o #{dev_file}", true) -end diff --git a/features/step_definitions/era_steps.rb b/features/step_definitions/era_steps.rb deleted file mode 100644 index 6b6a0a7..0000000 --- a/features/step_definitions/era_steps.rb +++ /dev/null @@ -1,47 +0,0 @@ -ERA_USAGE =< #{xml_file}") - end -end - -Then(/^the metadata should be valid$/) do - run_simple("era_check #{dev_file}", true) -end - -Given(/^valid era metadata$/) do - in_current_dir do - system("era_xml create --nr-blocks 100 --nr-writesets 2 --current-era 1000 > #{xml_file}") - system("dd if=/dev/zero of=#{dev_file} bs=4k count=1024 > /dev/null") - end - - run_simple("era_restore -i #{xml_file} -o #{dev_file}") -end - -When(/^I era dump$/) do - run_simple("era_dump #{dev_file} -o #{new_dump_file}", true) -end - -When(/^I era restore$/) do - run_simple("era_restore -i #{dump_files[-1]} -o #{dev_file}", true) -end diff --git a/features/step_definitions/thin_steps.rb b/features/step_definitions/thin_steps.rb deleted file mode 100644 index 5f62a68..0000000 --- a/features/step_definitions/thin_steps.rb +++ /dev/null @@ -1,73 +0,0 @@ -Given(/^valid thin metadata$/) do - in_current_dir do - system("thinp_xml create --nr-thins uniform[4..9] --nr-mappings uniform[1000..10000] > #{xml_file}") - system("dd if=/dev/zero of=#{dev_file} bs=4k count=1024 > /dev/null") - end - - run_simple("thin_restore -i #{xml_file} -o #{dev_file}") -end - -Given(/^the dev file metadata\.bin$/) do - run_simple("dd if=/dev/zero of=#{dev_file} bs=4k count=1024") -end - -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 - -Given(/^a tiny file$/) do - run_simple("rm -f tiny") - run_simple("fallocate -l 123 tiny") -end - -When(/^I run thin_check with (.*?)$/) do |opts| - run_simple("thin_check #{opts} #{dev_file}", false) -end - -When(/^I run thin_rmap with (.*?)$/) do |opts| - run_simple("thin_rmap #{opts} #{dev_file}", false) -end - -When(/^I run thin_restore with (.*?)$/) do |opts| - run_simple("thin_restore #{opts}", false) -end - -Then /^it should give no output$/ do - ps = all_commands.last - output = ps.stdout + ps.stderr - expect(output).to eq("") -end - -Then(/^it should pass with version$/) do - expect(all_commands.last.stdout.chomp).to eq(tools_version) -end - -When(/^I dump$/) do - run_simple("thin_dump #{dev_file} -o #{new_dump_file}", true) -end - -When(/^I restore$/) do - run_simple("thin_restore -i #{dump_files[-1]} -o #{dev_file}", true) -end - -Then(/^dumps ([0-9]+) and ([0-9]+) should be identical$/) do |d1, d2| - run_simple("diff -ub #{dump_files[d1.to_i]} #{dump_files[d2.to_i]}", true) -end - -Given(/^small thin metadata$/) do - 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 diff --git a/features/support/aruba.rb b/features/support/aruba.rb deleted file mode 100644 index de4d203..0000000 --- a/features/support/aruba.rb +++ /dev/null @@ -1,3 +0,0 @@ -require 'aruba/cucumber' - -ENV['PATH'] = "#{Dir::pwd}/bin:#{ENV['PATH']}" diff --git a/features/support/world_extensions.rb b/features/support/world_extensions.rb deleted file mode 100644 index 42b3ab6..0000000 --- a/features/support/world_extensions.rb +++ /dev/null @@ -1,72 +0,0 @@ -Before do - @aruba_timeout_seconds = 120 -end - -module ThinpWorld - def tools_version - version = '' - - File.open('VERSION', 'r') do |f| - version = f.readline - version.chomp! - end - - version - end - - def xml_file - 'metadata.xml' - end - - def dev_file - 'metadata.bin' - end - - def dump_files - @dump_files ||= [xml_file] - end - - def new_dump_file - fn = "dump_#{dump_files.size}.xml" - @dump_files << fn - fn - end - - def corrupt_block(n) - write_block(n, change_random_byte(read_block(n))) - 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) - `thinp_xml create --nr-thins uniform[4..9] --nr-mappings uniform[1000..5000] > #{path}` - end - - private - def read_block(n) - b = nil - - File.open(dev_file, "r") do |f| - f.seek(n * 4096) - b = f.read(4096) - end - - b - end - - def write_block(n, b) - File.open(dev_file, "w") do |f| - f.seek(n * 4096) - f.write(b) - end - end - - def change_random_byte(b) - i = rand(b.size) - puts "changing byte #{i}" - b.setbyte(i, (b.getbyte(i) + 1) % 256) - b - end -end - -World(ThinpWorld)