mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-10-07 14:49:21 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| fe6bab5f03 |
@@ -1,65 +0,0 @@
|
|||||||
name: "Lint Commit Message Size"
|
|
||||||
|
|
||||||
on:
|
|
||||||
pull_request:
|
|
||||||
types: [opened, synchronize, reopened]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
check-commit-bounds:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Check out code
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
|
|
||||||
- name: Validate Line Count, Width, and Spacing
|
|
||||||
run: |
|
|
||||||
# Fetch commit hashes unique to this PR branch
|
|
||||||
COMMITS=$(git log --no-merges --pretty=format:"%H" origin/${{ github.base_ref }}..HEAD)
|
|
||||||
|
|
||||||
MAX_LINES=3
|
|
||||||
MAX_CHARS=90
|
|
||||||
FAILED=0
|
|
||||||
|
|
||||||
for commit in $COMMITS; do
|
|
||||||
SUBJECT=$(git log --format="%s" -n 1 $commit)
|
|
||||||
|
|
||||||
# Extract clean commit message, trimming trailing blank lines
|
|
||||||
RAW_MSG=$(git log --format="%B" -n 1 $commit)
|
|
||||||
CLEAN_MSG=$(echo "$RAW_MSG" | awk '{msg[NR]=$0} END {while(NR>0 && msg[NR]=="") NR--; for(i=1;i<=NR;i++) print msg[i]}')
|
|
||||||
|
|
||||||
# 1. Check total line count
|
|
||||||
LINE_COUNT=$(echo "$CLEAN_MSG" | wc -l)
|
|
||||||
if [ "$LINE_COUNT" -gt "$MAX_LINES" ]; then
|
|
||||||
echo "❌ Error: Commit message has too many lines ($LINE_COUNT/$MAX_LINES)."
|
|
||||||
echo " Commit: '$SUBJECT'"
|
|
||||||
FAILED=1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# 2. Check for multiple consecutive blank lines
|
|
||||||
# This regex looks for 2 or more empty lines anywhere in the message
|
|
||||||
if echo "$CLEAN_MSG" | grep -pz '(\r?\n){3,}'; then
|
|
||||||
echo "❌ Error: Commit message contains multiple consecutive line breaks."
|
|
||||||
echo " Commit: '$SUBJECT'"
|
|
||||||
FAILED=1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# 3. Check maximum width of any individual line
|
|
||||||
while IFS= read -r line; do
|
|
||||||
LINE_LENGTH=${#line}
|
|
||||||
if [ "$LINE_LENGTH" -gt "$MAX_CHARS" ]; then
|
|
||||||
echo "❌ Error: Line length exceeds limit ($LINE_LENGTH / $MAX_CHARS chars)."
|
|
||||||
echo " Offending line: '$line'"
|
|
||||||
FAILED=1
|
|
||||||
fi
|
|
||||||
done <<< "$CLEAN_MSG"
|
|
||||||
|
|
||||||
done
|
|
||||||
|
|
||||||
# Fail the job if any check failed
|
|
||||||
if [ "$FAILED" -ne 0 ]; then
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "✅ All commit messages passed style rules!"
|
|
||||||
+3
-3
@@ -1,6 +1,6 @@
|
|||||||
m4_pattern_allow([PKG_CHECK_EXISTS])
|
m4_pattern_allow([PKG_CHECK_EXISTS])
|
||||||
|
|
||||||
AC_INIT([rtorrent],[0.16.19],[sundell.software@gmail.com])
|
AC_INIT([rtorrent],[0.16.18],[sundell.software@gmail.com])
|
||||||
|
|
||||||
AC_CONFIG_HEADERS([config.h])
|
AC_CONFIG_HEADERS([config.h])
|
||||||
AC_CONFIG_MACRO_DIRS([scripts])
|
AC_CONFIG_MACRO_DIRS([scripts])
|
||||||
@@ -14,7 +14,7 @@ AX_CXX_COMPILE_STDCXX(20, noext, mandatory)
|
|||||||
|
|
||||||
PKG_PROG_PKG_CONFIG
|
PKG_PROG_PKG_CONFIG
|
||||||
|
|
||||||
AC_DEFINE([API_VERSION], [24], [api version])
|
AC_DEFINE([API_VERSION], [23], [api version])
|
||||||
|
|
||||||
RAK_CHECK_CFLAGS
|
RAK_CHECK_CFLAGS
|
||||||
RAK_CHECK_CXXFLAGS
|
RAK_CHECK_CXXFLAGS
|
||||||
@@ -47,7 +47,7 @@ fi
|
|||||||
|
|
||||||
PKG_CHECK_MODULES([CPPUNIT], [cppunit],, [no_cppunit="yes"])
|
PKG_CHECK_MODULES([CPPUNIT], [cppunit],, [no_cppunit="yes"])
|
||||||
PKG_CHECK_MODULES([ZLIB], [zlib])
|
PKG_CHECK_MODULES([ZLIB], [zlib])
|
||||||
PKG_CHECK_MODULES([DEPENDENCIES], [libtorrent >= 0.16.19])
|
PKG_CHECK_MODULES([DEPENDENCIES], [libtorrent >= 0.16.18])
|
||||||
|
|
||||||
AC_LANG_PUSH(C++)
|
AC_LANG_PUSH(C++)
|
||||||
TORRENT_WITH_XMLRPC_C
|
TORRENT_WITH_XMLRPC_C
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ group_insert(const torrent::Object::list_type& args) {
|
|||||||
rpc::commands.call("method.insert", rpc::create_object_list("group." + name + ".ratio.enable", "simple",
|
rpc::commands.call("method.insert", rpc::create_object_list("group." + name + ".ratio.enable", "simple",
|
||||||
"schedule=group." + name + ".ratio,5,60,on_ratio=" + name));
|
"schedule=group." + name + ".ratio,5,60,on_ratio=" + name));
|
||||||
rpc::commands.call("method.insert", rpc::create_object_list("group." + name + ".ratio.disable", "simple",
|
rpc::commands.call("method.insert", rpc::create_object_list("group." + name + ".ratio.disable", "simple",
|
||||||
"schedule.remove=group." + name + ".ratio"));
|
"schedule_remove=group." + name + ".ratio"));
|
||||||
rpc::commands.call("method.insert", rpc::create_object_list("group." + name + ".ratio.command", "simple",
|
rpc::commands.call("method.insert", rpc::create_object_list("group." + name + ".ratio.command", "simple",
|
||||||
"d.try_close= ;d.ignore_commands.set=1"));
|
"d.try_close= ;d.ignore_commands.set=1"));
|
||||||
rpc::commands.call("method.insert", rpc::create_object_list("group." + name + ".view", "string", view));
|
rpc::commands.call("method.insert", rpc::create_object_list("group." + name + ".view", "string", view));
|
||||||
@@ -250,12 +250,12 @@ initialize_command_local() {
|
|||||||
|
|
||||||
CMD_ANY (category_name + ".size", [category](auto, auto) { return torrent::runtime::socket_manager()->category_managed_size(category); });
|
CMD_ANY (category_name + ".size", [category](auto, auto) { return torrent::runtime::socket_manager()->category_managed_size(category); });
|
||||||
CMD_ANY (category_name + ".max_size", [category](auto, auto) { return torrent::runtime::socket_manager()->category_max_size(category); });
|
CMD_ANY (category_name + ".max_size", [category](auto, auto) { return torrent::runtime::socket_manager()->category_max_size(category); });
|
||||||
|
CMD_ANY (category_name + ".min_alloc", [category](auto, auto) { return torrent::runtime::socket_manager()->category_min_allocation(category); });
|
||||||
|
CMD_ANY (category_name + ".max_alloc", [category](auto, auto) { return torrent::runtime::socket_manager()->category_max_allocation(category); });
|
||||||
|
|
||||||
if (i == 0)
|
if (i == 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
CMD_ANY (category_name + ".min_alloc", [category](auto, auto) { return torrent::runtime::socket_manager()->category_min_allocation(category); });
|
|
||||||
CMD_ANY (category_name + ".max_alloc", [category](auto, auto) { return torrent::runtime::socket_manager()->category_max_allocation(category); });
|
|
||||||
CMD_ANY_VALUE_V(category_name + ".min_alloc.set", [category](auto, auto& value) { torrent::runtime::socket_manager()->set_category_min_allocation(category, value); });
|
CMD_ANY_VALUE_V(category_name + ".min_alloc.set", [category](auto, auto& value) { torrent::runtime::socket_manager()->set_category_min_allocation(category, value); });
|
||||||
CMD_ANY_VALUE_V(category_name + ".max_alloc.set", [category](auto, auto& value) { torrent::runtime::socket_manager()->set_category_max_allocation(category, value); });
|
CMD_ANY_VALUE_V(category_name + ".max_alloc.set", [category](auto, auto& value) { torrent::runtime::socket_manager()->set_category_max_allocation(category, value); });
|
||||||
}
|
}
|
||||||
@@ -354,10 +354,6 @@ initialize_command_local() {
|
|||||||
|
|
||||||
rpc::rpc.mark_safe(category_name + ".size");
|
rpc::rpc.mark_safe(category_name + ".size");
|
||||||
rpc::rpc.mark_safe(category_name + ".max_size");
|
rpc::rpc.mark_safe(category_name + ".max_size");
|
||||||
|
|
||||||
if (i == 0)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
rpc::rpc.mark_safe(category_name + ".min_alloc");
|
rpc::rpc.mark_safe(category_name + ".min_alloc");
|
||||||
rpc::rpc.mark_safe(category_name + ".max_alloc");
|
rpc::rpc.mark_safe(category_name + ".max_alloc");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,11 +2,12 @@
|
|||||||
#define RTORRENT_INPUT_INPUT_EVENT_H
|
#define RTORRENT_INPUT_INPUT_EVENT_H
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <torrent/system/event.h>
|
|
||||||
|
#include <torrent/event.h>
|
||||||
|
|
||||||
namespace input {
|
namespace input {
|
||||||
|
|
||||||
class InputEvent : public torrent::system::Event {
|
class InputEvent : public torrent::Event {
|
||||||
public:
|
public:
|
||||||
typedef std::function<void (int)> slot_int;
|
typedef std::function<void (int)> slot_int;
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#include "pid_watcher.h"
|
||||||
|
|
||||||
|
#include <cassert>
|
||||||
|
#include <torrent/exceptions.h>
|
||||||
|
|
||||||
|
PidWatcher::PidWatcher(std::thread::id thread_id)
|
||||||
|
: m_thread_id(thread_id) {
|
||||||
|
}
|
||||||
|
|
||||||
|
PidWatcher::~PidWatcher() = default;
|
||||||
|
|
||||||
|
void
|
||||||
|
PidWatcher::prepare_spawn() {
|
||||||
|
assert(std::this_thread::get_id() == m_thread_id);
|
||||||
|
|
||||||
|
if (m_spawn_in_progress.exchange(true, std::memory_order_acquire))
|
||||||
|
throw torrent::internal_error("PidWatcher::prepare_spawn() called while spawn already in progress.");
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
#ifndef RTORRENT_PID_WATCHER_H
|
||||||
|
#define RTORRENT_PID_WATCHER_H
|
||||||
|
|
||||||
|
#include <torrent/common.h>
|
||||||
|
|
||||||
|
struct atomic_queue {
|
||||||
|
std::array<std::atomic<pid_t>, 16> queue{};
|
||||||
|
|
||||||
|
|
||||||
|
class PidWatcher {
|
||||||
|
public:
|
||||||
|
PidWatcher(std::thread::id thread_id);
|
||||||
|
~PidWatcher();
|
||||||
|
|
||||||
|
void prepare_spawn();
|
||||||
|
void completed_spawn(pid_t pid);
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::thread::id m_thread_id;
|
||||||
|
|
||||||
|
align_cacheline
|
||||||
|
|
||||||
|
std::atomic<bool> m_spawn_in_progress{};
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
+2
-2
@@ -3,13 +3,13 @@
|
|||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <torrent/system/event.h>
|
#include <torrent/event.h>
|
||||||
|
|
||||||
#include "rpc/scgi_task.h"
|
#include "rpc/scgi_task.h"
|
||||||
|
|
||||||
namespace rpc {
|
namespace rpc {
|
||||||
|
|
||||||
class SCgi : public torrent::system::Event {
|
class SCgi : public torrent::Event {
|
||||||
public:
|
public:
|
||||||
static const int max_tasks = 100;
|
static const int max_tasks = 100;
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -4,13 +4,13 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <torrent/system/event.h>
|
#include <torrent/event.h>
|
||||||
|
|
||||||
namespace rpc {
|
namespace rpc {
|
||||||
|
|
||||||
class SCgi;
|
class SCgi;
|
||||||
|
|
||||||
class SCgiTask : public torrent::system::Event {
|
class SCgiTask : public torrent::Event {
|
||||||
public:
|
public:
|
||||||
static constexpr int default_buffer_size = 8191;
|
static constexpr int default_buffer_size = 8191;
|
||||||
static constexpr int max_header_size = 2000;
|
static constexpr int max_header_size = 2000;
|
||||||
|
|||||||
@@ -49,8 +49,6 @@ rtorrent_Test_Rpc_SOURCES = $(rtorrent_Test_Common) \
|
|||||||
rtorrent_Test_Src_SOURCES = $(rtorrent_Test_Common) \
|
rtorrent_Test_Src_SOURCES = $(rtorrent_Test_Common) \
|
||||||
src/test_command_dynamic.cc \
|
src/test_command_dynamic.cc \
|
||||||
src/test_command_dynamic.h \
|
src/test_command_dynamic.h \
|
||||||
src/test_command_local.cc \
|
|
||||||
src/test_command_local.h \
|
|
||||||
src/test_watch_ready_queue.cc \
|
src/test_watch_ready_queue.cc \
|
||||||
src/test_watch_ready_queue.h
|
src/test_watch_ready_queue.h
|
||||||
|
|
||||||
|
|||||||
@@ -2,10 +2,9 @@
|
|||||||
#define LIBTORRENT_HELPERS_MOCK_COMPARE_H
|
#define LIBTORRENT_HELPERS_MOCK_COMPARE_H
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <map>
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
#include <torrent/event.h>
|
||||||
#include <torrent/net/socket_address.h>
|
#include <torrent/net/socket_address.h>
|
||||||
#include <torrent/system/event.h>
|
|
||||||
|
|
||||||
// Compare arguments to mock functions with what is expected. The lhs
|
// Compare arguments to mock functions with what is expected. The lhs
|
||||||
// are the expected arguments, rhs are the ones called with.
|
// are the expected arguments, rhs are the ones called with.
|
||||||
@@ -14,13 +13,13 @@ template <typename Arg>
|
|||||||
inline bool mock_compare_arg(Arg lhs, Arg rhs) { return lhs == rhs; }
|
inline bool mock_compare_arg(Arg lhs, Arg rhs) { return lhs == rhs; }
|
||||||
|
|
||||||
template <int I, typename A, typename... Args>
|
template <int I, typename A, typename... Args>
|
||||||
std::enable_if_t<I == 1, int>
|
typename std::enable_if<I == 1, int>::type
|
||||||
mock_compare_tuple(const std::tuple<A, Args...>& lhs, const std::tuple<Args...>& rhs) {
|
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;
|
return mock_compare_arg(std::get<I>(lhs), std::get<I - 1>(rhs)) ? 0 : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <int I, typename A, typename... Args>
|
template <int I, typename A, typename... Args>
|
||||||
std::enable_if_t<1 < I, int>
|
typename std::enable_if<1 < I, int>::type
|
||||||
mock_compare_tuple(const std::tuple<A, Args...>& lhs, const std::tuple<Args...>& rhs) {
|
mock_compare_tuple(const std::tuple<A, Args...>& lhs, const std::tuple<Args...>& rhs) {
|
||||||
auto res = mock_compare_tuple<I - 1>(lhs, rhs);
|
auto res = mock_compare_tuple<I - 1>(lhs, rhs);
|
||||||
|
|
||||||
@@ -71,37 +70,24 @@ void mock_compare_add(T* v) {
|
|||||||
// Specialize:
|
// 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 <>
|
template <>
|
||||||
inline bool mock_compare_arg<sockaddr*>(sockaddr* lhs, sockaddr* rhs) {
|
inline bool mock_compare_arg<sockaddr*>(sockaddr* lhs, sockaddr* rhs) {
|
||||||
return lhs != nullptr && rhs != nullptr && torrent::sa_equal(lhs, rhs);
|
return lhs != nullptr && rhs != nullptr && torrent::sa_equal(lhs, rhs);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
inline bool mock_compare_arg<const sockaddr*>(const sockaddr* lhs, const sockaddr* rhs) {
|
inline bool mock_compare_arg<const sockaddr*>(const sockaddr* lhs, const sockaddr* rhs) {
|
||||||
return lhs != nullptr && rhs != nullptr && torrent::sa_equal(lhs, rhs);
|
return lhs != nullptr && rhs != nullptr && torrent::sa_equal(lhs, rhs);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
inline bool mock_compare_arg<torrent::system::Event*>(torrent::system::Event* lhs, torrent::system::Event* rhs) {
|
inline bool mock_compare_arg<torrent::Event*>(torrent::Event* lhs, torrent::Event* rhs) {
|
||||||
if (mock_compare_map<torrent::system::Event>::is_key(lhs)) {
|
if (mock_compare_map<torrent::Event>::is_key(lhs)) {
|
||||||
if (!mock_compare_map<torrent::system::Event>::has_value(rhs)) {
|
if (!mock_compare_map<torrent::Event>::has_value(rhs)) {
|
||||||
mock_compare_map<torrent::system::Event>::values[lhs] = rhs;
|
mock_compare_map<torrent::Event>::values[lhs] = rhs;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return mock_compare_map<torrent::system::Event>::has_key(lhs) && mock_compare_map<torrent::system::Event>::get(lhs) == rhs;
|
return mock_compare_map<torrent::Event>::has_key(lhs) && mock_compare_map<torrent::Event>::get(lhs) == rhs;
|
||||||
}
|
}
|
||||||
|
|
||||||
return lhs == rhs;
|
return lhs == rhs;
|
||||||
|
|||||||
@@ -6,9 +6,9 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include "torrent/event.h"
|
||||||
#include "torrent/net/socket_address.h"
|
#include "torrent/net/socket_address.h"
|
||||||
#include "torrent/net/fd.h"
|
#include "torrent/net/fd.h"
|
||||||
#include "torrent/system/event.h"
|
|
||||||
#include "torrent/utils/log.h"
|
#include "torrent/utils/log.h"
|
||||||
#include "torrent/utils/random.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_uint16);
|
||||||
MOCK_CLEANUP_MAP(torrent::random_uniform_uint32);
|
MOCK_CLEANUP_MAP(torrent::random_uniform_uint32);
|
||||||
|
|
||||||
mock_compare_map<torrent::system::Event>::values.clear();
|
mock_compare_map<torrent::Event>::values.clear();
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
@@ -55,9 +55,7 @@ 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__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__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) {
|
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)); }));
|
||||||
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); }));
|
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); }));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -114,6 +112,69 @@ int fd__socket(int domain, int type, int protocol) {
|
|||||||
return mock_call<int>(__func__, &torrent::fd__socket, domain, type, 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':
|
// Mock functions for 'torrent/utils/random.h':
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -1,54 +0,0 @@
|
|||||||
#include "config.h"
|
|
||||||
|
|
||||||
#include "test/src/test_command_local.h"
|
|
||||||
|
|
||||||
#include <torrent/torrent.h>
|
|
||||||
#include <torrent/runtime/socket_manager.h>
|
|
||||||
#include <torrent/utils/option_strings.h>
|
|
||||||
|
|
||||||
#include "control.h"
|
|
||||||
#include "globals.h"
|
|
||||||
#include "rpc/parse_commands.h"
|
|
||||||
|
|
||||||
CPPUNIT_TEST_SUITE_REGISTRATION(TestCommandLocal);
|
|
||||||
|
|
||||||
void initialize_command_local();
|
|
||||||
|
|
||||||
void
|
|
||||||
TestCommandLocal::setUp() {
|
|
||||||
torrent::initialize_main_thread();
|
|
||||||
torrent::initialize();
|
|
||||||
|
|
||||||
if (control == nullptr)
|
|
||||||
control = new Control;
|
|
||||||
|
|
||||||
if (!rpc::commands.has("system.sockets.size"))
|
|
||||||
initialize_command_local();
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
TestCommandLocal::tearDown() {
|
|
||||||
torrent::cleanup();
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
TestCommandLocal::test_socket_category_commands() {
|
|
||||||
for (uint32_t i = 0; i < torrent::runtime::SocketManager::category_count; ++i) {
|
|
||||||
auto category = static_cast<torrent::runtime::socket_manager_category_t>(i);
|
|
||||||
auto name = "system.sockets." + torrent::option_to_str_or_throw(torrent::OPTION_SOCKET_CATEGORY, i);
|
|
||||||
|
|
||||||
for (const auto suffix : {".size", ".max_size", ".min_alloc", ".max_alloc"})
|
|
||||||
if (rpc::commands.has(name + suffix))
|
|
||||||
CPPUNIT_ASSERT_NO_THROW(rpc::commands.call(name + suffix));
|
|
||||||
|
|
||||||
const bool has_allocation = category != torrent::runtime::category_generic;
|
|
||||||
|
|
||||||
CPPUNIT_ASSERT(rpc::commands.has(name + ".size"));
|
|
||||||
CPPUNIT_ASSERT(rpc::commands.has(name + ".max_size"));
|
|
||||||
|
|
||||||
CPPUNIT_ASSERT_EQUAL(has_allocation, rpc::commands.has(name + ".min_alloc"));
|
|
||||||
CPPUNIT_ASSERT_EQUAL(has_allocation, rpc::commands.has(name + ".max_alloc"));
|
|
||||||
CPPUNIT_ASSERT_EQUAL(has_allocation, rpc::commands.has(name + ".min_alloc.set"));
|
|
||||||
CPPUNIT_ASSERT_EQUAL(has_allocation, rpc::commands.has(name + ".max_alloc.set"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
#include "test/helpers/test_fixture.h"
|
|
||||||
|
|
||||||
class TestCommandLocal : public test_fixture {
|
|
||||||
CPPUNIT_TEST_SUITE(TestCommandLocal);
|
|
||||||
|
|
||||||
CPPUNIT_TEST(test_socket_category_commands);
|
|
||||||
|
|
||||||
CPPUNIT_TEST_SUITE_END();
|
|
||||||
|
|
||||||
public:
|
|
||||||
void setUp();
|
|
||||||
void tearDown();
|
|
||||||
|
|
||||||
void test_socket_category_commands();
|
|
||||||
};
|
|
||||||
Reference in New Issue
Block a user