mirror of
https://github.com/falk-werner/webfused
synced 2024-10-27 20:44:08 +00:00
added basic unit test
This commit is contained in:
parent
207f18f4fd
commit
141c857d4e
@ -1,6 +1,8 @@
|
|||||||
cmake_minimum_required (VERSION 3.10)
|
cmake_minimum_required (VERSION 3.10)
|
||||||
project(webfused VERSION 0.1.0 DESCRIPTION "Webfuse daemon")
|
project(webfused VERSION 0.1.0 DESCRIPTION "Webfuse daemon")
|
||||||
|
|
||||||
|
option(WITHOUT_TESTS "disable unit tests" OFF)
|
||||||
|
|
||||||
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
||||||
find_package(Threads REQUIRED)
|
find_package(Threads REQUIRED)
|
||||||
|
|
||||||
@ -78,3 +80,43 @@ target_include_directories(webfuse-passwd PUBLIC
|
|||||||
|
|
||||||
target_compile_options(webfuse-passwd PUBLIC ${OPENSSL_CFLAGS_OTHER})
|
target_compile_options(webfuse-passwd PUBLIC ${OPENSSL_CFLAGS_OTHER})
|
||||||
install(TARGETS webfuse-passwd DESTINATION bin)
|
install(TARGETS webfuse-passwd DESTINATION bin)
|
||||||
|
|
||||||
|
if(NOT WITHOUT_TESTS)
|
||||||
|
|
||||||
|
|
||||||
|
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
||||||
|
find_package(Threads REQUIRED)
|
||||||
|
|
||||||
|
|
||||||
|
include (CTest)
|
||||||
|
|
||||||
|
pkg_check_modules(GTEST gtest_main)
|
||||||
|
include(GoogleTest)
|
||||||
|
pkg_check_modules(GMOCK gmock)
|
||||||
|
|
||||||
|
add_executable(alltests
|
||||||
|
test/test_config.cc
|
||||||
|
)
|
||||||
|
|
||||||
|
target_include_directories(alltests PRIVATE
|
||||||
|
src
|
||||||
|
${GMOCK_INCLUDE_DIRS}
|
||||||
|
${GTEST_INCLUDE_DIRS}
|
||||||
|
)
|
||||||
|
|
||||||
|
target_compile_options(alltests PRIVATE ${GMOCK_CFLAGS} ${GTEST_CFLAGS} "-pthread")
|
||||||
|
|
||||||
|
target_link_libraries(alltests PRIVATE
|
||||||
|
${LIBCONFIG_LIBRARIES}
|
||||||
|
${GMOCK_LIBRARIES}
|
||||||
|
${GTEST_LIBRARIES}
|
||||||
|
${CMAKE_THREAD_LIBS_INIT}
|
||||||
|
)
|
||||||
|
|
||||||
|
# copy test data
|
||||||
|
configure_file(etc/webfused.conf webfused.conf COPYONLY)
|
||||||
|
|
||||||
|
enable_testing()
|
||||||
|
gtest_discover_tests(alltests TEST_PREFIX alltests:)
|
||||||
|
|
||||||
|
endif(NOT WITHOUT_TESTS)
|
||||||
|
14
README.md
14
README.md
@ -23,6 +23,7 @@ To install dependecies, see below.
|
|||||||
- [jansson](https://github.com/akheron/jansson)
|
- [jansson](https://github.com/akheron/jansson)
|
||||||
- [openssl](https://www.openssl.org/)
|
- [openssl](https://www.openssl.org/)
|
||||||
- [libconfig](https://hyperrealm.github.io/libconfig/)
|
- [libconfig](https://hyperrealm.github.io/libconfig/)
|
||||||
|
- [Google Test](https://github.com/google/googletest) *(Test only)*
|
||||||
|
|
||||||
### Installing dependencies
|
### Installing dependencies
|
||||||
|
|
||||||
@ -82,3 +83,16 @@ To install libfuse, meson is needed. Please refer to [meson quick guide](https:/
|
|||||||
|
|
||||||
sudo apt update
|
sudo apt update
|
||||||
sudo apt install libconfig-dev
|
sudo apt install libconfig-dev
|
||||||
|
|
||||||
|
#### GoogleTest
|
||||||
|
|
||||||
|
Installation of GoogleTest is optional webfuse library, but required to compile tests.
|
||||||
|
|
||||||
|
wget -O gtest-1.10.0.tar.gz https://github.com/google/googletest/archive/release-1.10.0.tar.gz
|
||||||
|
tar -xf gtest-1.10.0.tar.gz
|
||||||
|
cd googletest-release-1.10.0
|
||||||
|
mkdir .build
|
||||||
|
cd .build
|
||||||
|
cmake ..
|
||||||
|
make
|
||||||
|
sudo make install
|
||||||
|
13
test/test_config.cc
Normal file
13
test/test_config.cc
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#include <gtest/gtest.h>
|
||||||
|
#include <libconfig.h>
|
||||||
|
|
||||||
|
TEST(config, is_loadable)
|
||||||
|
{
|
||||||
|
config_t config;
|
||||||
|
config_init(&config);
|
||||||
|
|
||||||
|
int result = config_read_file(&config, "webfused.conf");
|
||||||
|
ASSERT_EQ(CONFIG_TRUE, result);
|
||||||
|
|
||||||
|
config_destroy(&config);
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user