Files
FastSync/tests/test_config.c
T
TapTap fbd7ccf4dd feat: add SSH transport, rsync-style CLI, and --stdio server mode
- Replace send()/recv() with read()/write() + io_set_fds() for fd abstraction
- Add client_connect_ssh() via socketpair + fork/exec; reap child in client_disconnect()
- Add server --stdio flag for SSH invocation
- Replace handle_arg() with rsync-style positional args (fastsync <src> <dest>)
- Add SSH vs TCP auto-detection via is_remote_dest()
- Add TransportType and ssh_destination to Config, fix uninitialized fields in
  config_receive() (pre-existing multithreaded crash)
- Sender threads now wait for server STATUS_OK before disconnecting
- Add --help, error handling for sendfile+SSH combos
- Add pre-flight checks and Posix Args test case to test.py
- Add test_config_ssh_dest() unit test
2026-07-06 18:42:33 +02:00

76 lines
2.6 KiB
C

#include "test_config.h"
#include "config.h"
#include "multiprocessing.h"
#include "queue.h"
#include "test_utils.h"
#include "utils.h"
#include <stdlib.h>
static void test_config_lifecycle() {
Config *cfg = config_create(str_dup("1.0"), str_dup("/src"), str_dup("/dst"),
true, true, false, false, false, 1, 4, false);
EXPECT_NOT_NULL(cfg);
EXPECT_EQ_STR(cfg->version, "1.0");
EXPECT_EQ_STR(cfg->send_directory, "/src");
EXPECT_EQ_STR(cfg->receive_root_directory, "/dst");
EXPECT_TRUE(cfg->save_to_disk);
EXPECT_TRUE(cfg->use_multithreading);
EXPECT_FALSE(cfg->use_chunk_serialization);
EXPECT_FALSE(cfg->use_compression);
EXPECT_EQ_INT(cfg->num_connections, 4);
EXPECT_EQ_INT(cfg->transport, TRANSPORT_TCP);
EXPECT_NULL(cfg->ssh_destination);
config_delete(cfg);
}
static void test_config_ssh_dest() {
Config *cfg = config_create(str_dup("1.0"), str_dup("/src"), str_dup("user@host:/dst"),
true, false, false, false, false, 1, 4, false);
cfg->transport = TRANSPORT_SSH;
cfg->ssh_destination = str_dup("user@host:/dst");
EXPECT_NOT_NULL(cfg);
EXPECT_EQ_INT(cfg->transport, TRANSPORT_SSH);
EXPECT_EQ_STR(cfg->ssh_destination, "user@host:/dst");
EXPECT_EQ_STR(cfg->receive_root_directory, "user@host:/dst");
config_delete(cfg);
}
static void test_pipeline_sender_lifecycle() {
Config *cfg = config_create(str_dup("2.0"), str_dup("/src2"),
str_dup("/dst2"), false, false, true, true, false, 1, 8, false);
Queue *q1 = queue_create(5, NULL);
Queue *q2 = queue_create(15, NULL);
PipelineContextSender *pcs = pipeline_context_sender_create(cfg, q1, q2);
EXPECT_NOT_NULL(pcs);
EXPECT_EQ_STR(pcs->config->version, "2.0");
EXPECT_EQ_INT(pcs->queue_scanner->capacity, 5);
EXPECT_EQ_INT(pcs->queue_loader->capacity, 15);
EXPECT_FALSE(pcs->scanner_done);
EXPECT_FALSE(pcs->loader_done);
pipeline_context_sender_destroy(pcs);
}
static void test_pipeline_receiver_lifecycle() {
Config *cfg = config_create(str_dup("3.0"), str_dup("/src3"),
str_dup("/dst3"), true, true, true, true, false, 1, 2, false);
Queue *q = queue_create(20, NULL);
PipelineContextReceiver *pcr = pipeline_context_receiver_create(cfg, q, 42);
EXPECT_NOT_NULL(pcr);
EXPECT_EQ_STR(pcr->config->version, "3.0");
EXPECT_EQ_INT(pcr->queue->capacity, 20);
EXPECT_EQ_INT(pcr->file_descriptor, 42);
EXPECT_FALSE(pcr->receiver_done);
pipeline_context_receiver_destroy(pcr);
}
void test_config() {
test_config_lifecycle();
test_config_ssh_dest();
test_pipeline_sender_lifecycle();
test_pipeline_receiver_lifecycle();
}