From 0c851fa452f829fe40475b0224a20a9fb689b020 Mon Sep 17 00:00:00 2001 From: Sebastian Messmer Date: Tue, 17 Feb 2015 00:23:33 +0100 Subject: [PATCH] Switch to biicode --- .gitignore | 2 - CMakeLists.txt | 99 +++++++++++++++++++ biicode.conf | 48 +++++++++ .../inmemory/InMemoryBlock.cpp | 5 +- .../inmemory/InMemoryBlock.h | 4 +- .../inmemory/InMemoryBlockStore.cpp | 5 +- .../inmemory/InMemoryBlockStore.h | 4 +- .../ondisk/FileAlreadyExistsException.cpp | 2 +- .../ondisk/FileAlreadyExistsException.h | 0 .../ondisk/OnDiskBlock.cpp | 8 +- .../ondisk/OnDiskBlock.h | 6 +- .../ondisk/OnDiskBlockStore.cpp | 4 +- .../ondisk/OnDiskBlockStore.h | 4 +- .../testfake/FakeBlock.cpp | 4 +- .../testfake/FakeBlock.h | 6 +- .../testfake/FakeBlockStore.cpp | 4 +- .../testfake/FakeBlockStore.h | 6 +- .../interface => interface}/Block.h | 2 +- .../interface => interface}/BlockStore.h | 2 +- .../helpers/BlockStoreWithRandomKeys.cpp | 2 +- .../helpers/BlockStoreWithRandomKeys.h | 4 +- src/blockstore/CMakeLists.txt | 3 - src/blockstore/implementations/CMakeLists.txt | 3 - .../implementations/inmemory/CMakeLists.txt | 3 - .../implementations/ondisk/CMakeLists.txt | 3 - .../implementations/testfake/CMakeLists.txt | 3 - src/blockstore/interface/CMakeLists.txt | 1 - src/blockstore/utils/CMakeLists.txt | 3 - .../inmemory/InMemoryBlockStoreTest.cpp | 10 +- .../ondisk/OnDiskBlockStoreTest.cpp | 14 ++- .../OnDiskBlockTest/OnDiskBlockCreateTest.cpp | 14 +-- .../OnDiskBlockTest/OnDiskBlockFlushTest.cpp | 15 +-- .../OnDiskBlockTest/OnDiskBlockLoadTest.cpp | 17 ++-- .../testfake/TestFakeBlockStoreTest.cpp | 10 +- .../interface/BlockStoreTest.cpp | 2 +- .../interface/BlockTest.cpp | 2 +- .../helpers/BlockStoreWithRandomKeysTest.cpp | 6 +- test/main.cpp | 6 ++ .../testutils/BlockStoreTest.h | 8 +- .../testutils/BlockStoreWithRandomKeysTest.h | 7 +- .../testutils/DataBlockFixture.cpp | 2 +- .../testutils/DataBlockFixture.h | 0 .../utils/BlockStoreUtilsTest.cpp | 9 +- .../blockstore => test}/utils/DataTest.cpp | 14 ++- .../blockstore => test}/utils/KeyTest.cpp | 8 +- .../utils => utils}/BlockStoreUtils.cpp | 5 +- .../utils => utils}/BlockStoreUtils.h | 0 {src/blockstore/utils => utils}/Data.cpp | 6 +- {src/blockstore/utils => utils}/Data.h | 4 +- .../FileDoesntExistException.cpp | 2 +- .../FileDoesntExistException.h | 0 {src/blockstore/utils => utils}/Key.cpp | 7 +- {src/blockstore/utils => utils}/Key.h | 0 53 files changed, 276 insertions(+), 132 deletions(-) delete mode 100644 .gitignore create mode 100644 CMakeLists.txt create mode 100644 biicode.conf rename {src/blockstore/implementations => implementations}/inmemory/InMemoryBlock.cpp (81%) rename {src/blockstore/implementations => implementations}/inmemory/InMemoryBlock.h (85%) rename {src/blockstore/implementations => implementations}/inmemory/InMemoryBlockStore.cpp (84%) rename {src/blockstore/implementations => implementations}/inmemory/InMemoryBlockStore.h (83%) rename {src/blockstore/implementations => implementations}/ondisk/FileAlreadyExistsException.cpp (81%) rename {src/blockstore/implementations => implementations}/ondisk/FileAlreadyExistsException.h (100%) rename {src/blockstore/implementations => implementations}/ondisk/OnDiskBlock.cpp (87%) rename {src/blockstore/implementations => implementations}/ondisk/OnDiskBlock.h (88%) rename {src/blockstore/implementations => implementations}/ondisk/OnDiskBlockStore.cpp (81%) rename {src/blockstore/implementations => implementations}/ondisk/OnDiskBlockStore.h (84%) rename {src/blockstore/implementations => implementations}/testfake/FakeBlock.cpp (82%) rename {src/blockstore/implementations => implementations}/testfake/FakeBlock.h (83%) rename {src/blockstore/implementations => implementations}/testfake/FakeBlockStore.cpp (90%) rename {src/blockstore/implementations => implementations}/testfake/FakeBlockStore.h (94%) rename {src/blockstore/interface => interface}/Block.h (91%) rename {src/blockstore/interface => interface}/BlockStore.h (93%) rename {src/blockstore/interface => interface}/helpers/BlockStoreWithRandomKeys.cpp (83%) rename {src/blockstore/interface => interface}/helpers/BlockStoreWithRandomKeys.h (89%) delete mode 100644 src/blockstore/CMakeLists.txt delete mode 100644 src/blockstore/implementations/CMakeLists.txt delete mode 100644 src/blockstore/implementations/inmemory/CMakeLists.txt delete mode 100644 src/blockstore/implementations/ondisk/CMakeLists.txt delete mode 100644 src/blockstore/implementations/testfake/CMakeLists.txt delete mode 100644 src/blockstore/interface/CMakeLists.txt delete mode 100644 src/blockstore/utils/CMakeLists.txt rename {src/test/blockstore => test}/implementations/inmemory/InMemoryBlockStoreTest.cpp (71%) rename {src/test/blockstore => test}/implementations/ondisk/OnDiskBlockStoreTest.cpp (69%) rename {src/test/blockstore => test}/implementations/ondisk/OnDiskBlockTest/OnDiskBlockCreateTest.cpp (88%) rename {src/test/blockstore => test}/implementations/ondisk/OnDiskBlockTest/OnDiskBlockFlushTest.cpp (90%) rename {src/test/blockstore => test}/implementations/ondisk/OnDiskBlockTest/OnDiskBlockLoadTest.cpp (82%) rename {src/test/blockstore => test}/implementations/testfake/TestFakeBlockStoreTest.cpp (71%) rename {src/test/blockstore => test}/interface/BlockStoreTest.cpp (67%) rename {src/test/blockstore => test}/interface/BlockTest.cpp (69%) rename {src/test/blockstore => test}/interface/helpers/BlockStoreWithRandomKeysTest.cpp (96%) create mode 100644 test/main.cpp rename {src/test/blockstore => test}/testutils/BlockStoreTest.h (98%) rename {src/test/blockstore => test}/testutils/BlockStoreWithRandomKeysTest.h (94%) rename {src/test => test}/testutils/DataBlockFixture.cpp (97%) rename {src/test => test}/testutils/DataBlockFixture.h (100%) rename {src/test/blockstore => test}/utils/BlockStoreUtilsTest.cpp (88%) rename {src/test/blockstore => test}/utils/DataTest.cpp (93%) rename {src/test/blockstore => test}/utils/KeyTest.cpp (96%) rename {src/blockstore/utils => utils}/BlockStoreUtils.cpp (73%) rename {src/blockstore/utils => utils}/BlockStoreUtils.h (100%) rename {src/blockstore/utils => utils}/Data.cpp (93%) rename {src/blockstore/utils => utils}/Data.h (92%) rename {src/blockstore/utils => utils}/FileDoesntExistException.cpp (83%) rename {src/blockstore/utils => utils}/FileDoesntExistException.h (100%) rename {src/blockstore/utils => utils}/Key.cpp (91%) rename {src/blockstore/utils => utils}/Key.h (100%) diff --git a/.gitignore b/.gitignore deleted file mode 100644 index d69a93cf..00000000 --- a/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -build.debug -build.release diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 00000000..b0f7f54d --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,99 @@ +INCLUDE(messmer/cmake/tools) + +# Initializes block variables +INIT_BIICODE_BLOCK() + +SETUP_GOOGLETEST() + +# Actually create targets: EXEcutables and libraries. +ADD_BIICODE_TARGETS() + +ADD_BOOST_LOCAL(filesystem system) + +ACTIVATE_CPP14() + +# You can safely delete lines from here... + +############################################################################### +# REFERENCE # +############################################################################### +# +# This CMakeLists.txt file helps defining your block building and compiling +# To learn more about the CMake use with biicode, visit http://docs.biicode.com/c++.html +# +# ---------------------------------------------------- +# NEW FEATURE! Include cmake files from remote blocks: +# ----------------------------------------------------- +# Now you can handle cmake dependencies alike you do with c/c++: +# +# INCLUDE(user/block/myrecipe) # include myrecipe.cmake from remote user/block +# +# > EXAMPLE: Include our recipes and activate C++11 in your block (http://www.biicode.com/biicode/cmake) +# +# INCLUDE(biicode/cmake/tools) # Include tools.cmake file from "cmake" block from the "biicode" user +# ACTIVATE_CPP11(INTERFACE ${BII_BLOCK_TARGET}) +# +# Remember to run "bii find" to download out cmake tools file +# +# --------------------- +# INIT_BIICODE_BLOCK() +# --------------------- +# This function creates several helper variables as ${BII_BLOCK_NAME} and ${BII_BLOCK_USER} +# Also it loads variables from the cmake/bii_user_block_vars.cmake +# ${BII_LIB_SRC} File list to create the library +# ${BII_LIB_TYPE} Empty (default, STATIC most casess) STATIC or SHARED +# ${BII_LIB_DEPS} Dependencies to other libraries (user2_block2, user3_blockX) +# ${BII_LIB_SYSTEM_HEADERS} System linking requirements as windows.h, pthread.h, etc +# +# You can use or modify them here, for example, to add or remove files from targets based on OS +# Or use typical cmake configurations done BEFORE defining targets. Examples: +# ADD_DEFINITIONS(-DFOO) +# FIND_PACKAGE(OpenGL QUIET) +# You can add INCLUDE_DIRECTORIES here too +# +# --------------------- +# ADD_BIICODE_TARGETS() +# --------------------- +# +# This function creates the following variables: +# ${BII_BLOCK_TARGET} Interface (no files) target for convenient configuration of all +# targets in this block, as the rest of targets always depend on it +# has name in the form "user_block_interface" +# ${BII_LIB_TARGET} Target library name, usually in the form "user_block". May not exist +# if BII_LIB_SRC is empty +# ${BII_BLOCK_TARGETS} List of all targets defined in this block +# ${BII_BLOCK_EXES} List of executables targets defined in this block +# ${BII_exe_name_TARGET}: Executable target (e.g. ${BII_main_TARGET}. You can also use +# directly the name of the executable target (e.g. user_block_main) +# +# > EXAMPLE: Add include directories to all targets of this block +# +# TARGET_INCLUDE_DIRECTORIES(${BII_BLOCK_TARGET} INTERFACE myincludedir) +# +# You can add private include directories to the Lib (if existing) +# +# > EXAMPLE: Link with pthread: +# +# TARGET_LINK_LIBRARIES(${BII_BLOCK_TARGET} INTERFACE pthread) +# or link against library: +# TARGET_LINK_LIBRARIES(${BII_LIB_TARGET} PUBLIC pthread) +# or directly use the library target name: +# TARGET_LINK_LIBRARIES(user_block PUBLIC pthread) +# +# NOTE: This can be also done adding pthread to ${BII_LIB_DEPS} +# BEFORE calling ADD_BIICODE_TARGETS() +# +# > EXAMPLE: how to activate C++11 +# +# IF(APPLE) +# TARGET_COMPILE_OPTIONS(${BII_BLOCK_TARGET} INTERFACE "-std=c++11 -stdlib=libc++") +# ELSEIF (WIN32 OR UNIX) +# TARGET_COMPILE_OPTIONS(${BII_BLOCK_TARGET} INTERFACE "-std=c++11") +# ENDIF(APPLE) +# +# > EXAMPLE: Set properties to target +# +# SET_TARGET_PROPERTIES(${BII_BLOCK_TARGET} PROPERTIES COMPILE_DEFINITIONS "IOV_MAX=255") +# + + diff --git a/biicode.conf b/biicode.conf new file mode 100644 index 00000000..7664bb1d --- /dev/null +++ b/biicode.conf @@ -0,0 +1,48 @@ +# Biicode configuration file + +[requirements] + cryptopp/cryptopp: 8 + google/gmock: 2 + google/gtest: 10 + messmer/cmake: 1 + messmer/cpp-utils + messmer/tempfile + +[parent] + # The parent version of this block. Must match folder name. E.g. + # user/block # No version number means not published yet + # You can change it to publish to a different track, and change version, e.g. + # user/block(track): 7 + +[paths] + # Local directories to look for headers (within block) + # / + # include + +[dependencies] + # Manual adjust file implicit dependencies, add (+), remove (-), or overwrite (=) + # hello.h + hello_imp.cpp hello_imp2.cpp + # *.h + *.cpp + + test/main.cpp + test/*.cpp + +[mains] + # Manual adjust of files that define an executable + # !main.cpp # Do not build executable from this file + # main2.cpp # Build it (it doesnt have a main() function, but maybe it includes it) + +[hooks] + # These are defined equal to [dependencies],files names matching bii*stage*hook.py + # will be launched as python scripts at stage = {post_process, clean} + # CMakeLists.txt + bii/my_post_process1_hook.py bii_clean_hook.py + +[includes] + # Mapping of include patterns to external blocks + # hello*.h: user3/depblock # includes will be processed as user3/depblock/hello*.h + +[data] + # Manually define data files dependencies, that will be copied to bin for execution + # By default they are copied to bin/user/block/... which should be taken into account + # when loading from disk such data + # image.cpp + image.jpg # code should write open("user/block/image.jpg") + diff --git a/src/blockstore/implementations/inmemory/InMemoryBlock.cpp b/implementations/inmemory/InMemoryBlock.cpp similarity index 81% rename from src/blockstore/implementations/inmemory/InMemoryBlock.cpp rename to implementations/inmemory/InMemoryBlock.cpp index 1304d635..387f50ce 100644 --- a/src/blockstore/implementations/inmemory/InMemoryBlock.cpp +++ b/implementations/inmemory/InMemoryBlock.cpp @@ -1,9 +1,8 @@ -#include -#include +#include +#include #include using std::unique_ptr; -using std::make_unique; using std::make_shared; using std::istream; using std::ostream; diff --git a/src/blockstore/implementations/inmemory/InMemoryBlock.h b/implementations/inmemory/InMemoryBlock.h similarity index 85% rename from src/blockstore/implementations/inmemory/InMemoryBlock.h rename to implementations/inmemory/InMemoryBlock.h index a8e7e4e3..833eec74 100644 --- a/src/blockstore/implementations/inmemory/InMemoryBlock.h +++ b/implementations/inmemory/InMemoryBlock.h @@ -2,8 +2,8 @@ #ifndef BLOCKSTORE_IMPLEMENTATIONS_INMEMORY_INMEMORYBLOCK_H_ #define BLOCKSTORE_IMPLEMENTATIONS_INMEMORY_INMEMORYBLOCK_H_ -#include -#include +#include +#include namespace blockstore { namespace inmemory { diff --git a/src/blockstore/implementations/inmemory/InMemoryBlockStore.cpp b/implementations/inmemory/InMemoryBlockStore.cpp similarity index 84% rename from src/blockstore/implementations/inmemory/InMemoryBlockStore.cpp rename to implementations/inmemory/InMemoryBlockStore.cpp index a9f5242b..feea58dd 100644 --- a/src/blockstore/implementations/inmemory/InMemoryBlockStore.cpp +++ b/implementations/inmemory/InMemoryBlockStore.cpp @@ -1,5 +1,6 @@ -#include -#include +#include +#include +#include using std::unique_ptr; using std::make_unique; diff --git a/src/blockstore/implementations/inmemory/InMemoryBlockStore.h b/implementations/inmemory/InMemoryBlockStore.h similarity index 83% rename from src/blockstore/implementations/inmemory/InMemoryBlockStore.h rename to implementations/inmemory/InMemoryBlockStore.h index 59450387..3531534a 100644 --- a/src/blockstore/implementations/inmemory/InMemoryBlockStore.h +++ b/implementations/inmemory/InMemoryBlockStore.h @@ -2,8 +2,8 @@ #ifndef BLOCKSTORE_IMPLEMENTATIONS_INMEMORY_INMEMORYBLOCKSTORE_H_ #define BLOCKSTORE_IMPLEMENTATIONS_INMEMORY_INMEMORYBLOCKSTORE_H_ -#include -#include "fspp/utils/macros.h" +#include +#include #include #include diff --git a/src/blockstore/implementations/ondisk/FileAlreadyExistsException.cpp b/implementations/ondisk/FileAlreadyExistsException.cpp similarity index 81% rename from src/blockstore/implementations/ondisk/FileAlreadyExistsException.cpp rename to implementations/ondisk/FileAlreadyExistsException.cpp index 70aa369e..5040ec78 100644 --- a/src/blockstore/implementations/ondisk/FileAlreadyExistsException.cpp +++ b/implementations/ondisk/FileAlreadyExistsException.cpp @@ -1,4 +1,4 @@ -#include +#include namespace bf = boost::filesystem; diff --git a/src/blockstore/implementations/ondisk/FileAlreadyExistsException.h b/implementations/ondisk/FileAlreadyExistsException.h similarity index 100% rename from src/blockstore/implementations/ondisk/FileAlreadyExistsException.h rename to implementations/ondisk/FileAlreadyExistsException.h diff --git a/src/blockstore/implementations/ondisk/OnDiskBlock.cpp b/implementations/ondisk/OnDiskBlock.cpp similarity index 87% rename from src/blockstore/implementations/ondisk/OnDiskBlock.cpp rename to implementations/ondisk/OnDiskBlock.cpp index 3233100c..0ab18d74 100644 --- a/src/blockstore/implementations/ondisk/OnDiskBlock.cpp +++ b/implementations/ondisk/OnDiskBlock.cpp @@ -1,10 +1,10 @@ -#include -#include -#include -#include #include #include #include +#include +#include +#include +#include using std::unique_ptr; using std::make_unique; diff --git a/src/blockstore/implementations/ondisk/OnDiskBlock.h b/implementations/ondisk/OnDiskBlock.h similarity index 88% rename from src/blockstore/implementations/ondisk/OnDiskBlock.h rename to implementations/ondisk/OnDiskBlock.h index 0e74d095..ce4aaf2f 100644 --- a/src/blockstore/implementations/ondisk/OnDiskBlock.h +++ b/implementations/ondisk/OnDiskBlock.h @@ -2,12 +2,12 @@ #ifndef BLOCKSTORE_IMPLEMENTATIONS_ONDISK_ONDISKBLOCK_H_ #define BLOCKSTORE_IMPLEMENTATIONS_ONDISK_ONDISKBLOCK_H_ -#include -#include #include +#include +#include #include -#include "fspp/utils/macros.h" +#include "messmer/cpp-utils/macros.h" namespace blockstore { namespace ondisk { diff --git a/src/blockstore/implementations/ondisk/OnDiskBlockStore.cpp b/implementations/ondisk/OnDiskBlockStore.cpp similarity index 81% rename from src/blockstore/implementations/ondisk/OnDiskBlockStore.cpp rename to implementations/ondisk/OnDiskBlockStore.cpp index d538a703..4c60b291 100644 --- a/src/blockstore/implementations/ondisk/OnDiskBlockStore.cpp +++ b/implementations/ondisk/OnDiskBlockStore.cpp @@ -1,5 +1,5 @@ -#include -#include +#include +#include using std::unique_ptr; using std::make_unique; diff --git a/src/blockstore/implementations/ondisk/OnDiskBlockStore.h b/implementations/ondisk/OnDiskBlockStore.h similarity index 84% rename from src/blockstore/implementations/ondisk/OnDiskBlockStore.h rename to implementations/ondisk/OnDiskBlockStore.h index 2113c956..92af8ed7 100644 --- a/src/blockstore/implementations/ondisk/OnDiskBlockStore.h +++ b/implementations/ondisk/OnDiskBlockStore.h @@ -2,10 +2,10 @@ #ifndef BLOCKSTORE_IMPLEMENTATIONS_ONDISK_ONDISKBLOCKSTORE_H_ #define BLOCKSTORE_IMPLEMENTATIONS_ONDISK_ONDISKBLOCKSTORE_H_ -#include #include +#include -#include "fspp/utils/macros.h" +#include "messmer/cpp-utils/macros.h" #include diff --git a/src/blockstore/implementations/testfake/FakeBlock.cpp b/implementations/testfake/FakeBlock.cpp similarity index 82% rename from src/blockstore/implementations/testfake/FakeBlock.cpp rename to implementations/testfake/FakeBlock.cpp index d86b546d..4dc2949e 100644 --- a/src/blockstore/implementations/testfake/FakeBlock.cpp +++ b/implementations/testfake/FakeBlock.cpp @@ -1,5 +1,5 @@ -#include "FakeBlock.h" -#include "FakeBlockStore.h" +#include +#include #include using std::unique_ptr; diff --git a/src/blockstore/implementations/testfake/FakeBlock.h b/implementations/testfake/FakeBlock.h similarity index 83% rename from src/blockstore/implementations/testfake/FakeBlock.h rename to implementations/testfake/FakeBlock.h index dda06c9b..97ac5c18 100644 --- a/src/blockstore/implementations/testfake/FakeBlock.h +++ b/implementations/testfake/FakeBlock.h @@ -2,10 +2,10 @@ #ifndef BLOCKSTORE_IMPLEMENTATIONS_INMEMORY_INMEMORYBLOCK_H_ #define BLOCKSTORE_IMPLEMENTATIONS_INMEMORY_INMEMORYBLOCK_H_ -#include -#include +#include +#include "../../utils/Data.h" -#include "fspp/utils/macros.h" +#include "messmer/cpp-utils/macros.h" namespace blockstore { namespace testfake { diff --git a/src/blockstore/implementations/testfake/FakeBlockStore.cpp b/implementations/testfake/FakeBlockStore.cpp similarity index 90% rename from src/blockstore/implementations/testfake/FakeBlockStore.cpp rename to implementations/testfake/FakeBlockStore.cpp index bd5d9c6e..35356268 100644 --- a/src/blockstore/implementations/testfake/FakeBlockStore.cpp +++ b/implementations/testfake/FakeBlockStore.cpp @@ -1,5 +1,5 @@ -#include "FakeBlockStore.h" -#include "FakeBlock.h" +#include +#include using std::unique_ptr; using std::make_unique; diff --git a/src/blockstore/implementations/testfake/FakeBlockStore.h b/implementations/testfake/FakeBlockStore.h similarity index 94% rename from src/blockstore/implementations/testfake/FakeBlockStore.h rename to implementations/testfake/FakeBlockStore.h index 096c030b..bb3c022f 100644 --- a/src/blockstore/implementations/testfake/FakeBlockStore.h +++ b/implementations/testfake/FakeBlockStore.h @@ -2,9 +2,9 @@ #ifndef BLOCKSTORE_IMPLEMENTATIONS_INMEMORY_INMEMORYBLOCKSTORE_H_ #define BLOCKSTORE_IMPLEMENTATIONS_INMEMORY_INMEMORYBLOCKSTORE_H_ -#include -#include "blockstore/utils/Data.h" -#include "fspp/utils/macros.h" +#include +#include "../../utils/Data.h" +#include "messmer/cpp-utils/macros.h" #include #include diff --git a/src/blockstore/interface/Block.h b/interface/Block.h similarity index 91% rename from src/blockstore/interface/Block.h rename to interface/Block.h index 5e51e781..18794a35 100644 --- a/src/blockstore/interface/Block.h +++ b/interface/Block.h @@ -2,8 +2,8 @@ #ifndef BLOCKSTORE_INTERFACE_BLOCK_H_ #define BLOCKSTORE_INTERFACE_BLOCK_H_ +#include #include -#include "blockstore/utils/Key.h" namespace blockstore { diff --git a/src/blockstore/interface/BlockStore.h b/interface/BlockStore.h similarity index 93% rename from src/blockstore/interface/BlockStore.h rename to interface/BlockStore.h index 1d87d832..0585c76f 100644 --- a/src/blockstore/interface/BlockStore.h +++ b/interface/BlockStore.h @@ -2,7 +2,7 @@ #ifndef FSPP_BLOCKSTORE_BLOCKSTORE_H_ #define FSPP_BLOCKSTORE_BLOCKSTORE_H_ -#include +#include #include #include diff --git a/src/blockstore/interface/helpers/BlockStoreWithRandomKeys.cpp b/interface/helpers/BlockStoreWithRandomKeys.cpp similarity index 83% rename from src/blockstore/interface/helpers/BlockStoreWithRandomKeys.cpp rename to interface/helpers/BlockStoreWithRandomKeys.cpp index 8962c63c..d056bcd5 100644 --- a/src/blockstore/interface/helpers/BlockStoreWithRandomKeys.cpp +++ b/interface/helpers/BlockStoreWithRandomKeys.cpp @@ -1,4 +1,4 @@ -#include +#include using namespace blockstore; diff --git a/src/blockstore/interface/helpers/BlockStoreWithRandomKeys.h b/interface/helpers/BlockStoreWithRandomKeys.h similarity index 89% rename from src/blockstore/interface/helpers/BlockStoreWithRandomKeys.h rename to interface/helpers/BlockStoreWithRandomKeys.h index 05d639bb..9e414aec 100644 --- a/src/blockstore/interface/helpers/BlockStoreWithRandomKeys.h +++ b/interface/helpers/BlockStoreWithRandomKeys.h @@ -2,8 +2,8 @@ #ifndef FSPP_BLOCKSTORE_BLOCKSTOREWITHRANDOMKEYS_H_ #define FSPP_BLOCKSTORE_BLOCKSTOREWITHRANDOMKEYS_H_ -#include -#include +#include +#include "../Block.h" namespace blockstore { diff --git a/src/blockstore/CMakeLists.txt b/src/blockstore/CMakeLists.txt deleted file mode 100644 index d4f05ddd..00000000 --- a/src/blockstore/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -add_subdirectory(interface) -add_subdirectory(utils) -add_subdirectory(implementations) diff --git a/src/blockstore/implementations/CMakeLists.txt b/src/blockstore/implementations/CMakeLists.txt deleted file mode 100644 index 608fd1e6..00000000 --- a/src/blockstore/implementations/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -add_subdirectory(ondisk) -add_subdirectory(inmemory) -add_subdirectory(testfake) \ No newline at end of file diff --git a/src/blockstore/implementations/inmemory/CMakeLists.txt b/src/blockstore/implementations/inmemory/CMakeLists.txt deleted file mode 100644 index 3b66b10d..00000000 --- a/src/blockstore/implementations/inmemory/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -add_library(blockstore_inmemory InMemoryBlock.cpp InMemoryBlockStore.cpp) - -target_link_libraries(blockstore_inmemory blockstore_interface blockstore_utils) diff --git a/src/blockstore/implementations/ondisk/CMakeLists.txt b/src/blockstore/implementations/ondisk/CMakeLists.txt deleted file mode 100644 index f907eb78..00000000 --- a/src/blockstore/implementations/ondisk/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -add_library(blockstore_ondisk OnDiskBlock.cpp OnDiskBlockStore.cpp FileAlreadyExistsException.cpp) - -target_link_libraries(blockstore_ondisk blockstore_interface blockstore_utils boost_filesystem boost_system) diff --git a/src/blockstore/implementations/testfake/CMakeLists.txt b/src/blockstore/implementations/testfake/CMakeLists.txt deleted file mode 100644 index e3dddf05..00000000 --- a/src/blockstore/implementations/testfake/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -add_library(blockstore_testfake FakeBlock.cpp FakeBlockStore.cpp) - -target_link_libraries(blockstore_testfake blockstore_interface blockstore_utils) diff --git a/src/blockstore/interface/CMakeLists.txt b/src/blockstore/interface/CMakeLists.txt deleted file mode 100644 index 98e1c3cb..00000000 --- a/src/blockstore/interface/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -add_library(blockstore_interface helpers/BlockStoreWithRandomKeys.cpp) diff --git a/src/blockstore/utils/CMakeLists.txt b/src/blockstore/utils/CMakeLists.txt deleted file mode 100644 index 1a62b338..00000000 --- a/src/blockstore/utils/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -add_library(blockstore_utils Data.cpp Key.cpp FileDoesntExistException.cpp BlockStoreUtils.cpp) - -target_link_libraries(blockstore_utils cryptopp) diff --git a/src/test/blockstore/implementations/inmemory/InMemoryBlockStoreTest.cpp b/test/implementations/inmemory/InMemoryBlockStoreTest.cpp similarity index 71% rename from src/test/blockstore/implementations/inmemory/InMemoryBlockStoreTest.cpp rename to test/implementations/inmemory/InMemoryBlockStoreTest.cpp index b6d37261..0d6e8db8 100644 --- a/src/test/blockstore/implementations/inmemory/InMemoryBlockStoreTest.cpp +++ b/test/implementations/inmemory/InMemoryBlockStoreTest.cpp @@ -1,8 +1,8 @@ -#include -#include -#include -#include -#include "gtest/gtest.h" +#include +#include +#include +#include +#include "google/gtest/gtest.h" using blockstore::BlockStore; diff --git a/src/test/blockstore/implementations/ondisk/OnDiskBlockStoreTest.cpp b/test/implementations/ondisk/OnDiskBlockStoreTest.cpp similarity index 69% rename from src/test/blockstore/implementations/ondisk/OnDiskBlockStoreTest.cpp rename to test/implementations/ondisk/OnDiskBlockStoreTest.cpp index a6ee4195..48343f9d 100644 --- a/src/test/blockstore/implementations/ondisk/OnDiskBlockStoreTest.cpp +++ b/test/implementations/ondisk/OnDiskBlockStoreTest.cpp @@ -1,8 +1,10 @@ -#include -#include -#include -#include -#include "gtest/gtest.h" +#include +#include +#include +#include +#include "google/gtest/gtest.h" + +#include "messmer/tempfile/src/TempDir.h" using blockstore::BlockStore; @@ -12,6 +14,8 @@ using blockstore::ondisk::OnDiskBlockStore; using std::unique_ptr; using std::make_unique; +using tempfile::TempDir; + class OnDiskBlockStoreTestFixture: public BlockStoreTestFixture { public: unique_ptr createBlockStore() override { diff --git a/src/test/blockstore/implementations/ondisk/OnDiskBlockTest/OnDiskBlockCreateTest.cpp b/test/implementations/ondisk/OnDiskBlockTest/OnDiskBlockCreateTest.cpp similarity index 88% rename from src/test/blockstore/implementations/ondisk/OnDiskBlockTest/OnDiskBlockCreateTest.cpp rename to test/implementations/ondisk/OnDiskBlockTest/OnDiskBlockCreateTest.cpp index 908d7e7c..b6a69b5a 100644 --- a/src/test/blockstore/implementations/ondisk/OnDiskBlockTest/OnDiskBlockCreateTest.cpp +++ b/test/implementations/ondisk/OnDiskBlockTest/OnDiskBlockCreateTest.cpp @@ -1,14 +1,17 @@ -#include -#include -#include "gtest/gtest.h" +#include +#include +#include "google/gtest/gtest.h" -#include "test/testutils/TempFile.h" -#include "test/testutils/TempDir.h" +#include "messmer/tempfile/src/TempFile.h" +#include "messmer/tempfile/src/TempDir.h" using ::testing::Test; using ::testing::WithParamInterface; using ::testing::Values; +using tempfile::TempFile; +using tempfile::TempDir; + using std::unique_ptr; using namespace blockstore; @@ -60,7 +63,6 @@ public: INSTANTIATE_TEST_CASE_P(OnDiskBlockCreateSizeTest, OnDiskBlockCreateSizeTest, Values(0, 1, 5, 1024, 10*1024*1024)); TEST_P(OnDiskBlockCreateSizeTest, OnDiskSizeIsCorrect) { - printf((std::string()+file.path().c_str()+"\n").c_str()); Data fileContent = Data::LoadFromFile(file.path()); EXPECT_EQ(GetParam(), fileContent.size()); } diff --git a/src/test/blockstore/implementations/ondisk/OnDiskBlockTest/OnDiskBlockFlushTest.cpp b/test/implementations/ondisk/OnDiskBlockTest/OnDiskBlockFlushTest.cpp similarity index 90% rename from src/test/blockstore/implementations/ondisk/OnDiskBlockTest/OnDiskBlockFlushTest.cpp rename to test/implementations/ondisk/OnDiskBlockTest/OnDiskBlockFlushTest.cpp index 8c52674c..93668491 100644 --- a/src/test/blockstore/implementations/ondisk/OnDiskBlockTest/OnDiskBlockFlushTest.cpp +++ b/test/implementations/ondisk/OnDiskBlockTest/OnDiskBlockFlushTest.cpp @@ -1,15 +1,18 @@ -#include -#include -#include -#include "gtest/gtest.h" +#include +#include +#include +#include "google/gtest/gtest.h" -#include "test/testutils/TempFile.h" -#include "test/testutils/TempDir.h" +#include "messmer/tempfile/src/TempFile.h" +#include "messmer/tempfile/src/TempDir.h" using ::testing::Test; using ::testing::WithParamInterface; using ::testing::Values; +using tempfile::TempFile; +using tempfile::TempDir; + using std::unique_ptr; using namespace blockstore; diff --git a/src/test/blockstore/implementations/ondisk/OnDiskBlockTest/OnDiskBlockLoadTest.cpp b/test/implementations/ondisk/OnDiskBlockTest/OnDiskBlockLoadTest.cpp similarity index 82% rename from src/test/blockstore/implementations/ondisk/OnDiskBlockTest/OnDiskBlockLoadTest.cpp rename to test/implementations/ondisk/OnDiskBlockTest/OnDiskBlockLoadTest.cpp index b191c3ec..a97c905b 100644 --- a/src/test/blockstore/implementations/ondisk/OnDiskBlockTest/OnDiskBlockLoadTest.cpp +++ b/test/implementations/ondisk/OnDiskBlockTest/OnDiskBlockLoadTest.cpp @@ -1,17 +1,20 @@ -#include -#include -#include -#include -#include "gtest/gtest.h" +#include +#include +#include +#include "google/gtest/gtest.h" -#include "test/testutils/TempFile.h" -#include "test/testutils/TempDir.h" +#include "../../../../utils/Data.h" +#include "messmer/tempfile/src/TempFile.h" +#include "messmer/tempfile/src/TempDir.h" #include using ::testing::Test; using ::testing::WithParamInterface; using ::testing::Values; +using tempfile::TempFile; +using tempfile::TempDir; + using std::ofstream; using std::unique_ptr; using std::ios; diff --git a/src/test/blockstore/implementations/testfake/TestFakeBlockStoreTest.cpp b/test/implementations/testfake/TestFakeBlockStoreTest.cpp similarity index 71% rename from src/test/blockstore/implementations/testfake/TestFakeBlockStoreTest.cpp rename to test/implementations/testfake/TestFakeBlockStoreTest.cpp index ec1de72c..c160e75c 100644 --- a/src/test/blockstore/implementations/testfake/TestFakeBlockStoreTest.cpp +++ b/test/implementations/testfake/TestFakeBlockStoreTest.cpp @@ -1,8 +1,8 @@ -#include -#include -#include -#include -#include "gtest/gtest.h" +#include +#include +#include +#include +#include "google/gtest/gtest.h" using blockstore::BlockStore; diff --git a/src/test/blockstore/interface/BlockStoreTest.cpp b/test/interface/BlockStoreTest.cpp similarity index 67% rename from src/test/blockstore/interface/BlockStoreTest.cpp rename to test/interface/BlockStoreTest.cpp index 23a03496..fd069e97 100644 --- a/src/test/blockstore/interface/BlockStoreTest.cpp +++ b/test/interface/BlockStoreTest.cpp @@ -1,4 +1,4 @@ /* * Tests that the header can be included without needing additional header includes as dependencies. */ -#include +#include diff --git a/src/test/blockstore/interface/BlockTest.cpp b/test/interface/BlockTest.cpp similarity index 69% rename from src/test/blockstore/interface/BlockTest.cpp rename to test/interface/BlockTest.cpp index bf85aad0..8a546609 100644 --- a/src/test/blockstore/interface/BlockTest.cpp +++ b/test/interface/BlockTest.cpp @@ -1,4 +1,4 @@ /* * Tests that the header can be included without needing additional header includes as dependencies. */ -#include +#include diff --git a/src/test/blockstore/interface/helpers/BlockStoreWithRandomKeysTest.cpp b/test/interface/helpers/BlockStoreWithRandomKeysTest.cpp similarity index 96% rename from src/test/blockstore/interface/helpers/BlockStoreWithRandomKeysTest.cpp rename to test/interface/helpers/BlockStoreWithRandomKeysTest.cpp index f2c192a0..f7c4f350 100644 --- a/src/test/blockstore/interface/helpers/BlockStoreWithRandomKeysTest.cpp +++ b/test/interface/helpers/BlockStoreWithRandomKeysTest.cpp @@ -1,6 +1,6 @@ -#include -#include -#include +#include +#include "google/gtest/gtest.h" +#include "google/gmock/gmock.h" using ::testing::Test; diff --git a/test/main.cpp b/test/main.cpp new file mode 100644 index 00000000..f7a14877 --- /dev/null +++ b/test/main.cpp @@ -0,0 +1,6 @@ +#include "google/gtest/gtest.h" + +int main(int argc, char **argv) { + testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} diff --git a/src/test/blockstore/testutils/BlockStoreTest.h b/test/testutils/BlockStoreTest.h similarity index 98% rename from src/test/blockstore/testutils/BlockStoreTest.h rename to test/testutils/BlockStoreTest.h index b92cad31..2884648f 100644 --- a/src/test/blockstore/testutils/BlockStoreTest.h +++ b/test/testutils/BlockStoreTest.h @@ -2,9 +2,11 @@ #ifndef TEST_BLOCKSTORE_IMPLEMENTATIONS_TESTUTILS_BLOCKSTORETEST_H_ #define TEST_BLOCKSTORE_IMPLEMENTATIONS_TESTUTILS_BLOCKSTORETEST_H_ -#include -#include -#include "test/testutils/TempDir.h" +#include "google/gtest/gtest.h" + +#include "DataBlockFixture.h" + +#include "../../interface/BlockStore.h" class BlockStoreTestFixture { public: diff --git a/src/test/blockstore/testutils/BlockStoreWithRandomKeysTest.h b/test/testutils/BlockStoreWithRandomKeysTest.h similarity index 94% rename from src/test/blockstore/testutils/BlockStoreWithRandomKeysTest.h rename to test/testutils/BlockStoreWithRandomKeysTest.h index 2dc16313..23301aaf 100644 --- a/src/test/blockstore/testutils/BlockStoreWithRandomKeysTest.h +++ b/test/testutils/BlockStoreWithRandomKeysTest.h @@ -2,11 +2,10 @@ #ifndef TEST_BLOCKSTORE_IMPLEMENTATIONS_TESTUTILS_BLOCKSTOREWITHRANDOMKEYSTEST_H_ #define TEST_BLOCKSTORE_IMPLEMENTATIONS_TESTUTILS_BLOCKSTOREWITHRANDOMKEYSTEST_H_ -#include +#include +#include -#include -#include -#include "test/testutils/TempDir.h" +#include "../../interface/BlockStore.h" class BlockStoreWithRandomKeysTestFixture { public: diff --git a/src/test/testutils/DataBlockFixture.cpp b/test/testutils/DataBlockFixture.cpp similarity index 97% rename from src/test/testutils/DataBlockFixture.cpp rename to test/testutils/DataBlockFixture.cpp index ec50b91c..5fdb3a0a 100644 --- a/src/test/testutils/DataBlockFixture.cpp +++ b/test/testutils/DataBlockFixture.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include diff --git a/src/test/testutils/DataBlockFixture.h b/test/testutils/DataBlockFixture.h similarity index 100% rename from src/test/testutils/DataBlockFixture.h rename to test/testutils/DataBlockFixture.h diff --git a/src/test/blockstore/utils/BlockStoreUtilsTest.cpp b/test/utils/BlockStoreUtilsTest.cpp similarity index 88% rename from src/test/blockstore/utils/BlockStoreUtilsTest.cpp rename to test/utils/BlockStoreUtilsTest.cpp index 9845b696..b123e520 100644 --- a/src/test/blockstore/utils/BlockStoreUtilsTest.cpp +++ b/test/utils/BlockStoreUtilsTest.cpp @@ -1,8 +1,7 @@ -#include "gtest/gtest.h" - -#include "blockstore/implementations/testfake/FakeBlockStore.h" -#include "test/testutils/DataBlockFixture.h" -#include "blockstore/utils/BlockStoreUtils.h" +#include +#include +#include +#include "google/gtest/gtest.h" #include diff --git a/src/test/blockstore/utils/DataTest.cpp b/test/utils/DataTest.cpp similarity index 93% rename from src/test/blockstore/utils/DataTest.cpp rename to test/utils/DataTest.cpp index 4bd7f199..1c5b4542 100644 --- a/src/test/blockstore/utils/DataTest.cpp +++ b/test/utils/DataTest.cpp @@ -1,9 +1,9 @@ -#include -#include -#include -#include "gtest/gtest.h" +#include +#include +#include +#include "google/gtest/gtest.h" -#include "test/testutils/TempFile.h" +#include "messmer/tempfile/src/TempFile.h" #include @@ -11,9 +11,13 @@ using ::testing::Test; using ::testing::WithParamInterface; using ::testing::Values; +using tempfile::TempFile; + using std::ifstream; using std::ofstream; +namespace bf = boost::filesystem; + using namespace blockstore; class DataTest: public Test { diff --git a/src/test/blockstore/utils/KeyTest.cpp b/test/utils/KeyTest.cpp similarity index 96% rename from src/test/blockstore/utils/KeyTest.cpp rename to test/utils/KeyTest.cpp index 98095f6b..a5a5f3cc 100644 --- a/src/test/blockstore/utils/KeyTest.cpp +++ b/test/utils/KeyTest.cpp @@ -1,8 +1,8 @@ -#include "gtest/gtest.h" +#include +#include +#include +#include "google/gtest/gtest.h" -#include -#include "blockstore/utils/Data.h" -#include "test/testutils/DataBlockFixture.h" using ::testing::Test; using ::testing::WithParamInterface; diff --git a/src/blockstore/utils/BlockStoreUtils.cpp b/utils/BlockStoreUtils.cpp similarity index 73% rename from src/blockstore/utils/BlockStoreUtils.cpp rename to utils/BlockStoreUtils.cpp index 53671e70..2e14be50 100644 --- a/src/blockstore/utils/BlockStoreUtils.cpp +++ b/utils/BlockStoreUtils.cpp @@ -1,6 +1,5 @@ -#include -#include "blockstore/interface/BlockStore.h" - +#include +#include #include using std::unique_ptr; diff --git a/src/blockstore/utils/BlockStoreUtils.h b/utils/BlockStoreUtils.h similarity index 100% rename from src/blockstore/utils/BlockStoreUtils.h rename to utils/BlockStoreUtils.h diff --git a/src/blockstore/utils/Data.cpp b/utils/Data.cpp similarity index 93% rename from src/blockstore/utils/Data.cpp rename to utils/Data.cpp index 37bd3ff9..12ef4907 100644 --- a/src/blockstore/utils/Data.cpp +++ b/utils/Data.cpp @@ -1,7 +1,5 @@ -#include -#include -#include "FileDoesntExistException.h" - +#include +#include #include #include diff --git a/src/blockstore/utils/Data.h b/utils/Data.h similarity index 92% rename from src/blockstore/utils/Data.h rename to utils/Data.h index 29345574..6b3d341c 100644 --- a/src/blockstore/utils/Data.h +++ b/utils/Data.h @@ -3,10 +3,8 @@ #define BLOCKSTORE_IMPLEMENTATIONS_ONDISK_DATA_H_ #include -//TODO Move this to a more generic utils -#include "fspp/utils/macros.h" - #include +#include #include namespace blockstore { diff --git a/src/blockstore/utils/FileDoesntExistException.cpp b/utils/FileDoesntExistException.cpp similarity index 83% rename from src/blockstore/utils/FileDoesntExistException.cpp rename to utils/FileDoesntExistException.cpp index c65dd22a..7cca8312 100644 --- a/src/blockstore/utils/FileDoesntExistException.cpp +++ b/utils/FileDoesntExistException.cpp @@ -1,4 +1,4 @@ -#include +#include namespace bf = boost::filesystem; diff --git a/src/blockstore/utils/FileDoesntExistException.h b/utils/FileDoesntExistException.h similarity index 100% rename from src/blockstore/utils/FileDoesntExistException.h rename to utils/FileDoesntExistException.h diff --git a/src/blockstore/utils/Key.cpp b/utils/Key.cpp similarity index 91% rename from src/blockstore/utils/Key.cpp rename to utils/Key.cpp index 5cd5b205..03a024ee 100644 --- a/src/blockstore/utils/Key.cpp +++ b/utils/Key.cpp @@ -1,7 +1,8 @@ -#include +#include +#include +#include -#include -#include +#include using CryptoPP::ArraySource; using CryptoPP::ArraySink; diff --git a/src/blockstore/utils/Key.h b/utils/Key.h similarity index 100% rename from src/blockstore/utils/Key.h rename to utils/Key.h