mirror of
https://github.com/shadowsocks/shadowsocks-libev.git
synced 2026-09-25 18:33:56 +00:00
Bundle pinned offline dependencies, remove libcork/libipset and submodule requirements, and add portable runtime helpers with relocatable static/shared library installations.
Add Clang static build validation for Linux/musl, macOS and Windows, real TCP/UDP and SIP003 interoperability coverage, and recorded performance tradeoffs. All 21 hosted checks pass at the reviewed PR head 8d504e6218.
39 lines
920 B
C
39 lines
920 B
C
#ifndef SS_TEST_HELPERS_H
|
|
#define SS_TEST_HELPERS_H
|
|
#include <assert.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include "platform.h"
|
|
|
|
static inline void test_network_cleanup(void)
|
|
{
|
|
#ifdef _WIN32
|
|
WSACleanup();
|
|
#endif
|
|
}
|
|
static inline void test_network_init(void)
|
|
{
|
|
#ifdef _WIN32
|
|
WSADATA data;
|
|
assert(WSAStartup(MAKEWORD(2, 2), &data) == 0);
|
|
assert(atexit(test_network_cleanup) == 0);
|
|
#endif
|
|
}
|
|
static inline FILE *test_tempfile(char *path, size_t size)
|
|
{
|
|
#ifdef _WIN32
|
|
char directory[MAX_PATH];
|
|
DWORD length = GetTempPathA(sizeof(directory), directory);
|
|
assert(length != 0 && length < sizeof(directory));
|
|
assert(size >= MAX_PATH);
|
|
assert(GetTempFileNameA(directory, "ssc", 0, path) != 0);
|
|
return fopen(path, "w");
|
|
#else
|
|
assert(snprintf(path, size, "/tmp/ss-test.XXXXXX") < (int)size);
|
|
int fd = mkstemp(path);
|
|
assert(fd >= 0);
|
|
return fdopen(fd, "w");
|
|
#endif
|
|
}
|
|
#endif
|