Add some ftests, and fixup whitespace from Nikhil's work

This commit is contained in:
Joe Thornber 2019-10-28 11:52:21 +00:00
parent cb055c90e5
commit 5f2c3bed69
16 changed files with 460 additions and 433 deletions

View File

@ -46,6 +46,9 @@ Options:
{-h|--help}
{-i|--input} <input xml file>
{-o|--output} <output device or file>
{--transaction-id} <natural>
{--data-block-size} <natural>
{--nr-data-blocks} <natural>
{-q|--quiet}
{-V|--version}")

View File

@ -216,6 +216,33 @@
(run-ok-rcv (stdout _) (thin-restore "-i" xml "-o" md "--quiet")
(assert-eof stdout)))))
(define-scenario (thin-restore override transaction-id)
"thin_restore obeys the --transaction-id override"
(with-empty-metadata (md)
(with-thin-xml (xml)
(run-ok-rcv (stdout stderr) (thin-restore "--transaction-id 2345" "-i" xml "-o" md)
(assert-eof stderr))
(run-ok-rcv (stdout stderr) (thin-dump md)
(assert-matches ".*transaction=\"2345\"" stdout)))))
(define-scenario (thin-restore override data-block-size)
"thin_restore obeys the --data-block-size override"
(with-empty-metadata (md)
(with-thin-xml (xml)
(run-ok-rcv (stdout stderr) (thin-restore "--data-block-size 8192" "-i" xml "-o" md)
(assert-eof stderr))
(run-ok-rcv (stdout stderr) (thin-dump md)
(assert-matches ".*data_block_size=\"8192\"" stdout)))))
(define-scenario (thin-restore override nr-data-blocks)
"thin_restore obeys the --nr-data-blocks override"
(with-empty-metadata (md)
(with-thin-xml (xml)
(run-ok-rcv (stdout stderr) (thin-restore "--nr-data-blocks 234500" "-i" xml "-o" md)
(assert-eof stderr))
(run-ok-rcv (stdout stderr) (thin-dump md)
(assert-matches ".*nr_data_blocks=\"234500\"" stdout)))))
;;;-----------------------------------------------------------
;;; thin_dump scenarios
;;;-----------------------------------------------------------

View File

@ -33,7 +33,6 @@
using namespace base;
using namespace thin_provisioning;
//----------------------------------------------------------------
namespace {

View File

@ -289,7 +289,6 @@ namespace {
};
optional<roots>
find_best_roots(transaction_manager &tm) {
vector<node_info> mapping_roots;
vector<node_info> device_roots;
@ -632,7 +631,6 @@ namespace {
return optional<node_info>(it->second);
}
block_manager<> &bm_;
vector<bool> referenced_;
vector<bool> examined_;
@ -779,7 +777,6 @@ namespace {
return 0ull;
}
void
emit_trees_(block_manager<>::ptr bm, superblock_detail::superblock const &sb,
emitter::ptr e, override_options const &ropts)
@ -827,6 +824,8 @@ namespace {
}
}
superblock_detail::superblock
recreate_superblock(override_options const &opts)
{
@ -874,7 +873,6 @@ namespace {
emit_trees_(bm, *msb, e, opts);
}
}
//----------------------------------------------------------------

View File

@ -49,7 +49,6 @@ namespace thin_provisioning {
bool skip_mappings_;
override_options overrides_;
using dev_set = std::set<uint64_t>;
using maybe_dev_set = boost::optional<dev_set>;

View File

@ -52,6 +52,7 @@ namespace thin_provisioning {
return *data_block_size_;
}
uint32_t get_data_block_size(uint32_t dflt) const {
return data_block_size_ ? *data_block_size_ : dflt;
}

View File

@ -99,7 +99,6 @@ namespace thin_provisioning {
uint32_t const SUPERBLOCK_MAGIC = 27022010;
uint32_t const METADATA_VERSION = 2;
//--------------------------------
class damage_visitor;

View File

@ -26,6 +26,7 @@
#include "thin-provisioning/human_readable_format.h"
#include "thin-provisioning/metadata.h"
#include "thin-provisioning/metadata_dumper.h"
#include "thin-provisioning/override_emitter.h"
#include "thin-provisioning/shared_library_emitter.h"
#include "thin-provisioning/xml_format.h"
#include "version.h"
@ -112,7 +113,6 @@ namespace {
} else
return dump_(path, cout, flags);
}
}
//----------------------------------------------------------------
@ -156,6 +156,9 @@ thin_dump_cmd::run(int argc, char **argv)
{ "repair", no_argument, NULL, 'r'},
{ "dev-id", required_argument, NULL, 1 },
{ "skip-mappings", no_argument, NULL, 2 },
{ "transaction-id", required_argument, NULL, 3 },
{ "data-block-size", required_argument, NULL, 4 },
{ "nr-data-blocks", required_argument, NULL, 5 },
{ "version", no_argument, NULL, 'V'},
{ NULL, no_argument, NULL, 0 }
};

View File

@ -6,6 +6,7 @@
#include "base/output_file_requirements.h"
#include "persistent-data/file_utils.h"
#include "thin-provisioning/commands.h"
#include "thin-provisioning/override_emitter.h"
#include "human_readable_format.h"
#include "metadata_dumper.h"
#include "metadata.h"
@ -68,7 +69,6 @@ thin_repair_cmd::run(int argc, char **argv)
int c;
boost::optional<string> input_path, output_path;
override_options opts;
const char shortopts[] = "hi:o:V";
const struct option longopts[] = {
@ -134,7 +134,6 @@ thin_repair_cmd::run(int argc, char **argv)
}
return repair(*input_path, *output_path, opts);
}
//----------------------------------------------------------------

View File

@ -174,4 +174,3 @@ thin_restore_cmd::run(int argc, char **argv)
}
//----------------------------------------------------------------