From fa1845abdf2aaf1679d1c0ee9e693210ad94f455 Mon Sep 17 00:00:00 2001 From: Falk Werner Date: Sun, 21 Jun 2020 17:10:33 +0200 Subject: [PATCH] removed unused test utils --- meson.build | 3 - test/webfuse_provider/utils/file_utils.cc | 38 ------- test/webfuse_provider/utils/file_utils.hpp | 17 ---- test/webfuse_provider/utils/path.c | 113 --------------------- test/webfuse_provider/utils/path.h | 43 -------- test/webfuse_provider/utils/tempdir.cc | 33 ------ test/webfuse_provider/utils/tempdir.hpp | 21 ---- 7 files changed, 268 deletions(-) delete mode 100644 test/webfuse_provider/utils/file_utils.cc delete mode 100644 test/webfuse_provider/utils/file_utils.hpp delete mode 100644 test/webfuse_provider/utils/path.c delete mode 100644 test/webfuse_provider/utils/path.h delete mode 100644 test/webfuse_provider/utils/tempdir.cc delete mode 100644 test/webfuse_provider/utils/tempdir.hpp diff --git a/meson.build b/meson.build index 9a38967..b680b72 100644 --- a/meson.build +++ b/meson.build @@ -113,10 +113,7 @@ alltests = executable('alltests', 'test/webfuse_provider/tests/core/jsonrpc/test_response_parser.cc', 'test/webfuse_provider/tests/core/timer/test_timepoint.cc', 'test/webfuse_provider/tests/core/timer/test_timer.cc', - 'test/webfuse_provider/utils/tempdir.cc', - 'test/webfuse_provider/utils/file_utils.cc', 'test/webfuse_provider/utils/timeout_watcher.cc', - 'test/webfuse_provider/utils/path.c', 'test/webfuse_provider/utils/ws_server.cc', 'test/webfuse_provider/utils/jansson_test_environment.cc', 'test/webfuse_provider/mocks/fake_invokation_context.cc', diff --git a/test/webfuse_provider/utils/file_utils.cc b/test/webfuse_provider/utils/file_utils.cc deleted file mode 100644 index 61b50e9..0000000 --- a/test/webfuse_provider/utils/file_utils.cc +++ /dev/null @@ -1,38 +0,0 @@ -#include "webfuse_provider/utils/file_utils.hpp" - -#include -#include -#include - -namespace webfuse_test -{ - -bool is_dir(std::string const & path) -{ - struct stat info; - int rc = stat(path.c_str(), &info); - - return (0 == rc) && (S_ISDIR(info.st_mode)); -} - -bool is_symlink(std::string const & path) -{ - struct stat info; - int rc = lstat(path.c_str(), &info); - - return (0 == rc) && (S_ISLNK(info.st_mode)); -} - -bool is_same_path(std::string const & path, std::string const & other) -{ - struct stat info; - int rc = stat(path.c_str(), &info); - - struct stat info_other; - int rc_other = stat(other.c_str(), &info_other); - - return (0 == rc) && (0 == rc_other) && (info.st_ino == info_other.st_ino); -} - - -} \ No newline at end of file diff --git a/test/webfuse_provider/utils/file_utils.hpp b/test/webfuse_provider/utils/file_utils.hpp deleted file mode 100644 index 01df8cc..0000000 --- a/test/webfuse_provider/utils/file_utils.hpp +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef WFP_TEST_FILE_UTILS_HPP -#define WFP_TEST_FILE_UTILS_HPP - -#include - -namespace webfuse_test -{ - -bool is_dir(std::string const & path); - -bool is_symlink(std::string const & path); - -bool is_same_path(std::string const & path, std::string const & other); - -} - -#endif diff --git a/test/webfuse_provider/utils/path.c b/test/webfuse_provider/utils/path.c deleted file mode 100644 index b1a2af0..0000000 --- a/test/webfuse_provider/utils/path.c +++ /dev/null @@ -1,113 +0,0 @@ -#include "webfuse_provider/utils/path.h" -#include -#include - -#define WFP_PATH_DEFAULT_CAPACITY (8) - -struct wfp_path -{ - char * * elements; - size_t count; - size_t capacity; -}; - -static void -wfp_path_add( - struct wfp_path * path, - char const * element, - size_t element_size) -{ - if (0 < element_size) - { - if (path->count >= path->capacity) - { - size_t new_capacity = 2 * path->capacity; - size_t new_size = sizeof(char*) * new_capacity; - - char * * elements = realloc(path->elements, new_size); - if (NULL != elements) - { - path->elements = elements; - path->capacity = new_capacity; - } - } - - if (path->count < path->capacity) - { - path->elements[path->count] = strndup(element, element_size); - path->count++; - } - } -} - -struct wfp_path * -wfp_path_create( - char const * value) -{ - struct wfp_path * path = malloc(sizeof(struct wfp_path)); - path->elements = malloc(sizeof(char*) * WFP_PATH_DEFAULT_CAPACITY); - path->capacity = WFP_PATH_DEFAULT_CAPACITY; - path->count = 0; - - char const * remainder = value; - char const * pos = strchr(remainder, '/'); - while (NULL != pos) - { - wfp_path_add(path, remainder, (pos - remainder)); - remainder = pos + 1; - pos = strchr(remainder, '/'); - } - - wfp_path_add(path, remainder, strlen(remainder)); - - return path; -} - -void -wfp_path_dispose( - struct wfp_path * path) -{ - for(size_t i = 0; i < path->count; i++) - { - free(path->elements[i]); - } - - free(path->elements); - free(path); - (void) path; -} - -size_t -wfp_path_element_count( - struct wfp_path * path) -{ - return path->count; -} - -char const * -wfp_path_get_element( - struct wfp_path * path, - size_t i) -{ - char const * result = NULL; - if (i < path->count) - { - result = path->elements[i]; - } - - return result; -} - -char const * -wfp_path_get_filename( - struct wfp_path * path) -{ - char const * result = NULL; - - if (0 < path->count) - { - result = path->elements[path->count - 1]; - } - - return result; -} diff --git a/test/webfuse_provider/utils/path.h b/test/webfuse_provider/utils/path.h deleted file mode 100644 index 01da8e6..0000000 --- a/test/webfuse_provider/utils/path.h +++ /dev/null @@ -1,43 +0,0 @@ -#ifndef WFP_PATH_H -#define WFP_PATH_H - -#ifndef __cplusplus -#include -#else -#include -using ::std::size_t; -#endif - -#ifdef __cplusplus -extern "C" -{ -#endif - -struct wfp_path; - -extern struct wfp_path * -wfp_path_create( - char const * value); - -extern void -wfp_path_dispose( - struct wfp_path * path); - -extern size_t -wfp_path_element_count( - struct wfp_path * path); - -extern char const * -wfp_path_get_element( - struct wfp_path * path, - size_t i); - -extern char const * -wfp_path_get_filename( - struct wfp_path * path); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/test/webfuse_provider/utils/tempdir.cc b/test/webfuse_provider/utils/tempdir.cc deleted file mode 100644 index a36574d..0000000 --- a/test/webfuse_provider/utils/tempdir.cc +++ /dev/null @@ -1,33 +0,0 @@ -#include "webfuse_provider/utils/tempdir.hpp" - -#include -#include -#include -#include - -namespace webfuse_test -{ - -TempDir::TempDir(char const * prefix) -{ - asprintf(&path_, "/tmp/%s_XXXXXX", prefix); - char * result = mkdtemp(path_); - if (NULL == result) - { - throw std::runtime_error("unable to create temp dir"); - } -} - -TempDir::~TempDir() -{ - rmdir(path_); - free(path_); -} - -char const * TempDir::path() -{ - return path_; -} - - -} \ No newline at end of file diff --git a/test/webfuse_provider/utils/tempdir.hpp b/test/webfuse_provider/utils/tempdir.hpp deleted file mode 100644 index ecf8a61..0000000 --- a/test/webfuse_provider/utils/tempdir.hpp +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef WFP_TEST_TEMPDIR_HPP -#define WFP_TEST_TEMPDIR_HPP - -namespace webfuse_test -{ - -class TempDir -{ - TempDir(TempDir const &) = delete; - TempDir & operator=(TempDir const &) = delete; -public: - explicit TempDir(char const * prefix); - ~TempDir(); - char const * path(); -private: - char * path_; -}; - -} - -#endif