removed unused test utils

pull/2/head
Falk Werner 4 years ago
parent fdd93149fe
commit fa1845abdf

@ -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',

@ -1,38 +0,0 @@
#include "webfuse_provider/utils/file_utils.hpp"
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
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);
}
}

@ -1,17 +0,0 @@
#ifndef WFP_TEST_FILE_UTILS_HPP
#define WFP_TEST_FILE_UTILS_HPP
#include <string>
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

@ -1,113 +0,0 @@
#include "webfuse_provider/utils/path.h"
#include <stdlib.h>
#include <string.h>
#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;
}

@ -1,43 +0,0 @@
#ifndef WFP_PATH_H
#define WFP_PATH_H
#ifndef __cplusplus
#include <stddef.h>
#else
#include <cstddef>
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

@ -1,33 +0,0 @@
#include "webfuse_provider/utils/tempdir.hpp"
#include <unistd.h>
#include <cstdio>
#include <cstdlib>
#include <stdexcept>
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_;
}
}

@ -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
Loading…
Cancel
Save