mirror of
https://github.com/shadowsocks/shadowsocks-libev.git
synced 2026-11-22 05:33:45 +00:00
Add C++20 ownership and allocation core
Header-only primitives for the no-heap-after-startup design: Result/Status, Region, ObjectPool with PoolPtr (std::unique_ptr with a pool deleter), generation-checked Handle and asynchronous close support, intrusive RefPtr, FixedBuffer, MonotonicArena, FixedHashMap and FixedLru, IntrusiveList, and a bounded FixedHeap for third-party allocator hooks. Unit tests cover each primitive (test_core_*). scripts/check_no_heap.py rejects heap allocation in C++ sources under src/ and runs as a ctest. clang-tidy now also analyses C++ sources and the core headers.
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
/* SPDX-License-Identifier: GPL-3.0-or-later */
|
||||
#ifndef SS_TEST_HELPERS_HPP
|
||||
#define SS_TEST_HELPERS_HPP
|
||||
|
||||
// Minimal harness for the C++ unit tests. Tests are built without
|
||||
// exceptions, so a failed check reports its location and aborts.
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
|
||||
#define SS_CHECK(...) \
|
||||
do { \
|
||||
if (!(__VA_ARGS__)) { \
|
||||
std::fprintf(stderr, "%s:%d: check failed: %s\n", __FILE__, \
|
||||
__LINE__, #__VA_ARGS__); \
|
||||
std::abort(); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define SS_RUN(test) \
|
||||
do { \
|
||||
test(); \
|
||||
std::printf("ok %s\n", #test); \
|
||||
} while (0)
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user