From 9be40b76b57475c901cf31fc1a56b9fa680b5930 Mon Sep 17 00:00:00 2001 From: Joe Thornber Date: Mon, 22 Aug 2011 10:42:13 +0100 Subject: [PATCH] create a separate unit-tests dir --- Makefile | 45 ++++++++++--------- btree.h | 2 +- endian.cc => endian_utils.cc | 2 +- endian.h => endian_utils.h | 0 math.h => math_utils.h | 0 metadata.h | 12 +++-- metadata_disk_structures.cc | 2 - metadata_disk_structures.h | 4 +- space_map_disk.cc | 7 --- space_map_disk.h | 4 +- space_map_disk_structures.h | 2 +- block_t.cc => unit-tests/block_t.cc | 0 btree_t.cc => unit-tests/btree_t.cc | 0 endian_t.cc => unit-tests/endian_t.cc | 0 metadata_t.cc => unit-tests/metadata_t.cc | 0 .../space_map_disk_t.cc | 0 space_map_t.cc => unit-tests/space_map_t.cc | 0 .../transaction_manager_t.cc | 0 18 files changed, 34 insertions(+), 46 deletions(-) rename endian.cc => endian_utils.cc (97%) rename endian.h => endian_utils.h (100%) rename math.h => math_utils.h (100%) delete mode 100644 space_map_disk.cc rename block_t.cc => unit-tests/block_t.cc (100%) rename btree_t.cc => unit-tests/btree_t.cc (100%) rename endian_t.cc => unit-tests/endian_t.cc (100%) rename metadata_t.cc => unit-tests/metadata_t.cc (100%) rename space_map_disk_t.cc => unit-tests/space_map_disk_t.cc (100%) rename space_map_t.cc => unit-tests/space_map_t.cc (100%) rename transaction_manager_t.cc => unit-tests/transaction_manager_t.cc (100%) diff --git a/Makefile b/Makefile index a20c7ae..df452f5 100644 --- a/Makefile +++ b/Makefile @@ -1,35 +1,36 @@ SOURCE=\ - endian.cc \ - metadata.cc \ - metadata_disk_structures.cc \ - space_map_disk.cc \ + endian_utils.cc \ + metadata_disk_structures.cc + +# metadata.cc \ TEST_SOURCE=\ - block_t.cc \ - btree_t.cc \ - endian_t.cc \ - metadata_t.cc \ - space_map_t.cc \ - space_map_disk_t.cc \ - transaction_manager_t.cc \ + unit-tests/block_t.cc \ + unit-tests/btree_t.cc \ + unit-tests/endian_t.cc \ + unit-tests/space_map_t.cc \ + unit-tests/space_map_disk_t.cc \ + unit-tests/transaction_manager_t.cc \ + +# unit-tests/metadata_t.cc \ OBJECTS=$(subst .cc,.o,$(SOURCE)) TEST_PROGRAMS=$(subst .cc,,$(TEST_SOURCE)) -CPPFLAGS=-Wall -std=c++0x -g -INCLUDES= +TOP_DIR:=$(PWD) +CPPFLAGS=-Wall -std=c++0x -g -I$(TOP_DIR) LIBS=-lstdc++ .PHONEY: unit-tests 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 .SUFFIXES: .cc .o .d %.d: %.cc - $(CC) -MM $(CPPFLAGS) $< > $@.$$$$; \ + g++ -MM $(CPPFLAGS) $< > $@.$$$$; \ sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ rm -f $@.$$$$ @@ -39,25 +40,25 @@ unit-tests: $(TEST_PROGRAMS) multisnap_display: $(OBJECTS) main.o g++ $(CPPFLAGS) -o $@ $+ $(LIBS) -block_t: block_t.o +unit-tests/block_t: unit-tests/block_t.o g++ $(CPPFLAGS) -o $@ $+ $(LIBS) -btree_t: btree_t.o +unit-tests/btree_t: unit-tests/btree_t.o 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) -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) -transaction_manager_t: transaction_manager_t.o +unit-tests/transaction_manager_t: unit-tests/transaction_manager_t.o g++ $(CPPFLAGS) -o $@ $+ $(LIBS) -metadata_t: metadata_t.o $(OBJECTS) +unit-tests/metadata_t: unit-tests/metadata_t.o $(OBJECTS) g++ $(CPPFLAGS) -o $@ $+ $(LIBS) -endian_t: endian_t.o $(OBJECTS) +unit-tests/endian_t: unit-tests/endian_t.o $(OBJECTS) g++ $(CPPFLAGS) -o $@ $+ $(LIBS) include $(subst .cc,.d,$(SOURCE)) diff --git a/btree.h b/btree.h index 73b957a..f7e26b3 100644 --- a/btree.h +++ b/btree.h @@ -1,7 +1,7 @@ #ifndef BTREE_H #define BTREE_H -#include "endian.h" +#include "endian_utils.h" #include "transaction_manager.h" #include diff --git a/endian.cc b/endian_utils.cc similarity index 97% rename from endian.cc rename to endian_utils.cc index 797edcc..6e7b76a 100644 --- a/endian.cc +++ b/endian_utils.cc @@ -1,4 +1,4 @@ -#include "endian.h" +#include "endian_utils.h" using namespace base; diff --git a/endian.h b/endian_utils.h similarity index 100% rename from endian.h rename to endian_utils.h diff --git a/math.h b/math_utils.h similarity index 100% rename from math.h rename to math_utils.h diff --git a/metadata.h b/metadata.h index 332018a..c46a362 100644 --- a/metadata.h +++ b/metadata.h @@ -4,7 +4,7 @@ #include "block.h" #include "transaction_manager.h" #include "btree.h" -#include "endian.h" +#include "endian_utils.h" #include "metadata_disk_structures.h" #include @@ -119,11 +119,7 @@ namespace thin_provisioning { public: typedef boost::shared_ptr ptr; - metadata(transaction_manager::ptr tm, - block_address superblock, - sector_t data_block_size, - block_address nr_data_blocks, - bool create); + metadata(std::string const &dev_path); ~metadata(); void commit(); @@ -162,7 +158,9 @@ namespace thin_provisioning { typedef persistent_data::btree<1, block_traits, MD_BLOCK_SIZE> single_mapping_tree; 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_; detail_tree details_; dev_tree mappings_top_level_; diff --git a/metadata_disk_structures.cc b/metadata_disk_structures.cc index 1dff20a..ce14290 100644 --- a/metadata_disk_structures.cc +++ b/metadata_disk_structures.cc @@ -9,7 +9,6 @@ using namespace thin_provisioning; void device_details_traits::unpack(device_details_disk const &disk, device_details &value) { - value.dev_size_ = to_cpu(disk.dev_size_); value.mapped_blocks_ = to_cpu(disk.mapped_blocks_); value.transaction_id_ = to_cpu(disk.transaction_id_); value.creation_time_ = to_cpu(disk.creation_time_); @@ -19,7 +18,6 @@ device_details_traits::unpack(device_details_disk const &disk, device_details &v void 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.transaction_id_ = to_disk<__le64>(value.transaction_id_); disk.creation_time_ = to_disk<__le32>(value.creation_time_); diff --git a/metadata_disk_structures.h b/metadata_disk_structures.h index 089b9d6..5e1efd8 100644 --- a/metadata_disk_structures.h +++ b/metadata_disk_structures.h @@ -1,7 +1,7 @@ #ifndef METADATA_DISK_STRUCTURES_H #define METADATA_DISK_STRUCTURES_H -#include "endian.h" +#include "endian_utils.h" #include "btree.h" //---------------------------------------------------------------- @@ -10,7 +10,6 @@ namespace thin_provisioning { using namespace base; // FIXME: don't use namespaces in headers. struct device_details_disk { - __le64 dev_size_; __le64 mapped_blocks_; __le64 transaction_id_; /* when created */ __le32 creation_time_; @@ -18,7 +17,6 @@ namespace thin_provisioning { } __attribute__ ((packed)); struct device_details { - uint64_t dev_size_; uint64_t mapped_blocks_; uint64_t transaction_id_; /* when created */ uint32_t creation_time_; diff --git a/space_map_disk.cc b/space_map_disk.cc deleted file mode 100644 index cab39f9..0000000 --- a/space_map_disk.cc +++ /dev/null @@ -1,7 +0,0 @@ -#include "space_map_disk.h" - - -//---------------------------------------------------------------- - - -//---------------------------------------------------------------- diff --git a/space_map_disk.h b/space_map_disk.h index fc52816..04a0d72 100644 --- a/space_map_disk.h +++ b/space_map_disk.h @@ -3,9 +3,9 @@ #include "space_map.h" #include "transaction_manager.h" -#include "endian.h" +#include "endian_utils.h" #include "space_map_disk_structures.h" -#include "math.h" +#include "math_utils.h" //---------------------------------------------------------------- diff --git a/space_map_disk_structures.h b/space_map_disk_structures.h index 54f688d..f36a1b4 100644 --- a/space_map_disk_structures.h +++ b/space_map_disk_structures.h @@ -1,7 +1,7 @@ #ifndef SPACE_MAP_DISK_STRUCTURES_H #define SPACE_MAP_DISK_STRUCTURES_H -#include "endian.h" +#include "endian_utils.h" #include "btree.h" //---------------------------------------------------------------- diff --git a/block_t.cc b/unit-tests/block_t.cc similarity index 100% rename from block_t.cc rename to unit-tests/block_t.cc diff --git a/btree_t.cc b/unit-tests/btree_t.cc similarity index 100% rename from btree_t.cc rename to unit-tests/btree_t.cc diff --git a/endian_t.cc b/unit-tests/endian_t.cc similarity index 100% rename from endian_t.cc rename to unit-tests/endian_t.cc diff --git a/metadata_t.cc b/unit-tests/metadata_t.cc similarity index 100% rename from metadata_t.cc rename to unit-tests/metadata_t.cc diff --git a/space_map_disk_t.cc b/unit-tests/space_map_disk_t.cc similarity index 100% rename from space_map_disk_t.cc rename to unit-tests/space_map_disk_t.cc diff --git a/space_map_t.cc b/unit-tests/space_map_t.cc similarity index 100% rename from space_map_t.cc rename to unit-tests/space_map_t.cc diff --git a/transaction_manager_t.cc b/unit-tests/transaction_manager_t.cc similarity index 100% rename from transaction_manager_t.cc rename to unit-tests/transaction_manager_t.cc