block_t and cache_t fully operational again.
This commit is contained in:
		
							
								
								
									
										3
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							@@ -7,4 +7,5 @@ thin_dump
 | 
			
		||||
thin_restore
 | 
			
		||||
thin_repair
 | 
			
		||||
*.metadata
 | 
			
		||||
bad-metadata
 | 
			
		||||
bad-metadata
 | 
			
		||||
Makefile
 | 
			
		||||
@@ -79,6 +79,7 @@ test-programs: $(TEST_PROGRAMS)
 | 
			
		||||
 | 
			
		||||
.SUFFIXES: .d
 | 
			
		||||
 | 
			
		||||
# FIXME: not working
 | 
			
		||||
%.d: %.cc
 | 
			
		||||
	$(CXX) -MM -MT $(subst .cc,.o,$<) $(INCLUDES) $(CXXFLAGS) $< > $@.$$$$;\
 | 
			
		||||
	sed 's,\([^ :]*\)\.o[ :]*,\1.o $@ : Makefile ,g' < $@.$$$$ > $@; \
 | 
			
		||||
@@ -142,7 +143,7 @@ thin_check: $(THIN_CHECK_OBJECTS) thin-provisioning/thin_check.o
 | 
			
		||||
#	$(CXX) $(CXXFLAGS) -o $@ $+ $(LIBS)
 | 
			
		||||
 | 
			
		||||
clean:
 | 
			
		||||
	$(RM) *.o unit-tests/*.o *.d unit-tests/*.d $(TEST_PROGRAMS) $(PROGRAMS)
 | 
			
		||||
	$(RM) *.o unit-tests/*.o *.d unit-tests/*.d $(TEST_PROGRAMS) $(PROGRAMS) $(OBJECTS)
 | 
			
		||||
distclean: clean
 | 
			
		||||
	$(RM) config.cache config.log config.status configure.h version.h Makefile unit-tests/Makefile
 | 
			
		||||
.PHONY: clean distclean
 | 
			
		||||
 
 | 
			
		||||
@@ -17,16 +17,16 @@
 | 
			
		||||
# <http://www.gnu.org/licenses/>.
 | 
			
		||||
 | 
			
		||||
TEST_SOURCE=\
 | 
			
		||||
	unit-tests/cache_t.cc
 | 
			
		||||
	unit-tests/cache_t.cc \
 | 
			
		||||
	unit-tests/block_t.cc
 | 
			
		||||
 | 
			
		||||
# FIXME Make these tests work.
 | 
			
		||||
#	unit-tests/block_t.cc \
 | 
			
		||||
	unit-tests/btree_t.cc \
 | 
			
		||||
	unit-tests/endian_t.cc \
 | 
			
		||||
	unit-tests/run_list_t.cc \
 | 
			
		||||
	unit-tests/space_map_t.cc \
 | 
			
		||||
	unit-tests/space_map_disk_t.cc \
 | 
			
		||||
	unit-tests/transaction_manager_t.cc
 | 
			
		||||
# FIXME: reinstate
 | 
			
		||||
	# unit-tests/btree_t.cc \
 | 
			
		||||
	# unit-tests/endian_t.cc \
 | 
			
		||||
	# unit-tests/run_list_t.cc \
 | 
			
		||||
	# unit-tests/space_map_t.cc \
 | 
			
		||||
	# unit-tests/space_map_disk_t.cc \
 | 
			
		||||
	# unit-tests/transaction_manager_t.cc
 | 
			
		||||
 | 
			
		||||
TEST_PROGRAMS=$(subst .cc,,$(TEST_SOURCE))
 | 
			
		||||
 | 
			
		||||
@@ -35,31 +35,31 @@ unit-test: $(TEST_PROGRAMS)
 | 
			
		||||
 | 
			
		||||
.PHONY: unit-test
 | 
			
		||||
 | 
			
		||||
unit-tests/block_t: unit-tests/block_t.o
 | 
			
		||||
	g++ $(CXXFLAGS) -o $@ $+ $(LIBS)
 | 
			
		||||
unit-tests/block_t: unit-tests/block_t.o $(OBJECTS)
 | 
			
		||||
	g++ $(CXXFLAGS) $(INCLUDES) -o $@ $+ $(LIBS) $(LIBEXPAT)
 | 
			
		||||
 | 
			
		||||
unit-tests/btree_t: unit-tests/btree_t.o $(OBJECTS)
 | 
			
		||||
	g++ $(CXXFLAGS) -o $@ $+ $(LIBS) $(LIBEXPAT)
 | 
			
		||||
	g++ $(CXXFLAGS) $(INCLUDES) -o $@ $+ $(LIBS) $(LIBEXPAT)
 | 
			
		||||
 | 
			
		||||
unit-tests/cache_t: unit-tests/cache_t.o $(OBJECTS)
 | 
			
		||||
	g++ $(CXXFLAGS) -o $@ $+ $(LIBS) $(LIBEXPAT)
 | 
			
		||||
	g++ $(CXXFLAGS) $(INCLUDES) -o $@ $+ $(LIBS) $(LIBEXPAT)
 | 
			
		||||
 | 
			
		||||
unit-tests/run_list_t: unit-tests/run_list_t.o $(OBJECTS)
 | 
			
		||||
	g++ $(CXXFLAGS) -o $@ $+ $(LIBS) $(LIBEXPAT)
 | 
			
		||||
	g++ $(CXXFLAGS) $(INCLUDES) -o $@ $+ $(LIBS) $(LIBEXPAT)
 | 
			
		||||
 | 
			
		||||
unit-tests/space_map_t: unit-tests/space_map_t.o $(OBJECTS)
 | 
			
		||||
	g++ $(CXXFLAGS) -o $@ $+ $(LIBS) $(LIBEXPAT)
 | 
			
		||||
	g++ $(CXXFLAGS) $(INCLUDES) -o $@ $+ $(LIBS) $(LIBEXPAT)
 | 
			
		||||
 | 
			
		||||
unit-tests/space_map_disk_t: unit-tests/space_map_disk_t.o $(OBJECTS)
 | 
			
		||||
	g++ $(CXXFLAGS) -o $@ $+ $(LIBS) $(LIBEXPAT)
 | 
			
		||||
	g++ $(CXXFLAGS) $(INCLUDES) -o $@ $+ $(LIBS) $(LIBEXPAT)
 | 
			
		||||
 | 
			
		||||
unit-tests/transaction_manager_t: unit-tests/transaction_manager_t.o $(OBJECTS)
 | 
			
		||||
	g++ $(CXXFLAGS) -o $@ $+ $(LIBS) $(LIBEXPAT)
 | 
			
		||||
	g++ $(CXXFLAGS) $(INCLUDES) -o $@ $+ $(LIBS) $(LIBEXPAT)
 | 
			
		||||
 | 
			
		||||
unit-tests/metadata_t: unit-tests/metadata_t.o $(OBJECTS)
 | 
			
		||||
	g++ $(CXXFLAGS) -o $@ $+ $(LIBS) $(LIBEXPAT)
 | 
			
		||||
	g++ $(CXXFLAGS) $(INCLUDES) -o $@ $+ $(LIBS) $(LIBEXPAT)
 | 
			
		||||
 | 
			
		||||
unit-tests/endian_t: unit-tests/endian_t.o $(OBJECTS)
 | 
			
		||||
	g++ $(CXXFLAGS) -o $@ $+ $(LIBS) $(LIBEXPAT)
 | 
			
		||||
	g++ $(CXXFLAGS) $(INCLUDES) -o $@ $+ $(LIBS) $(LIBEXPAT)
 | 
			
		||||
 | 
			
		||||
all: $(TEST_PROGRAMS)
 | 
			
		||||
 
 | 
			
		||||
@@ -16,7 +16,7 @@
 | 
			
		||||
// with thin-provisioning-tools.  If not, see
 | 
			
		||||
// <http://www.gnu.org/licenses/>.
 | 
			
		||||
 | 
			
		||||
#include "block.h"
 | 
			
		||||
#include "persistent-data/block.h"
 | 
			
		||||
 | 
			
		||||
#define BOOST_TEST_MODULE BlockManagerTests
 | 
			
		||||
#include <boost/test/included/unit_test.hpp>
 | 
			
		||||
@@ -34,20 +34,20 @@ namespace {
 | 
			
		||||
 | 
			
		||||
	template <uint32_t BlockSize>
 | 
			
		||||
	void check_all_bytes(typename block_manager<BlockSize>::read_ref const &rr, int v) {
 | 
			
		||||
		typename block_manager<BlockSize>::const_buffer &data = rr.data();
 | 
			
		||||
		persistent_data::buffer<BlockSize> const &data = rr.data();
 | 
			
		||||
		for (unsigned b = 0; b < BlockSize; b++)
 | 
			
		||||
			BOOST_CHECK_EQUAL(data[b], v);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	template <uint32_t BlockSize>
 | 
			
		||||
	class zero_validator : public block_manager<BlockSize>::validator {
 | 
			
		||||
		void check(block_manager<4096>::const_buffer &data, block_address location) const {
 | 
			
		||||
	struct zero_validator : public block_manager<BlockSize>::validator {
 | 
			
		||||
		virtual void check(buffer<BlockSize> const &data, block_address location) const {
 | 
			
		||||
			for (unsigned b = 0; b < BlockSize; b++)
 | 
			
		||||
				if (data[b] != 0)
 | 
			
		||||
 					throw runtime_error("validator check zero");
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		void prepare(block_manager<4096>::buffer &data, block_address location) const {
 | 
			
		||||
		virtual void prepare(buffer<BlockSize> &data, block_address location) const {
 | 
			
		||||
			cerr << "zeroing" << endl;
 | 
			
		||||
			for (unsigned b = 0; b < BlockSize; b++)
 | 
			
		||||
				data[b] = 0;
 | 
			
		||||
@@ -92,7 +92,7 @@ BOOST_AUTO_TEST_CASE(writes_persist)
 | 
			
		||||
	bm4096::ptr bm = create_bm(nr);
 | 
			
		||||
	for (unsigned i = 0; i < nr; i++) {
 | 
			
		||||
		bm4096::write_ref wr = bm->write_lock(i);
 | 
			
		||||
		::memset(wr.data(), i, 4096);
 | 
			
		||||
		::memset(wr.data().raw(), i, 4096);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	for (unsigned i = 0; i < nr; i++) {
 | 
			
		||||
@@ -137,7 +137,7 @@ BOOST_AUTO_TEST_CASE(write_validator_works)
 | 
			
		||||
 | 
			
		||||
	{
 | 
			
		||||
		bm4096::write_ref wr = bm->write_lock(0, v);
 | 
			
		||||
		::memset(wr.data(), 23, sizeof(wr.data()));
 | 
			
		||||
		::memset(wr.data().raw(), 23, sizeof(wr.data().raw()));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	bm->flush();		// force the prepare method to be called
 | 
			
		||||
@@ -183,15 +183,6 @@ BOOST_AUTO_TEST_CASE(references_can_be_copied)
 | 
			
		||||
	bm4096::write_ref wr2(wr1);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#if 0
 | 
			
		||||
BOOST_AUTO_TEST_CASE(flush_throws_if_held_locks)
 | 
			
		||||
{
 | 
			
		||||
	bm4096::ptr bm = create_bm();
 | 
			
		||||
	bm4096::write_ref wr = bm->write_lock(0);
 | 
			
		||||
	BOOST_CHECK_THROW(bm->flush(), runtime_error);
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
BOOST_AUTO_TEST_CASE(no_concurrent_write_locks)
 | 
			
		||||
{
 | 
			
		||||
	bm4096::ptr bm = create_bm();
 | 
			
		||||
 
 | 
			
		||||
@@ -16,7 +16,7 @@
 | 
			
		||||
// with thin-provisioning-tools.  If not, see
 | 
			
		||||
// <http://www.gnu.org/licenses/>.
 | 
			
		||||
 | 
			
		||||
#include "cache.h"
 | 
			
		||||
#include "persistent-data/cache.h"
 | 
			
		||||
 | 
			
		||||
#define BOOST_TEST_MODULE CacheTests
 | 
			
		||||
#include <boost/test/included/unit_test.hpp>
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user