From d14861d478e1081293d6fc27e2c182870f9cdade Mon Sep 17 00:00:00 2001 From: Falk Werner Date: Sat, 27 Apr 2019 13:20:59 +0200 Subject: [PATCH] adds test of wf_status --- CMakeLists.txt | 2 ++ lib/webfuse/core/status.c | 2 +- test/test_fuse_req.cc | 2 +- test/test_status.cc | 30 ++++++++++++++++++++++++++++++ 4 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 test/test_status.cc diff --git a/CMakeLists.txt b/CMakeLists.txt index 38a4726..07e6172 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -306,6 +306,8 @@ add_executable(alltests test/test_slist.cc test/test_path.cc test/test_static_filesystem.cc + test/test_fuse_req.cc + test/test_status.cc ) target_link_libraries(alltests PUBLIC webfuse-adapter-static webfuse-provider-static webfuse-core ${EXTRA_LIBS} ${GMOCK_LIBRARIES} ${GTEST_LIBRARIES}) diff --git a/lib/webfuse/core/status.c b/lib/webfuse/core/status.c index 9eb9964..d5bc7ba 100644 --- a/lib/webfuse/core/status.c +++ b/lib/webfuse/core/status.c @@ -23,7 +23,7 @@ char const * wf_status_tostring(wf_status status) { case WF_GOOD: return "Good"; case WF_BAD: return "Bad"; - case WF_BAD_NOTIMPLEMENTED: return "Bad (not implelemted)"; + case WF_BAD_NOTIMPLEMENTED: return "Bad (not implemented)"; case WF_BAD_TIMEOUT: return "Bad (timeout)"; case WF_BAD_BUSY: return "Bad (busy)"; case WF_BAD_FORMAT: return "Bad (format)"; diff --git a/test/test_fuse_req.cc b/test/test_fuse_req.cc index efb63af..d1264d9 100644 --- a/test/test_fuse_req.cc +++ b/test/test_fuse_req.cc @@ -1,5 +1,5 @@ #include -#include "webfuse/adapter/fuse_wrapper.h" +#include "webfuse/adapter/impl/fuse_wrapper.h" TEST(libfuse, fuse_req_t_size) { diff --git a/test/test_status.cc b/test/test_status.cc new file mode 100644 index 0000000..4558f72 --- /dev/null +++ b/test/test_status.cc @@ -0,0 +1,30 @@ +#include +#include "webfuse/core/status_intern.h" + +TEST(wf_status, tostring) +{ + ASSERT_STREQ("Good", wf_status_tostring(WF_GOOD)); + ASSERT_STREQ("Bad", wf_status_tostring(WF_BAD)); + ASSERT_STREQ("Bad (not implemented)", wf_status_tostring(WF_BAD_NOTIMPLEMENTED)); + ASSERT_STREQ("Bad (busy)", wf_status_tostring(WF_BAD_BUSY)); + ASSERT_STREQ("Bad (timeout)", wf_status_tostring(WF_BAD_TIMEOUT)); + ASSERT_STREQ("Bad (format)", wf_status_tostring(WF_BAD_FORMAT)); + ASSERT_STREQ("Bad (no entry)", wf_status_tostring(WF_BAD_NOENTRY)); + ASSERT_STREQ("Bad (access denied)", wf_status_tostring(WF_BAD_ACCESS_DENIED)); + + ASSERT_STREQ("Bad (unknown)", wf_status_tostring(-1)); +} + +TEST(wf_status, to_rc) +{ + ASSERT_EQ(0, wf_status_to_rc(WF_GOOD)); + ASSERT_EQ(-ENOENT, wf_status_to_rc(WF_BAD)); + ASSERT_EQ(-ENOSYS, wf_status_to_rc(WF_BAD_NOTIMPLEMENTED)); + ASSERT_EQ(-ENOENT, wf_status_to_rc(WF_BAD_BUSY)); + ASSERT_EQ(-ETIMEDOUT, wf_status_to_rc(WF_BAD_TIMEOUT)); + ASSERT_EQ(-ENOENT, wf_status_to_rc(WF_BAD_FORMAT)); + ASSERT_EQ(-ENOENT, wf_status_to_rc(WF_BAD_NOENTRY)); + ASSERT_EQ(-EACCES, wf_status_to_rc(WF_BAD_ACCESS_DENIED)); + + ASSERT_EQ(-ENOENT, wf_status_to_rc(-1)); +} \ No newline at end of file