diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8e76287..b3e3084 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -25,3 +25,6 @@ jobs: - name: Build run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} + + - name: Unit Test + run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --target test diff --git a/CMakeLists.txt b/CMakeLists.txt index 03299b0..44433ba 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,32 @@ cmake_minimum_required(VERSION 3.10) project(webfuse VERSION 2.0.0) +find_package(PkgConfig REQUIRED) +pkg_check_modules(FUSE REQUIRED IMPORTED_TARGET fuse3) +pkg_check_modules(LWS REQUIRED IMPORTED_TARGET libwebsockets) + +add_library(webfuse_static STATIC + src/webfuse/webfuse.cpp) + +target_include_directories(webfuse_static PUBLIC src) +target_link_libraries(webfuse_static PUBLIC PkgConfig::FUSE PkgConfig::LWS) + add_executable(webfuse src/main.cpp) + +target_link_libraries(webfuse PRIVATE webfuse_static) + +if(NOT(WITHOUT_TEST)) + + pkg_check_modules(GTEST REQUIRED IMPORTED_TARGET gtest_main) + + add_executable(alltests + test/webfuse/test_app.cpp + ) + + target_link_libraries(alltests PRIVATE webfuse_static PkgConfig::GTEST) + + enable_testing() + add_test(NAME alltests COMMAND alltests) + +endif() diff --git a/src/main.cpp b/src/main.cpp index 4112f94..702f132 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,6 +1,7 @@ -#include +#include "webfuse/webfuse.hpp" int main(int argc, char* argv[]) { - return EXIT_SUCCESS; + webfuse::app app(argc, argv); + return app.run(); } \ No newline at end of file diff --git a/src/webfuse/webfuse.cpp b/src/webfuse/webfuse.cpp new file mode 100644 index 0000000..2d69d06 --- /dev/null +++ b/src/webfuse/webfuse.cpp @@ -0,0 +1,27 @@ +#include "webfuse/webfuse.hpp" + +namespace webfuse +{ + +class app::detail +{ + int dummy; +}; + +app::app(int argc, char * argv[]) +: d(new detail) +{ + +} + +app::~app() +{ + delete d; +} + +int app::run() +{ + return 0; +} + +} \ No newline at end of file diff --git a/src/webfuse/webfuse.hpp b/src/webfuse/webfuse.hpp new file mode 100644 index 0000000..60c5989 --- /dev/null +++ b/src/webfuse/webfuse.hpp @@ -0,0 +1,24 @@ +#ifndef WEBFUSE_HPP +#define WEBFUSE_HPP + +namespace webfuse +{ + +class app +{ + app(app const &) = delete; + app& operator=(app const &) = delete; + app(app &&) = delete; + app& operator=(app &&) = delete; +public: + app(int argc, char * argv[]); + ~app(); + int run(); +private: + class detail; + detail * d; +}; + +} + +#endif \ No newline at end of file diff --git a/test/webfuse/test_app.cpp b/test/webfuse/test_app.cpp new file mode 100644 index 0000000..ff08344 --- /dev/null +++ b/test/webfuse/test_app.cpp @@ -0,0 +1,9 @@ +#include "webfuse/webfuse.hpp" +#include + +TEST(app, init) +{ + char args0[] = "webfuse"; + char * args[] = { args0, nullptr }; + webfuse::app(1, args); +} \ No newline at end of file