create a separate unit-tests dir
This commit is contained in:
parent
7dbc18d327
commit
9be40b76b5
45
Makefile
45
Makefile
@ -1,35 +1,36 @@
|
|||||||
SOURCE=\
|
SOURCE=\
|
||||||
endian.cc \
|
endian_utils.cc \
|
||||||
metadata.cc \
|
metadata_disk_structures.cc
|
||||||
metadata_disk_structures.cc \
|
|
||||||
space_map_disk.cc \
|
# metadata.cc \
|
||||||
|
|
||||||
TEST_SOURCE=\
|
TEST_SOURCE=\
|
||||||
block_t.cc \
|
unit-tests/block_t.cc \
|
||||||
btree_t.cc \
|
unit-tests/btree_t.cc \
|
||||||
endian_t.cc \
|
unit-tests/endian_t.cc \
|
||||||
metadata_t.cc \
|
unit-tests/space_map_t.cc \
|
||||||
space_map_t.cc \
|
unit-tests/space_map_disk_t.cc \
|
||||||
space_map_disk_t.cc \
|
unit-tests/transaction_manager_t.cc \
|
||||||
transaction_manager_t.cc \
|
|
||||||
|
# unit-tests/metadata_t.cc \
|
||||||
|
|
||||||
OBJECTS=$(subst .cc,.o,$(SOURCE))
|
OBJECTS=$(subst .cc,.o,$(SOURCE))
|
||||||
TEST_PROGRAMS=$(subst .cc,,$(TEST_SOURCE))
|
TEST_PROGRAMS=$(subst .cc,,$(TEST_SOURCE))
|
||||||
CPPFLAGS=-Wall -std=c++0x -g
|
TOP_DIR:=$(PWD)
|
||||||
INCLUDES=
|
CPPFLAGS=-Wall -std=c++0x -g -I$(TOP_DIR)
|
||||||
LIBS=-lstdc++
|
LIBS=-lstdc++
|
||||||
|
|
||||||
.PHONEY: unit-tests test-programs
|
.PHONEY: unit-tests test-programs
|
||||||
|
|
||||||
test-programs: $(TEST_PROGRAMS)
|
test-programs: $(TEST_PROGRAMS)
|
||||||
|
|
||||||
unit-tests: $(TEST_PROGRAMS)
|
unit-test: $(TEST_PROGRAMS)
|
||||||
for p in $(TEST_PROGRAMS); do echo Running $$p; ./$$p; done
|
for p in $(TEST_PROGRAMS); do echo Running $$p; ./$$p; done
|
||||||
|
|
||||||
.SUFFIXES: .cc .o .d
|
.SUFFIXES: .cc .o .d
|
||||||
|
|
||||||
%.d: %.cc
|
%.d: %.cc
|
||||||
$(CC) -MM $(CPPFLAGS) $< > $@.$$$$; \
|
g++ -MM $(CPPFLAGS) $< > $@.$$$$; \
|
||||||
sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
|
sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
|
||||||
rm -f $@.$$$$
|
rm -f $@.$$$$
|
||||||
|
|
||||||
@ -39,25 +40,25 @@ unit-tests: $(TEST_PROGRAMS)
|
|||||||
multisnap_display: $(OBJECTS) main.o
|
multisnap_display: $(OBJECTS) main.o
|
||||||
g++ $(CPPFLAGS) -o $@ $+ $(LIBS)
|
g++ $(CPPFLAGS) -o $@ $+ $(LIBS)
|
||||||
|
|
||||||
block_t: block_t.o
|
unit-tests/block_t: unit-tests/block_t.o
|
||||||
g++ $(CPPFLAGS) -o $@ $+ $(LIBS)
|
g++ $(CPPFLAGS) -o $@ $+ $(LIBS)
|
||||||
|
|
||||||
btree_t: btree_t.o
|
unit-tests/btree_t: unit-tests/btree_t.o
|
||||||
g++ $(CPPFLAGS) -o $@ $+ $(LIBS)
|
g++ $(CPPFLAGS) -o $@ $+ $(LIBS)
|
||||||
|
|
||||||
space_map_t: space_map_t.o
|
unit-tests/space_map_t: unit-tests/space_map_t.o
|
||||||
g++ $(CPPFLAGS) -o $@ $+ $(LIBS)
|
g++ $(CPPFLAGS) -o $@ $+ $(LIBS)
|
||||||
|
|
||||||
space_map_disk_t: space_map_disk_t.o $(OBJECTS)
|
unit-tests/space_map_disk_t: unit-tests/space_map_disk_t.o $(OBJECTS)
|
||||||
g++ $(CPPFLAGS) -o $@ $+ $(LIBS)
|
g++ $(CPPFLAGS) -o $@ $+ $(LIBS)
|
||||||
|
|
||||||
transaction_manager_t: transaction_manager_t.o
|
unit-tests/transaction_manager_t: unit-tests/transaction_manager_t.o
|
||||||
g++ $(CPPFLAGS) -o $@ $+ $(LIBS)
|
g++ $(CPPFLAGS) -o $@ $+ $(LIBS)
|
||||||
|
|
||||||
metadata_t: metadata_t.o $(OBJECTS)
|
unit-tests/metadata_t: unit-tests/metadata_t.o $(OBJECTS)
|
||||||
g++ $(CPPFLAGS) -o $@ $+ $(LIBS)
|
g++ $(CPPFLAGS) -o $@ $+ $(LIBS)
|
||||||
|
|
||||||
endian_t: endian_t.o $(OBJECTS)
|
unit-tests/endian_t: unit-tests/endian_t.o $(OBJECTS)
|
||||||
g++ $(CPPFLAGS) -o $@ $+ $(LIBS)
|
g++ $(CPPFLAGS) -o $@ $+ $(LIBS)
|
||||||
|
|
||||||
include $(subst .cc,.d,$(SOURCE))
|
include $(subst .cc,.d,$(SOURCE))
|
||||||
|
2
btree.h
2
btree.h
@ -1,7 +1,7 @@
|
|||||||
#ifndef BTREE_H
|
#ifndef BTREE_H
|
||||||
#define BTREE_H
|
#define BTREE_H
|
||||||
|
|
||||||
#include "endian.h"
|
#include "endian_utils.h"
|
||||||
#include "transaction_manager.h"
|
#include "transaction_manager.h"
|
||||||
|
|
||||||
#include <boost/noncopyable.hpp>
|
#include <boost/noncopyable.hpp>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#include "endian.h"
|
#include "endian_utils.h"
|
||||||
|
|
||||||
using namespace base;
|
using namespace base;
|
||||||
|
|
12
metadata.h
12
metadata.h
@ -4,7 +4,7 @@
|
|||||||
#include "block.h"
|
#include "block.h"
|
||||||
#include "transaction_manager.h"
|
#include "transaction_manager.h"
|
||||||
#include "btree.h"
|
#include "btree.h"
|
||||||
#include "endian.h"
|
#include "endian_utils.h"
|
||||||
#include "metadata_disk_structures.h"
|
#include "metadata_disk_structures.h"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
@ -119,11 +119,7 @@ namespace thin_provisioning {
|
|||||||
public:
|
public:
|
||||||
typedef boost::shared_ptr<metadata> ptr;
|
typedef boost::shared_ptr<metadata> ptr;
|
||||||
|
|
||||||
metadata(transaction_manager<MD_BLOCK_SIZE>::ptr tm,
|
metadata(std::string const &dev_path);
|
||||||
block_address superblock,
|
|
||||||
sector_t data_block_size,
|
|
||||||
block_address nr_data_blocks,
|
|
||||||
bool create);
|
|
||||||
~metadata();
|
~metadata();
|
||||||
|
|
||||||
void commit();
|
void commit();
|
||||||
@ -162,7 +158,9 @@ namespace thin_provisioning {
|
|||||||
typedef persistent_data::btree<1, block_traits, MD_BLOCK_SIZE> single_mapping_tree;
|
typedef persistent_data::btree<1, block_traits, MD_BLOCK_SIZE> single_mapping_tree;
|
||||||
|
|
||||||
tm_ptr tm_;
|
tm_ptr tm_;
|
||||||
space_map::ptr metadata_sm_;
|
|
||||||
|
// Ignoring the metadata sm for now, since we don't need it for the basic 'dump' tool
|
||||||
|
// space_map::ptr metadata_sm_;
|
||||||
space_map::ptr data_sm_;
|
space_map::ptr data_sm_;
|
||||||
detail_tree details_;
|
detail_tree details_;
|
||||||
dev_tree mappings_top_level_;
|
dev_tree mappings_top_level_;
|
||||||
|
@ -9,7 +9,6 @@ using namespace thin_provisioning;
|
|||||||
void
|
void
|
||||||
device_details_traits::unpack(device_details_disk const &disk, device_details &value)
|
device_details_traits::unpack(device_details_disk const &disk, device_details &value)
|
||||||
{
|
{
|
||||||
value.dev_size_ = to_cpu<uint64_t>(disk.dev_size_);
|
|
||||||
value.mapped_blocks_ = to_cpu<uint64_t>(disk.mapped_blocks_);
|
value.mapped_blocks_ = to_cpu<uint64_t>(disk.mapped_blocks_);
|
||||||
value.transaction_id_ = to_cpu<uint64_t>(disk.transaction_id_);
|
value.transaction_id_ = to_cpu<uint64_t>(disk.transaction_id_);
|
||||||
value.creation_time_ = to_cpu<uint32_t>(disk.creation_time_);
|
value.creation_time_ = to_cpu<uint32_t>(disk.creation_time_);
|
||||||
@ -19,7 +18,6 @@ device_details_traits::unpack(device_details_disk const &disk, device_details &v
|
|||||||
void
|
void
|
||||||
device_details_traits::pack(device_details const &value, device_details_disk &disk)
|
device_details_traits::pack(device_details const &value, device_details_disk &disk)
|
||||||
{
|
{
|
||||||
disk.dev_size_ = to_disk<__le64>(value.dev_size_);
|
|
||||||
disk.mapped_blocks_ = to_disk<__le64>(value.mapped_blocks_);
|
disk.mapped_blocks_ = to_disk<__le64>(value.mapped_blocks_);
|
||||||
disk.transaction_id_ = to_disk<__le64>(value.transaction_id_);
|
disk.transaction_id_ = to_disk<__le64>(value.transaction_id_);
|
||||||
disk.creation_time_ = to_disk<__le32>(value.creation_time_);
|
disk.creation_time_ = to_disk<__le32>(value.creation_time_);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#ifndef METADATA_DISK_STRUCTURES_H
|
#ifndef METADATA_DISK_STRUCTURES_H
|
||||||
#define METADATA_DISK_STRUCTURES_H
|
#define METADATA_DISK_STRUCTURES_H
|
||||||
|
|
||||||
#include "endian.h"
|
#include "endian_utils.h"
|
||||||
#include "btree.h"
|
#include "btree.h"
|
||||||
|
|
||||||
//----------------------------------------------------------------
|
//----------------------------------------------------------------
|
||||||
@ -10,7 +10,6 @@ namespace thin_provisioning {
|
|||||||
using namespace base; // FIXME: don't use namespaces in headers.
|
using namespace base; // FIXME: don't use namespaces in headers.
|
||||||
|
|
||||||
struct device_details_disk {
|
struct device_details_disk {
|
||||||
__le64 dev_size_;
|
|
||||||
__le64 mapped_blocks_;
|
__le64 mapped_blocks_;
|
||||||
__le64 transaction_id_; /* when created */
|
__le64 transaction_id_; /* when created */
|
||||||
__le32 creation_time_;
|
__le32 creation_time_;
|
||||||
@ -18,7 +17,6 @@ namespace thin_provisioning {
|
|||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
struct device_details {
|
struct device_details {
|
||||||
uint64_t dev_size_;
|
|
||||||
uint64_t mapped_blocks_;
|
uint64_t mapped_blocks_;
|
||||||
uint64_t transaction_id_; /* when created */
|
uint64_t transaction_id_; /* when created */
|
||||||
uint32_t creation_time_;
|
uint32_t creation_time_;
|
||||||
|
@ -1,7 +0,0 @@
|
|||||||
#include "space_map_disk.h"
|
|
||||||
|
|
||||||
|
|
||||||
//----------------------------------------------------------------
|
|
||||||
|
|
||||||
|
|
||||||
//----------------------------------------------------------------
|
|
@ -3,9 +3,9 @@
|
|||||||
|
|
||||||
#include "space_map.h"
|
#include "space_map.h"
|
||||||
#include "transaction_manager.h"
|
#include "transaction_manager.h"
|
||||||
#include "endian.h"
|
#include "endian_utils.h"
|
||||||
#include "space_map_disk_structures.h"
|
#include "space_map_disk_structures.h"
|
||||||
#include "math.h"
|
#include "math_utils.h"
|
||||||
|
|
||||||
//----------------------------------------------------------------
|
//----------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#ifndef SPACE_MAP_DISK_STRUCTURES_H
|
#ifndef SPACE_MAP_DISK_STRUCTURES_H
|
||||||
#define SPACE_MAP_DISK_STRUCTURES_H
|
#define SPACE_MAP_DISK_STRUCTURES_H
|
||||||
|
|
||||||
#include "endian.h"
|
#include "endian_utils.h"
|
||||||
#include "btree.h"
|
#include "btree.h"
|
||||||
|
|
||||||
//----------------------------------------------------------------
|
//----------------------------------------------------------------
|
||||||
|
Loading…
Reference in New Issue
Block a user