mkdtemp → test_mkdtemp из test_utils.h для кроссплатформенной сборки (MSYS2/MinGW)
This commit is contained in:
1 parent
98f3049e6b
commit
ebd975a03b
3 files changed
+7
-12
No files matched your search
@@ -16,6 +16,7 @@
|
||||
#include "../lib/u_async.h"
|
||||
#include "../lib/debug_config.h"
|
||||
#include "../lib/mem.h"
|
||||
#include "test_utils.h"
|
||||
#include "../transport_layer/secure_channel.h"
|
||||
#include "../routing_layer/topo_node_sqlite.h"
|
||||
#include "../routing_layer/conn_mgr.h"
|
||||
@@ -57,7 +58,7 @@ static int file_size(const char* path) {
|
||||
|
||||
static void test_setup(void) {
|
||||
snprintf(g_temp_dir, sizeof(g_temp_dir), "%s", TEMP_DIR);
|
||||
if (!mkdtemp(g_temp_dir)) { fprintf(stderr, "mkdtemp failed\n"); exit(1); }
|
||||
if (test_mkdtemp(g_temp_dir) != 0) { fprintf(stderr, "mkdtemp failed\n"); exit(1); }
|
||||
debug_config_init(); debug_set_level(DEBUG_LEVEL_ERROR);
|
||||
g_ua = uasync_create();
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "../lib/u_async.h"
|
||||
#include "../lib/debug_config.h"
|
||||
#include "../lib/mem.h"
|
||||
#include "test_utils.h"
|
||||
|
||||
#include <sqlite3.h>
|
||||
#include <openssl/evp.h>
|
||||
@@ -60,7 +61,6 @@ static char* gv(const char* p, const char* k) {
|
||||
char* r = (strcmp(k, "pub") == 0) ? u_strdup(c->global.my_public_key_hex) : u_strdup(c->global.my_private_key_hex);
|
||||
free_config(c); return r;
|
||||
}
|
||||
static void t_mkdtemp(char* t) { (void)!mkdtemp(t); }
|
||||
static void t_rmdir(const char* p) { char cmd[512]; snprintf(cmd, sizeof(cmd), "rm -rf %s", p); system(cmd); }
|
||||
|
||||
static int db_count(sqlite3* db, const char* tbl, const char* wh, uint64_t val) {
|
||||
@@ -308,7 +308,7 @@ int main(void) {
|
||||
utun_instance_set_tun_init_enabled(0);
|
||||
srand((unsigned)time(NULL));
|
||||
printf("=== test_media_delivery_full ===\n");
|
||||
t_mkdtemp(g_tdir);
|
||||
test_mkdtemp(g_tdir);
|
||||
|
||||
for (int i = 0; i < N_NODES; i++) {
|
||||
snprintf(g_cfg[i], sizeof(g_cfg[i]), "%s/n%d.conf", g_tdir, i);
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "../transport_layer/etcp.h"
|
||||
#include "../config_parser.h"
|
||||
#include "../config_updater.h"
|
||||
#include "test_utils.h"
|
||||
#include "../routing_layer/topo_group.h"
|
||||
#include "../routing_layer/topo_node.h"
|
||||
#include "../lib/u_async.h"
|
||||
@@ -58,14 +59,7 @@ static char* gv(const char* p, const char* k) {
|
||||
free_config(c); return r;
|
||||
}
|
||||
|
||||
static void test_mkdtemp(char* tmpl) {
|
||||
(void)!mkdtemp(tmpl);
|
||||
}
|
||||
|
||||
static void test_unlink(const char* p) { unlink(p); }
|
||||
static void test_rmdir(const char* p) {
|
||||
char cmd[512]; snprintf(cmd, sizeof(cmd), "rm -rf %s", p); system(cmd);
|
||||
}
|
||||
/* ── helpers ── */
|
||||
|
||||
static int count_rows(sqlite3* db, const char* tbl, const char* where, uint64_t val) {
|
||||
char sql[256];
|
||||
@@ -303,6 +297,6 @@ done:
|
||||
if (g_a) { g_a->running = 0; utun_instance_destroy(g_a); g_a = NULL; }
|
||||
if (g_b) { g_b->running = 0; utun_instance_destroy(g_b); g_b = NULL; }
|
||||
if (g_ua) { uasync_destroy(g_ua, 0); g_ua = NULL; }
|
||||
test_rmdir(g_tdir);
|
||||
{ char cmd[512]; snprintf(cmd, sizeof(cmd), "rm -rf %s", g_tdir); system(cmd); }
|
||||
return g_failed > 0 ? 1 : 0;
|
||||
}
|
||||
Reference in new issue
Block a user