mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-08-05 17:52:29 +00:00
Cleaned up system headers.
This commit is contained in:
@@ -2,12 +2,11 @@
|
||||
#define RTORRENT_INPUT_INPUT_EVENT_H
|
||||
|
||||
#include <functional>
|
||||
|
||||
#include <torrent/event.h>
|
||||
#include <torrent/system/event.h>
|
||||
|
||||
namespace input {
|
||||
|
||||
class InputEvent : public torrent::Event {
|
||||
class InputEvent : public torrent::system::Event {
|
||||
public:
|
||||
typedef std::function<void (int)> slot_int;
|
||||
|
||||
|
||||
+2
-2
@@ -3,13 +3,13 @@
|
||||
|
||||
#include <array>
|
||||
#include <memory>
|
||||
#include <torrent/event.h>
|
||||
#include <torrent/system/event.h>
|
||||
|
||||
#include "rpc/scgi_task.h"
|
||||
|
||||
namespace rpc {
|
||||
|
||||
class SCgi : public torrent::Event {
|
||||
class SCgi : public torrent::system::Event {
|
||||
public:
|
||||
static const int max_tasks = 100;
|
||||
|
||||
|
||||
+2
-2
@@ -4,13 +4,13 @@
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <vector>
|
||||
#include <torrent/event.h>
|
||||
#include <torrent/system/event.h>
|
||||
|
||||
namespace rpc {
|
||||
|
||||
class SCgi;
|
||||
|
||||
class SCgiTask : public torrent::Event {
|
||||
class SCgiTask : public torrent::system::Event {
|
||||
public:
|
||||
static constexpr int default_buffer_size = 8191;
|
||||
static constexpr int max_header_size = 2000;
|
||||
|
||||
@@ -2,9 +2,10 @@
|
||||
#define LIBTORRENT_HELPERS_MOCK_COMPARE_H
|
||||
|
||||
#include <algorithm>
|
||||
#include <map>
|
||||
#include <type_traits>
|
||||
#include <torrent/event.h>
|
||||
#include <torrent/net/socket_address.h>
|
||||
#include <torrent/system/event.h>
|
||||
|
||||
// Compare arguments to mock functions with what is expected. The lhs
|
||||
// are the expected arguments, rhs are the ones called with.
|
||||
@@ -13,13 +14,13 @@ template <typename Arg>
|
||||
inline bool mock_compare_arg(Arg lhs, Arg rhs) { return lhs == rhs; }
|
||||
|
||||
template <int I, typename A, typename... Args>
|
||||
typename std::enable_if<I == 1, int>::type
|
||||
std::enable_if_t<I == 1, int>
|
||||
mock_compare_tuple(const std::tuple<A, Args...>& lhs, const std::tuple<Args...>& rhs) {
|
||||
return mock_compare_arg(std::get<I>(lhs), std::get<I - 1>(rhs)) ? 0 : 1;
|
||||
}
|
||||
|
||||
template <int I, typename A, typename... Args>
|
||||
typename std::enable_if<1 < I, int>::type
|
||||
std::enable_if_t<1 < I, int>
|
||||
mock_compare_tuple(const std::tuple<A, Args...>& lhs, const std::tuple<Args...>& rhs) {
|
||||
auto res = mock_compare_tuple<I - 1>(lhs, rhs);
|
||||
|
||||
@@ -70,24 +71,37 @@ void mock_compare_add(T* v) {
|
||||
// Specialize:
|
||||
//
|
||||
|
||||
constexpr int mock_compare_gt_two_int = -0xFD30;
|
||||
|
||||
template <>
|
||||
inline bool mock_compare_arg<int>(int lhs, int rhs) {
|
||||
if (lhs == mock_compare_gt_two_int)
|
||||
return rhs > 2;
|
||||
if (rhs == mock_compare_gt_two_int)
|
||||
return lhs > 2;
|
||||
|
||||
return lhs == rhs;
|
||||
}
|
||||
|
||||
template <>
|
||||
inline bool mock_compare_arg<sockaddr*>(sockaddr* lhs, sockaddr* rhs) {
|
||||
return lhs != nullptr && rhs != nullptr && torrent::sa_equal(lhs, rhs);
|
||||
}
|
||||
|
||||
template <>
|
||||
inline bool mock_compare_arg<const sockaddr*>(const sockaddr* lhs, const sockaddr* rhs) {
|
||||
return lhs != nullptr && rhs != nullptr && torrent::sa_equal(lhs, rhs);
|
||||
}
|
||||
|
||||
template <>
|
||||
inline bool mock_compare_arg<torrent::Event*>(torrent::Event* lhs, torrent::Event* rhs) {
|
||||
if (mock_compare_map<torrent::Event>::is_key(lhs)) {
|
||||
if (!mock_compare_map<torrent::Event>::has_value(rhs)) {
|
||||
mock_compare_map<torrent::Event>::values[lhs] = rhs;
|
||||
inline bool mock_compare_arg<torrent::system::Event*>(torrent::system::Event* lhs, torrent::system::Event* rhs) {
|
||||
if (mock_compare_map<torrent::system::Event>::is_key(lhs)) {
|
||||
if (!mock_compare_map<torrent::system::Event>::has_value(rhs)) {
|
||||
mock_compare_map<torrent::system::Event>::values[lhs] = rhs;
|
||||
return true;
|
||||
}
|
||||
|
||||
return mock_compare_map<torrent::Event>::has_key(lhs) && mock_compare_map<torrent::Event>::get(lhs) == rhs;
|
||||
return mock_compare_map<torrent::system::Event>::has_key(lhs) && mock_compare_map<torrent::system::Event>::get(lhs) == rhs;
|
||||
}
|
||||
|
||||
return lhs == rhs;
|
||||
|
||||
@@ -6,9 +6,9 @@
|
||||
#include <iostream>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "torrent/event.h"
|
||||
#include "torrent/net/socket_address.h"
|
||||
#include "torrent/net/fd.h"
|
||||
#include "torrent/system/event.h"
|
||||
#include "torrent/utils/log.h"
|
||||
#include "torrent/utils/random.h"
|
||||
|
||||
@@ -32,7 +32,7 @@ mock_clear(bool ignore_assert) {
|
||||
MOCK_CLEANUP_MAP(torrent::random_uniform_uint16);
|
||||
MOCK_CLEANUP_MAP(torrent::random_uniform_uint32);
|
||||
|
||||
mock_compare_map<torrent::Event>::values.clear();
|
||||
mock_compare_map<torrent::system::Event>::values.clear();
|
||||
}
|
||||
} // namespace
|
||||
|
||||
@@ -55,7 +55,9 @@ mock_redirect_defaults([[maybe_unused]] mock_redirect_flags flags) {
|
||||
|
||||
mock_redirect(torrent::fd__close, std::function<int(int fildes)>([](int fildes) { return ::close(fildes); }));
|
||||
mock_redirect(torrent::fd__fcntl_int, std::function<int(int fildes, int cmd, int arg)>([](int fildes, int cmd, int arg) { return ::fcntl(fildes, cmd, arg); }));
|
||||
mock_redirect(torrent::fd__setsockopt_int, std::function<int(int socket, int level, int option_name, int option_value)>([](int socket, int level, int option_name, int option_value) { return ::setsockopt(socket, level, option_name, &option_value, sizeof(int)); }));
|
||||
mock_redirect(torrent::fd__setsockopt_int, std::function<int(int socket, int level, int option_name, int option_value)>([](int socket, int level, int option_name, int option_value) {
|
||||
return ::setsockopt(socket, level, option_name, &option_value, sizeof(int));
|
||||
}));
|
||||
mock_redirect(torrent::fd__socket, std::function<int(int domain, int type, int protocol)>([](int domain, int type, int protocol) { return ::socket(domain, type, protocol); }));
|
||||
}
|
||||
|
||||
@@ -112,69 +114,6 @@ int fd__socket(int domain, int type, int protocol) {
|
||||
return mock_call<int>(__func__, &torrent::fd__socket, domain, type, protocol);
|
||||
}
|
||||
|
||||
//
|
||||
// Mock functions for 'torrent/common.h':
|
||||
//
|
||||
|
||||
namespace this_thread {
|
||||
|
||||
void event_open(Event* event) {
|
||||
MOCK_LOG("fd:%i type_name:%s", event->file_descriptor(), event->type_name());
|
||||
return mock_call<void>(__func__, &torrent::this_thread::event_open, event);
|
||||
}
|
||||
|
||||
void event_open_and_count(Event* event) {
|
||||
MOCK_LOG("fd:%i type_name:%s", event->file_descriptor(), event->type_name());
|
||||
return mock_call<void>(__func__, &torrent::this_thread::event_open_and_count, event);
|
||||
}
|
||||
|
||||
void event_close_and_count(Event* event) {
|
||||
MOCK_LOG("fd:%i type_name:%s", event->file_descriptor(), event->type_name());
|
||||
return mock_call<void>(__func__, &torrent::this_thread::event_close_and_count, event);
|
||||
}
|
||||
|
||||
void event_closed_and_count(Event* event) {
|
||||
MOCK_LOG("fd:%i type_name:%s", event->file_descriptor(), event->type_name());
|
||||
return mock_call<void>(__func__, &torrent::this_thread::event_closed_and_count, event);
|
||||
}
|
||||
|
||||
void event_insert_read(Event* event) {
|
||||
MOCK_LOG("fd:%i type_name:%s", event->file_descriptor(), event->type_name());
|
||||
return mock_call<void>(__func__, &torrent::this_thread::event_insert_read, event);
|
||||
}
|
||||
|
||||
void event_insert_write(Event* event) {
|
||||
MOCK_LOG("fd:%i type_name:%s", event->file_descriptor(), event->type_name());
|
||||
return mock_call<void>(__func__, &torrent::this_thread::event_insert_write, event);
|
||||
}
|
||||
|
||||
void event_insert_error(Event* event) {
|
||||
MOCK_LOG("fd:%i type_name:%s", event->file_descriptor(), event->type_name());
|
||||
return mock_call<void>(__func__, &torrent::this_thread::event_insert_error, event);
|
||||
}
|
||||
|
||||
void event_remove_read(Event* event) {
|
||||
MOCK_LOG("fd:%i type_name:%s", event->file_descriptor(), event->type_name());
|
||||
return mock_call<void>(__func__, &torrent::this_thread::event_remove_read, event);
|
||||
}
|
||||
|
||||
void event_remove_write(Event* event) {
|
||||
MOCK_LOG("fd:%i type_name:%s", event->file_descriptor(), event->type_name());
|
||||
return mock_call<void>(__func__, &torrent::this_thread::event_remove_write, event);
|
||||
}
|
||||
|
||||
void event_remove_error(Event* event) {
|
||||
MOCK_LOG("fd:%i type_name:%s", event->file_descriptor(), event->type_name());
|
||||
return mock_call<void>(__func__, &torrent::this_thread::event_remove_error, event);
|
||||
}
|
||||
|
||||
void event_remove_and_close(Event* event) {
|
||||
MOCK_LOG("fd:%i type_name:%s", event->file_descriptor(), event->type_name());
|
||||
return mock_call<void>(__func__, &torrent::this_thread::event_remove_and_close, event);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// Mock functions for 'torrent/utils/random.h':
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user