Added memgraph prefix. Fixes T160

Summary: Added memgraph prefix. Fixes T160

Test Plan: manual

Reviewers: sale

Subscribers: sale, buda

Maniphest Tasks: T160

Differential Revision: https://memgraph.phacility.com/D18
This commit is contained in:
Marko Budiselic 2016-12-16 14:05:04 +01:00
parent 9c3a79bb18
commit d158333335
12 changed files with 256 additions and 291 deletions

View File

@ -1,11 +1,11 @@
cmake_minimum_required(VERSION 3.1)
# get directory name
get_filename_component(ProjectId ${CMAKE_SOURCE_DIR} NAME)
get_filename_component(project_name ${CMAKE_SOURCE_DIR} NAME)
# replace whitespaces with underscores
string(REPLACE " " "_" ProjectId ${ProjectId})
string(REPLACE " " "_" project_name ${project_name})
# set project name
project(${ProjectId})
project(${project_name})
# setup CMake module path, defines path for include() and find_package()
# https://cmake.org/cmake/help/latest/variable/CMAKE_MODULE_PATH.html
@ -16,6 +16,7 @@ find_package(Threads REQUIRED)
# flags
# c++14
set(cxx_standard 14)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1y")
# functions
@ -252,10 +253,20 @@ option(POC "Build proof of concept binaries" ON)
message(STATUS "POC binaries: ${POC}")
option(TOOLS "Build tool executables" ON)
message(STATUS "TOOLS binaries: ${TOOLS}")
option(TESTS "Build test binaries" ON)
message(STATUS "TESTS binaries: ${TESTS}")
option(BENCHMARK "Build benchmark binaries" ON)
message(STATUS "BENCHMARK binaries: ${BENCHMARK}")
option(BENCHMARK "Build benchmark test binaries" ON)
message(STATUS "BENCHMARK test binaries: ${BENCHMARK}")
option(CONCURRENT "Build concurrent test binaries" ON)
message(STATUS "CONCURRENT test binaries: ${CONCURRENT}")
option(INTEGRATION "Build integration test binaries" ON)
message(STATUS "INTEGRATION test binaries: ${INTEGRATION}")
option(MANUAL "Build manual test binaries" ON)
message(STATUS "MANUAL test binaries: ${MANUAL}")
option(UNIT "Build unit test binaries" ON)
message(STATUS "UNIT test binaries: ${UNIT}")
# -- binaries -----------------------------------------------------------------
# -- configure defines --------------------------------------------------------
@ -361,6 +372,10 @@ add_library(memgraph STATIC ${memgraph_src_files})
add_library(memgraph_pic STATIC ${memgraph_src_files})
set_property(TARGET memgraph_pic PROPERTY POSITION_INDEPENDENT_CODE TRUE)
# TODO: test build & run logic T190
include_directories(${catch_source_dir}/include)
# tests
if (TESTS)
enable_testing()
@ -372,11 +387,31 @@ if (POC)
add_subdirectory(poc)
endif()
# benchmark binaries
# benchmark test binaries
if (BENCHMARK)
add_subdirectory(${PROJECT_SOURCE_DIR}/tests/benchmark)
endif()
# concurrent test binaries
if (CONCURRENT)
add_subdirectory(${PROJECT_SOURCE_DIR}/tests/concurrent)
endif()
# integration test binaries
if (INTEGRATION)
add_subdirectory(${PROJECT_SOURCE_DIR}/tests/integration)
endif()
# integration test binaries
if (MANUAL)
add_subdirectory(${PROJECT_SOURCE_DIR}/tests/manual)
endif()
# integration test binaries
if (UNIT)
add_subdirectory(${PROJECT_SOURCE_DIR}/tests/unit)
endif()
# memgraph build name
execute_process(
OUTPUT_VARIABLE COMMIT_BRANCH

View File

@ -1,130 +1,11 @@
cmake_minimum_required(VERSION 3.1)
project(memgraph_tests)
project(${project_name}_tests)
set(src_dir ${CMAKE_SOURCE_DIR}/src)
include_directories(${catch_source_dir}/include)
# TODO: modular approach (REFACTOR)
## UNIT TESTS
# find unit tests
file(GLOB_RECURSE unit_test_files ${CMAKE_HOME_DIRECTORY}/tests/unit/*.cpp)
get_file_names("${unit_test_files}" file_names)
set(unit_test_names "${file_names}")
message(STATUS "Available unit tests are: ${unit_test_names}")
# copy unit test data
file(COPY ${CMAKE_SOURCE_DIR}/tests/data
DESTINATION ${CMAKE_BINARY_DIR}/tests)
# build unit tests
foreach(test ${unit_test_names})
set(test_name unit_${test})
add_executable(${test_name} unit/${test}.cpp ${src_dir}/template_engine/engine.cpp)
target_link_libraries(${test_name} memgraph)
# TODO: separate dependencies
target_link_libraries(${test_name} stdc++fs)
target_link_libraries(${test_name} cypher_lib)
target_link_libraries(${test_name} Threads::Threads)
target_link_libraries(${test_name} ${fmt_static_lib})
target_link_libraries(${test_name} ${yaml_static_lib})
add_test(NAME ${test_name} COMMAND ${test_name})
set_property(TARGET ${test_name} PROPERTY CXX_STANDARD 14)
endforeach()
## CONCURRENCY TESTS
# find concurrency tests
file(GLOB_RECURSE concurrency_test_files
${CMAKE_HOME_DIRECTORY}/tests/concurrent/*.cpp)
get_file_names("${concurrency_test_files}" file_names)
set(concurrency_test_names "${file_names}")
message(STATUS "Available concurrency tests are: ${concurrency_test_names}")
# build concurrency tests
foreach(test ${concurrency_test_names})
set(test_name concurrent_${test})
add_executable(${test_name} concurrent/${test}.cpp)
target_link_libraries(${test_name} memgraph)
target_link_libraries(${test_name} Threads::Threads)
target_link_libraries(${test_name} ${fmt_static_lib})
target_link_libraries(${test_name} ${yaml_static_lib})
add_test(NAME ${test_name} COMMAND ${test_name})
set_property(TARGET ${test_name} PROPERTY CXX_STANDARD 14)
endforeach()
## INTEGRATION TESTS
# TODO: move to tests/integration folder
# test hard coded queries
add_executable(integration_queries integration/queries.cpp)
target_link_libraries(integration_queries stdc++fs)
target_link_libraries(integration_queries memgraph)
target_link_libraries(integration_queries Threads::Threads)
target_link_libraries(integration_queries ${fmt_static_lib})
target_link_libraries(integration_queries ${yaml_static_lib})
add_test(NAME integration_queries COMMAND integration_queries)
set_property(TARGET integration_queries PROPERTY CXX_STANDARD 14)
# test cleaning methods
add_executable(integration_cleaning integration/cleaning.cpp)
target_link_libraries(integration_cleaning memgraph)
target_link_libraries(integration_cleaning Threads::Threads)
target_link_libraries(integration_cleaning ${fmt_static_lib})
target_link_libraries(integration_cleaning ${yaml_static_lib})
add_test(NAME integration_cleaning COMMAND integration_cleaning)
set_property(TARGET integration_cleaning PROPERTY CXX_STANDARD 14)
# test snapshot validity
add_executable(integration_snapshot integration/snapshot.cpp)
target_link_libraries(integration_snapshot memgraph)
target_link_libraries(integration_snapshot Threads::Threads)
target_link_libraries(integration_snapshot ${fmt_static_lib})
target_link_libraries(integration_snapshot ${yaml_static_lib})
add_test(NAME integration_snapshot COMMAND integration_snapshot)
set_property(TARGET integration_snapshot PROPERTY CXX_STANDARD 14)
# test index validity
add_executable(integration_index integration/index.cpp)
target_link_libraries(integration_index memgraph)
target_link_libraries(integration_index Threads::Threads)
target_link_libraries(integration_index ${fmt_static_lib})
target_link_libraries(integration_index ${yaml_static_lib})
add_test(NAME integration_index COMMAND integration_index)
set_property(TARGET integration_index PROPERTY CXX_STANDARD 14)
## MANUAL TESTS
# cypher_ast
add_executable(manual_cypher_ast manual/cypher_ast.cpp)
target_link_libraries(manual_cypher_ast stdc++fs)
target_link_libraries(manual_cypher_ast memgraph)
target_link_libraries(manual_cypher_ast Threads::Threads)
target_link_libraries(manual_cypher_ast ${fmt_static_lib})
target_link_libraries(manual_cypher_ast ${yaml_static_lib})
target_link_libraries(manual_cypher_ast cypher_lib)
set_property(TARGET manual_cypher_ast PROPERTY CXX_STANDARD 14)
# query_engine
add_executable(manual_query_engine manual/query_engine.cpp)
target_link_libraries(manual_query_engine stdc++fs)
target_link_libraries(manual_query_engine memgraph)
target_link_libraries(manual_query_engine ${fmt_static_lib})
target_link_libraries(manual_query_engine ${yaml_static_lib})
target_link_libraries(manual_query_engine dl)
target_link_libraries(manual_query_engine cypher_lib)
target_link_libraries(manual_query_engine Threads::Threads)
set_property(TARGET manual_query_engine PROPERTY CXX_STANDARD 14)
# query_hasher
add_executable(manual_query_hasher manual/query_hasher.cpp)
target_link_libraries(manual_query_hasher stdc++fs)
target_link_libraries(manual_query_hasher memgraph)
target_link_libraries(manual_query_hasher ${fmt_static_lib})
target_link_libraries(manual_query_hasher ${yaml_static_lib})
target_link_libraries(manual_query_hasher Threads::Threads)
set_property(TARGET manual_query_hasher PROPERTY CXX_STANDARD 14)
# TODO: test logic here T190

View File

@ -1,21 +1,43 @@
find_package(Threads REQUIRED)
file(GLOB_RECURSE ALL_BENCH_CPP *.cpp)
# set current directory name as a test type
get_filename_component(test_type ${CMAKE_CURRENT_SOURCE_DIR} NAME)
foreach(ONE_BENCH_CPP ${ALL_BENCH_CPP})
# get all cpp abs file names recursively starting from current directory
file(GLOB_RECURSE test_type_cpps *.cpp)
message(STATUS "Available ${test_type} cpp files are: ${test_type_cpps}")
get_filename_component(ONE_BENCH_EXEC ${ONE_BENCH_CPP} NAME_WE)
# for each cpp file build binary and register test
foreach(test_cpp ${test_type_cpps})
# Avoid name collision
set(TARGET_NAME Bench_${ONE_BENCH_EXEC})
# get exec name (remove extension from the abs path)
get_filename_component(exec_name ${test_cpp} NAME_WE)
add_executable(${TARGET_NAME} ${ONE_BENCH_CPP})
set_target_properties(${TARGET_NAME} PROPERTIES OUTPUT_NAME ${ONE_BENCH_EXEC})
target_link_libraries(${TARGET_NAME} benchmark ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries(${TARGET_NAME} memgraph)
target_link_libraries(${TARGET_NAME} ${fmt_static_lib})
target_link_libraries(${TARGET_NAME} Threads::Threads)
target_link_libraries(${TARGET_NAME} ${yaml_static_lib})
add_test(${TARGET_NAME} ${ONE_BENCH_EXEC})
# set target name in format {project_name}_{test_type}_{exec_name}
set(target_name ${project_name}_${test_type}_${exec_name})
# build exec file
add_executable(${target_name} ${test_cpp})
set_property(TARGET ${target_name} PROPERTY CXX_STANDARD ${cxx_standard})
# OUTPUT_NAME sets the real name of a target when it is built and can be
# used to help create two targets of the same name even though CMake
# requires unique logical target names
set_target_properties(${target_name} PROPERTIES OUTPUT_NAME ${exec_name})
# link libraries
# threads (cross-platform)
target_link_libraries(${target_name} Threads::Threads)
# google-benchmark
target_link_libraries(${target_name} benchmark ${CMAKE_THREAD_LIBS_INIT})
# memgraph lib
target_link_libraries(${target_name} memgraph)
# fmt format lib
target_link_libraries(${target_name} ${fmt_static_lib})
# yaml parser lib
target_link_libraries(${target_name} ${yaml_static_lib})
# register test
add_test(${target_name} ${exec_name})
endforeach()

View File

@ -1,34 +0,0 @@
#include "benchmark/benchmark_api.h"
#include <set>
#include <vector>
static void BM_VectorInsert(benchmark::State &state)
{
while (state.KeepRunning()) {
std::vector<int> insertion_test;
for (int i = 0, i_end = state.range_x(); i < i_end; i++) {
insertion_test.push_back(i);
}
}
}
// Register the function as a benchmark
BENCHMARK(BM_VectorInsert)->Range(8, 8 << 10);
//~~~~~~~~~~~~~~~~
// Define another benchmark
static void BM_SetInsert(benchmark::State &state)
{
while (state.KeepRunning()) {
std::set<int> insertion_test;
for (int i = 0, i_end = state.range_x(); i < i_end; i++) {
insertion_test.insert(i);
}
}
}
BENCHMARK(BM_SetInsert)->Range(8, 8 << 10);
BENCHMARK_MAIN();

View File

@ -1,34 +0,0 @@
#include "benchmark/benchmark_api.h"
#include <set>
#include <vector>
static void BM_VectorInsert(benchmark::State &state)
{
while (state.KeepRunning()) {
std::vector<int> insertion_test;
for (int i = 0, i_end = state.range_x(); i < i_end; i++) {
insertion_test.push_back(i);
}
}
}
// Register the function as a benchmark
BENCHMARK(BM_VectorInsert)->Range(8, 8 << 10);
//~~~~~~~~~~~~~~~~
// Define another benchmark
static void BM_SetInsert(benchmark::State &state)
{
while (state.KeepRunning()) {
std::set<int> insertion_test;
for (int i = 0, i_end = state.range_x(); i < i_end; i++) {
insertion_test.insert(i);
}
}
}
BENCHMARK(BM_SetInsert)->Range(8, 8 << 10);
BENCHMARK_MAIN();

View File

@ -0,0 +1,41 @@
find_package(Threads REQUIRED)
# set current directory name as a test type
get_filename_component(test_type ${CMAKE_CURRENT_SOURCE_DIR} NAME)
# get all cpp abs file names recursively starting from current directory
file(GLOB_RECURSE test_type_cpps *.cpp)
message(STATUS "Available ${test_type} cpp files are: ${test_type_cpps}")
# for each cpp file build binary and register test
foreach(test_cpp ${test_type_cpps})
# get exec name (remove extension from the abs path)
get_filename_component(exec_name ${test_cpp} NAME_WE)
# set target name in format {project_name}_{test_type}_{exec_name}
set(target_name ${project_name}_${test_type}_${exec_name})
# build exec file
add_executable(${target_name} ${test_cpp})
set_property(TARGET ${target_name} PROPERTY CXX_STANDARD ${cxx_standard})
# OUTPUT_NAME sets the real name of a target when it is built and can be
# used to help create two targets of the same name even though CMake
# requires unique logical target names
set_target_properties(${target_name} PROPERTIES OUTPUT_NAME ${exec_name})
# link libraries
# threads (cross-platform)
target_link_libraries(${target_name} Threads::Threads)
# memgraph lib
target_link_libraries(${target_name} memgraph)
# fmt format lib
target_link_libraries(${target_name} ${fmt_static_lib})
# yaml parser lib
target_link_libraries(${target_name} ${yaml_static_lib})
# register test
add_test(${target_name} ${exec_name})
endforeach()

View File

@ -0,0 +1,43 @@
find_package(Threads REQUIRED)
# set current directory name as a test type
get_filename_component(test_type ${CMAKE_CURRENT_SOURCE_DIR} NAME)
# get all cpp abs file names recursively starting from current directory
file(GLOB test_type_cpps *.cpp)
message(STATUS "Available ${test_type} cpp files are: ${test_type_cpps}")
# for each cpp file build binary and register test
foreach(test_cpp ${test_type_cpps})
# get exec name (remove extension from the abs path)
get_filename_component(exec_name ${test_cpp} NAME_WE)
# set target name in format {project_name}_{test_type}_{exec_name}
set(target_name ${project_name}_${test_type}_${exec_name})
# build exec file
add_executable(${target_name} ${test_cpp})
set_property(TARGET ${target_name} PROPERTY CXX_STANDARD ${cxx_standard})
# OUTPUT_NAME sets the real name of a target when it is built and can be
# used to help create two targets of the same name even though CMake
# requires unique logical target names
set_target_properties(${target_name} PROPERTIES OUTPUT_NAME ${exec_name})
# link libraries
# filesystem
target_link_libraries(${target_name} stdc++fs)
# threads (cross-platform)
target_link_libraries(${target_name} Threads::Threads)
# memgraph lib
target_link_libraries(${target_name} memgraph)
# fmt format lib
target_link_libraries(${target_name} ${fmt_static_lib})
# yaml parser lib
target_link_libraries(${target_name} ${yaml_static_lib})
# register test
add_test(${target_name} ${exec_name})
endforeach()

View File

@ -0,0 +1,47 @@
find_package(Threads REQUIRED)
# set current directory name as a test type
get_filename_component(test_type ${CMAKE_CURRENT_SOURCE_DIR} NAME)
# get all cpp abs file names recursively starting from current directory
file(GLOB_RECURSE test_type_cpps *.cpp)
message(STATUS "Available ${test_type} cpp files are: ${test_type_cpps}")
# for each cpp file build binary and register test
foreach(test_cpp ${test_type_cpps})
# get exec name (remove extension from the abs path)
get_filename_component(exec_name ${test_cpp} NAME_WE)
# set target name in format {project_name}_{test_type}_{exec_name}
set(target_name ${project_name}_${test_type}_${exec_name})
# build exec file
add_executable(${target_name} ${test_cpp})
set_property(TARGET ${target_name} PROPERTY CXX_STANDARD ${cxx_standard})
# OUTPUT_NAME sets the real name of a target when it is built and can be
# used to help create two targets of the same name even though CMake
# requires unique logical target names
set_target_properties(${target_name} PROPERTIES OUTPUT_NAME ${exec_name})
# link libraries
# filesystem
target_link_libraries(${target_name} stdc++fs)
# threads (cross-platform)
target_link_libraries(${target_name} Threads::Threads)
# memgraph lib
target_link_libraries(${target_name} memgraph)
# fmt format lib
target_link_libraries(${target_name} ${fmt_static_lib})
# yaml parser lib
target_link_libraries(${target_name} ${yaml_static_lib})
# cypher lib
target_link_libraries(${target_name} cypher_lib)
# dynamic lib
target_link_libraries(${target_name} dl)
# register test
add_test(${target_name} ${exec_name})
endforeach()

View File

@ -1,48 +0,0 @@
# compiler
CXX=clang++
# compile flags
CFLAGS=-std=c++1y -pthread -g2 # -D_GLIBCXX_DEBUG
# includes and libraries
INCLUDE_PATHS=-I../../../include -I../../../libs/fmt -I../../../src
LIB_PATHS=-L../../../libs/fmt/fmt
LDFLAGS=-lfmt
# source and executable
LOG_SRC_PATH=../../..
SOURCES=main.cpp async_log.o sync_log.o stderr.o stdout.o default.o levels.o log.o
EXECUTABLE=a.out
# release target
all: $(EXECUTABLE)
$(EXECUTABLE): $(SOURCES)
$(CXX) $(CFLAGS) $(INCLUDE_PATHS) $(SOURCES) -o $(EXECUTABLE) $(LIB_PATHS) $(LDFLAGS)
# TODO: auto
async_log.o: ../../../src/logging/logs/async_log.cpp
$(CXX) $(CFLAGS) $(INCLUDE_PATHS) -c ../../../src/logging/logs/async_log.cpp
sync_log.o: ../../../src/logging/logs/sync_log.cpp
$(CXX) $(CFLAGS) $(INCLUDE_PATHS) -c ../../../src/logging/logs/sync_log.cpp
stderr.o: ../../../src/logging/streams/stderr.cpp
$(CXX) $(CFLAGS) $(INCLUDE_PATHS) -c ../../../src/logging/streams/stderr.cpp
stdout.o: ../../../src/logging/streams/stdout.cpp
$(CXX) $(CFLAGS) $(INCLUDE_PATHS) -c ../../../src/logging/streams/stdout.cpp
default.o: ../../../src/logging/default.cpp
$(CXX) $(CFLAGS) $(INCLUDE_PATHS) -c ../../../src/logging/default.cpp
levels.o: ../../../src/logging/levels.cpp
$(CXX) $(CFLAGS) $(INCLUDE_PATHS) -c ../../../src/logging/levels.cpp
log.o: ../../../src/logging/log.cpp
$(CXX) $(CFLAGS) $(INCLUDE_PATHS) -c ../../../src/logging/log.cpp
.PHONY:
clean:
rm -f a.out
rm -f *.o

View File

@ -1,20 +0,0 @@
#include <iostream>
#include "logging/default.hpp"
#include "logging/streams/stdout.hpp"
int main(void)
{
// init logging
logging::init_sync();
logging::log->pipe(std::make_unique<Stdout>());
// get Main logger
Logger logger;
logger = logging::log->logger("Main");
logger.info("{}", logging::log->type());
std::string* test = new std::string("test_value");
return 0;
}

View File

@ -1,15 +0,0 @@
#include <iostream>
#include <vector>
#include "utils/iterator/map.hpp"
int main(void)
{
std::vector<int> test{1,2,3};
for (auto item : test) {
std::cout << item << std::endl;
}
return 0;
}

47
tests/unit/CMakeLists.txt Normal file
View File

@ -0,0 +1,47 @@
find_package(Threads REQUIRED)
# set current directory name as a test type
get_filename_component(test_type ${CMAKE_CURRENT_SOURCE_DIR} NAME)
# get all cpp abs file names recursively starting from current directory
file(GLOB_RECURSE test_type_cpps *.cpp)
message(STATUS "Available ${test_type} cpp files are: ${test_type_cpps}")
# for each cpp file build binary and register test
foreach(test_cpp ${test_type_cpps})
# get exec name (remove extension from the abs path)
get_filename_component(exec_name ${test_cpp} NAME_WE)
# set target name in format {project_name}_{test_type}_{exec_name}
set(target_name ${project_name}_${test_type}_${exec_name})
# build exec file
add_executable(${target_name} ${test_cpp})
set_property(TARGET ${target_name} PROPERTY CXX_STANDARD ${cxx_standard})
# OUTPUT_NAME sets the real name of a target when it is built and can be
# used to help create two targets of the same name even though CMake
# requires unique logical target names
set_target_properties(${target_name} PROPERTIES OUTPUT_NAME ${exec_name})
# link libraries
# filesystem
target_link_libraries(${target_name} stdc++fs)
# threads (cross-platform)
target_link_libraries(${target_name} Threads::Threads)
# memgraph lib
target_link_libraries(${target_name} memgraph)
# fmt format lib
target_link_libraries(${target_name} ${fmt_static_lib})
# yaml parser lib
target_link_libraries(${target_name} ${yaml_static_lib})
# cypher lib
target_link_libraries(${target_name} cypher_lib)
# dynamic lib
target_link_libraries(${target_name} dl)
# register test
add_test(${target_name} ${exec_name})
endforeach()