mirror of
https://github.com/shadowsocks/shadowsocks-libev.git
synced 2026-10-20 21:43:41 +00:00
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.
27 lines
1.2 KiB
C++
27 lines
1.2 KiB
C++
/* 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
|