Add some ftests, and fixup whitespace from Nikhil's work
This commit is contained in:
parent
cb055c90e5
commit
5f2c3bed69
@ -46,6 +46,9 @@ Options:
|
|||||||
{-h|--help}
|
{-h|--help}
|
||||||
{-i|--input} <input xml file>
|
{-i|--input} <input xml file>
|
||||||
{-o|--output} <output device or file>
|
{-o|--output} <output device or file>
|
||||||
|
{--transaction-id} <natural>
|
||||||
|
{--data-block-size} <natural>
|
||||||
|
{--nr-data-blocks} <natural>
|
||||||
{-q|--quiet}
|
{-q|--quiet}
|
||||||
{-V|--version}")
|
{-V|--version}")
|
||||||
|
|
||||||
|
@ -216,6 +216,33 @@
|
|||||||
(run-ok-rcv (stdout _) (thin-restore "-i" xml "-o" md "--quiet")
|
(run-ok-rcv (stdout _) (thin-restore "-i" xml "-o" md "--quiet")
|
||||||
(assert-eof stdout)))))
|
(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
|
;;; thin_dump scenarios
|
||||||
;;;-----------------------------------------------------------
|
;;;-----------------------------------------------------------
|
||||||
|
@ -33,7 +33,6 @@
|
|||||||
using namespace base;
|
using namespace base;
|
||||||
using namespace thin_provisioning;
|
using namespace thin_provisioning;
|
||||||
|
|
||||||
|
|
||||||
//----------------------------------------------------------------
|
//----------------------------------------------------------------
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
@ -289,7 +289,6 @@ namespace {
|
|||||||
};
|
};
|
||||||
|
|
||||||
optional<roots>
|
optional<roots>
|
||||||
|
|
||||||
find_best_roots(transaction_manager &tm) {
|
find_best_roots(transaction_manager &tm) {
|
||||||
vector<node_info> mapping_roots;
|
vector<node_info> mapping_roots;
|
||||||
vector<node_info> device_roots;
|
vector<node_info> device_roots;
|
||||||
@ -632,7 +631,6 @@ namespace {
|
|||||||
return optional<node_info>(it->second);
|
return optional<node_info>(it->second);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
block_manager<> &bm_;
|
block_manager<> &bm_;
|
||||||
vector<bool> referenced_;
|
vector<bool> referenced_;
|
||||||
vector<bool> examined_;
|
vector<bool> examined_;
|
||||||
@ -779,7 +777,6 @@ namespace {
|
|||||||
return 0ull;
|
return 0ull;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
emit_trees_(block_manager<>::ptr bm, superblock_detail::superblock const &sb,
|
emit_trees_(block_manager<>::ptr bm, superblock_detail::superblock const &sb,
|
||||||
emitter::ptr e, override_options const &ropts)
|
emitter::ptr e, override_options const &ropts)
|
||||||
@ -827,6 +824,8 @@ namespace {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
superblock_detail::superblock
|
superblock_detail::superblock
|
||||||
recreate_superblock(override_options const &opts)
|
recreate_superblock(override_options const &opts)
|
||||||
{
|
{
|
||||||
@ -874,7 +873,6 @@ namespace {
|
|||||||
|
|
||||||
emit_trees_(bm, *msb, e, opts);
|
emit_trees_(bm, *msb, e, opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------
|
//----------------------------------------------------------------
|
||||||
|
@ -49,7 +49,6 @@ namespace thin_provisioning {
|
|||||||
bool skip_mappings_;
|
bool skip_mappings_;
|
||||||
override_options overrides_;
|
override_options overrides_;
|
||||||
|
|
||||||
|
|
||||||
using dev_set = std::set<uint64_t>;
|
using dev_set = std::set<uint64_t>;
|
||||||
using maybe_dev_set = boost::optional<dev_set>;
|
using maybe_dev_set = boost::optional<dev_set>;
|
||||||
|
|
||||||
|
@ -52,6 +52,7 @@ namespace thin_provisioning {
|
|||||||
|
|
||||||
return *data_block_size_;
|
return *data_block_size_;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t get_data_block_size(uint32_t dflt) const {
|
uint32_t get_data_block_size(uint32_t dflt) const {
|
||||||
return data_block_size_ ? *data_block_size_ : dflt;
|
return data_block_size_ ? *data_block_size_ : dflt;
|
||||||
}
|
}
|
||||||
|
@ -99,7 +99,6 @@ namespace thin_provisioning {
|
|||||||
uint32_t const SUPERBLOCK_MAGIC = 27022010;
|
uint32_t const SUPERBLOCK_MAGIC = 27022010;
|
||||||
uint32_t const METADATA_VERSION = 2;
|
uint32_t const METADATA_VERSION = 2;
|
||||||
|
|
||||||
|
|
||||||
//--------------------------------
|
//--------------------------------
|
||||||
|
|
||||||
class damage_visitor;
|
class damage_visitor;
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
#include "thin-provisioning/human_readable_format.h"
|
#include "thin-provisioning/human_readable_format.h"
|
||||||
#include "thin-provisioning/metadata.h"
|
#include "thin-provisioning/metadata.h"
|
||||||
#include "thin-provisioning/metadata_dumper.h"
|
#include "thin-provisioning/metadata_dumper.h"
|
||||||
|
#include "thin-provisioning/override_emitter.h"
|
||||||
#include "thin-provisioning/shared_library_emitter.h"
|
#include "thin-provisioning/shared_library_emitter.h"
|
||||||
#include "thin-provisioning/xml_format.h"
|
#include "thin-provisioning/xml_format.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
@ -112,7 +113,6 @@ namespace {
|
|||||||
} else
|
} else
|
||||||
return dump_(path, cout, flags);
|
return dump_(path, cout, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------
|
//----------------------------------------------------------------
|
||||||
@ -156,6 +156,9 @@ thin_dump_cmd::run(int argc, char **argv)
|
|||||||
{ "repair", no_argument, NULL, 'r'},
|
{ "repair", no_argument, NULL, 'r'},
|
||||||
{ "dev-id", required_argument, NULL, 1 },
|
{ "dev-id", required_argument, NULL, 1 },
|
||||||
{ "skip-mappings", no_argument, NULL, 2 },
|
{ "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'},
|
{ "version", no_argument, NULL, 'V'},
|
||||||
{ NULL, no_argument, NULL, 0 }
|
{ NULL, no_argument, NULL, 0 }
|
||||||
};
|
};
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include "base/output_file_requirements.h"
|
#include "base/output_file_requirements.h"
|
||||||
#include "persistent-data/file_utils.h"
|
#include "persistent-data/file_utils.h"
|
||||||
#include "thin-provisioning/commands.h"
|
#include "thin-provisioning/commands.h"
|
||||||
|
#include "thin-provisioning/override_emitter.h"
|
||||||
#include "human_readable_format.h"
|
#include "human_readable_format.h"
|
||||||
#include "metadata_dumper.h"
|
#include "metadata_dumper.h"
|
||||||
#include "metadata.h"
|
#include "metadata.h"
|
||||||
@ -68,7 +69,6 @@ thin_repair_cmd::run(int argc, char **argv)
|
|||||||
int c;
|
int c;
|
||||||
boost::optional<string> input_path, output_path;
|
boost::optional<string> input_path, output_path;
|
||||||
override_options opts;
|
override_options opts;
|
||||||
|
|
||||||
const char shortopts[] = "hi:o:V";
|
const char shortopts[] = "hi:o:V";
|
||||||
|
|
||||||
const struct option longopts[] = {
|
const struct option longopts[] = {
|
||||||
@ -134,7 +134,6 @@ thin_repair_cmd::run(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
return repair(*input_path, *output_path, opts);
|
return repair(*input_path, *output_path, opts);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------
|
//----------------------------------------------------------------
|
||||||
|
@ -174,4 +174,3 @@ thin_restore_cmd::run(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------
|
//----------------------------------------------------------------
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user