Start stubbing out cache_dump
This commit is contained in:
parent
a933749cbf
commit
d3ce6b811b
1
.gitignore
vendored
1
.gitignore
vendored
@ -14,6 +14,7 @@ thin_repair
|
||||
thin_rmap
|
||||
|
||||
cache_check
|
||||
cache_dump
|
||||
cache_restore
|
||||
|
||||
*.metadata
|
||||
|
@ -21,6 +21,7 @@
|
||||
V=@
|
||||
PROGRAMS=\
|
||||
cache_check \
|
||||
cache_dump \
|
||||
cache_restore \
|
||||
\
|
||||
thin_check \
|
||||
@ -234,6 +235,9 @@ CACHE_CHECK_SOURCE=\
|
||||
caching/superblock.cc
|
||||
CACHE_CHECK_OBJECTS=$(subst .cc,.o,$(CACHE_CHECK_SOURCE))
|
||||
|
||||
CACHE_DUMP_SOURCE=$(SOURCE)
|
||||
CACHE_DUMP_OBJECTS=$(subst .cc,.o,$(CACHE_DUMP_SOURCE))
|
||||
|
||||
CACHE_RESTORE_SOURCE=$(SOURCE)
|
||||
CACHE_RESTORE_OBJECTS=$(subst .cc,.o,$(CACHE_RESTORE_SOURCE))
|
||||
|
||||
@ -241,6 +245,10 @@ cache_check: $(CACHE_CHECK_OBJECTS) caching/cache_check.o
|
||||
@echo " [LD] $@"
|
||||
$(V) $(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $+ $(LIBS)
|
||||
|
||||
cache_dump: $(CACHE_DUMP_OBJECTS) caching/cache_dump.o
|
||||
@echo " [LD] $@"
|
||||
$(V) $(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $+ $(LIBS) $(LIBEXPAT)
|
||||
|
||||
cache_restore: $(CACHE_RESTORE_OBJECTS) caching/cache_restore.o
|
||||
@echo " [LD] $@"
|
||||
$(V) $(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $+ $(LIBS) $(LIBEXPAT)
|
||||
|
60
caching/cache_dump.cc
Normal file
60
caching/cache_dump.cc
Normal file
@ -0,0 +1,60 @@
|
||||
#include <getopt.h>
|
||||
#include <libgen.h>
|
||||
#include <iostream>
|
||||
|
||||
#include "version.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
//----------------------------------------------------------------
|
||||
|
||||
namespace {
|
||||
void usage(ostream &out, string const &cmd) {
|
||||
out << "Usage: " << cmd << " [options] {device|file}" << endl
|
||||
<< "Options:" << endl
|
||||
<< " {-h|--help}" << endl
|
||||
<< " {-V|--version}" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int c;
|
||||
char const shortopts[] = "hV";
|
||||
|
||||
option const longopts[] = {
|
||||
{ "help", no_argument, NULL, 'h'},
|
||||
{ "version", no_argument, NULL, 'V'},
|
||||
{ NULL, no_argument, NULL, 0 }
|
||||
};
|
||||
|
||||
while ((c = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1) {
|
||||
switch(c) {
|
||||
case 'h':
|
||||
usage(cout, basename(argv[0]));
|
||||
return 0;
|
||||
|
||||
case 'V':
|
||||
cout << THIN_PROVISIONING_TOOLS_VERSION << endl;
|
||||
return 0;
|
||||
|
||||
default:
|
||||
usage(cerr, basename(argv[0]));
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (argc == optind) {
|
||||
cerr << "No input file provided." << endl;
|
||||
usage(cerr, basename(argv[0]));
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------
|
30
features/cache_dump.feature
Normal file
30
features/cache_dump.feature
Normal file
@ -0,0 +1,30 @@
|
||||
Feature: cache_dump
|
||||
Scenario: print version (-V flag)
|
||||
When I run cache_dump with -V
|
||||
Then it should pass with version
|
||||
|
||||
Scenario: print version (--version flag)
|
||||
When I run cache_dump with --version
|
||||
Then it should pass with version
|
||||
|
||||
Scenario: print help (-h)
|
||||
When I run cache_dump with -h
|
||||
Then it should pass with:
|
||||
|
||||
"""
|
||||
Usage: cache_dump [options] {device|file}
|
||||
Options:
|
||||
{-h|--help}
|
||||
{-V|--version}
|
||||
"""
|
||||
|
||||
Scenario: print help (--help)
|
||||
When I run cache_dump with -h
|
||||
Then it should pass with:
|
||||
|
||||
"""
|
||||
Usage: cache_dump [options] {device|file}
|
||||
Options:
|
||||
{-h|--help}
|
||||
{-V|--version}
|
||||
"""
|
@ -46,3 +46,10 @@ Feature: thin_restore
|
||||
"""
|
||||
No output file provided.
|
||||
"""
|
||||
|
||||
Scenario: dump/restore is a noop
|
||||
Given valid cache metadata
|
||||
When I dump cache
|
||||
And I restore cache
|
||||
And I dump cache
|
||||
Then cache dumps 1 and 2 should be identical
|
||||
|
@ -64,3 +64,22 @@ When(/^I run cache_restore with (.*?)$/) do |opts|
|
||||
run_simple("cache_restore #{opts}", false)
|
||||
end
|
||||
|
||||
When(/^I run cache_dump with (.*?)$/) do |opts|
|
||||
run_simple("cache_dump #{opts}", false)
|
||||
end
|
||||
|
||||
Given(/^valid cache metadata$/) do
|
||||
pending # express the regexp above with the code you wish you had
|
||||
end
|
||||
|
||||
When(/^I dump cache$/) do
|
||||
pending # express the regexp above with the code you wish you had
|
||||
end
|
||||
|
||||
When(/^I restore cache$/) do
|
||||
pending # express the regexp above with the code you wish you had
|
||||
end
|
||||
|
||||
Then(/^cache dumps (\d+) and (\d+) should be identical$/) do |arg1, arg2|
|
||||
pending # express the regexp above with the code you wish you had
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user