Modernize build: switch to CMake, add unit tests, fix man pages

Remove autotools (configure.ac, Makefile.am, m4/, autogen.sh) and make
CMake the sole build system. Enhance CMake with proper Find modules for
MbedTLS, libsodium, PCRE, and c-ares with version/feature detection.
Add support for connmarktos, nftables, stack protector, and MinGW.

Add 10 unit test suites (CTest) covering base64, buffer, cache, crypto,
jconf, json, netutils, ppbloom, rule, and utils modules. Add a Python
stress test measuring bandwidth per cipher with memory leak detection.

Fix man page typos ("Resovle" -> "Resolve"), document missing TCP buffer
options, fix ss-manager duplicate --executable entry, add example section
to ss-tunnel, and document --workdir and --nftables-sets options.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Max Lv
2026-02-07 16:40:27 +08:00
committed by Max Lv
co-authored by Claude Opus 4.6
parent b2a0c545d8
commit 1c404eccf4
45 changed files with 2221 additions and 1965 deletions
+103
View File
@@ -0,0 +1,103 @@
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <assert.h>
#include <string.h>
#include <stdlib.h>
int verbose = 0;
#include "crypto.h"
/* Provide nonce_cache symbol needed by crypto.c */
struct cache *nonce_cache = NULL;
static void
test_balloc(void)
{
buffer_t buf;
memset(&buf, 0, sizeof(buf));
int ret = balloc(&buf, 100);
assert(ret == 0);
(void)ret;
assert(buf.data != NULL);
assert(buf.capacity >= 100);
assert(buf.len == 0);
assert(buf.idx == 0);
bfree(&buf);
assert(buf.data == NULL);
assert(buf.capacity == 0);
}
static void
test_brealloc(void)
{
buffer_t buf;
memset(&buf, 0, sizeof(buf));
balloc(&buf, 50);
buf.len = 10;
/* Grow the buffer */
int ret = brealloc(&buf, 10, 200);
assert(ret == 0);
(void)ret;
assert(buf.capacity >= 200);
assert(buf.len == 10);
bfree(&buf);
}
static void
test_bprepend(void)
{
buffer_t dst, src;
memset(&dst, 0, sizeof(dst));
memset(&src, 0, sizeof(src));
balloc(&dst, 100);
balloc(&src, 100);
/* Put some data in src */
memcpy(src.data, "HEADER", 6);
src.len = 6;
/* Put some data in dst */
memcpy(dst.data, "BODY", 4);
dst.len = 4;
int ret = bprepend(&dst, &src, 200);
assert(ret == 0);
(void)ret;
assert(dst.len == 10);
assert(memcmp(dst.data, "HEADERBODY", 10) == 0);
bfree(&dst);
bfree(&src);
}
static void
test_balloc_zero(void)
{
buffer_t buf;
memset(&buf, 0, sizeof(buf));
int ret = balloc(&buf, 0);
assert(ret == 0);
(void)ret;
/* A zero-capacity buffer should still succeed */
bfree(&buf);
}
int
main(void)
{
test_balloc();
test_brealloc();
test_bprepend();
test_balloc_zero();
return 0;
}