feat: add skip-compress option
CI / lint (pull_request) Successful in 12s
CI / sanitizers (address) (pull_request) Successful in 36s
CI / sanitizers (undefined) (pull_request) Successful in 37s
CI / fuzz-build (pull_request) Successful in 15s
CI / coverage (pull_request) Successful in 31s
CI / build-and-test (pull_request) Successful in 1m16s
CI / valgrind (pull_request) Successful in 33s
CI / lint (pull_request) Successful in 12s
CI / sanitizers (address) (pull_request) Successful in 36s
CI / sanitizers (undefined) (pull_request) Successful in 37s
CI / fuzz-build (pull_request) Successful in 15s
CI / coverage (pull_request) Successful in 31s
CI / build-and-test (pull_request) Successful in 1m16s
CI / valgrind (pull_request) Successful in 33s
This commit is contained in:
@@ -52,6 +52,35 @@ class TestArchiveMode:
|
||||
assert not mismatches, f"Mismatch: {mismatches}"
|
||||
|
||||
|
||||
class TestSkipCompress:
|
||||
def test_skip_compress_case_insensitive(self, shared_server):
|
||||
clean_dir(DEST_DIR)
|
||||
with open(os.path.join(SOURCE_DIR, "skip-case.TXT"), "wb") as f:
|
||||
f.write((b"skip compression case test\n" * 100))
|
||||
result, _ = run_client(
|
||||
SOURCE_DIR, DEST_DIR,
|
||||
flags=["-c", "--skip-compress=.txt"],
|
||||
port=shared_server.port,
|
||||
)
|
||||
assert result.returncode == 0, f"Skip-compress sync failed: {(result.stderr or result.stdout)[:200]}"
|
||||
received = get_dest_received_dir(DEST_DIR, SOURCE_DIR)
|
||||
with open(os.path.join(received, "skip-case.TXT"), "rb") as f:
|
||||
assert f.read() == b"skip compression case test\n" * 100
|
||||
|
||||
def test_skip_compress_empty_list(self, shared_server):
|
||||
clean_dir(DEST_DIR)
|
||||
result, _ = run_client(
|
||||
SOURCE_DIR, DEST_DIR,
|
||||
flags=["-c", "--skip-compress="],
|
||||
port=shared_server.port,
|
||||
)
|
||||
assert result.returncode == 0, f"Empty skip-compress sync failed: {(result.stderr or result.stdout)[:200]}"
|
||||
received = get_dest_received_dir(DEST_DIR, SOURCE_DIR)
|
||||
mismatches, missing = verify_transfer(SOURCE_DIR, received)
|
||||
assert not missing, f"Missing: {missing}"
|
||||
assert not mismatches, f"Mismatch: {mismatches}"
|
||||
|
||||
|
||||
class TestExclude:
|
||||
def test_exclude_single(self, shared_server):
|
||||
clean_dir(DEST_DIR)
|
||||
|
||||
@@ -247,6 +247,32 @@ static void test_parse_args_valid_compression_level() {
|
||||
config_delete(cfg);
|
||||
}
|
||||
|
||||
static void test_parse_args_skip_compress() {
|
||||
Config* cfg = config_create();
|
||||
char* argv[] = {"fastsync", "--skip-compress=.ZIP, .GZ", "/src", "/dst"};
|
||||
int positional_args[2];
|
||||
int positional_count = 0;
|
||||
|
||||
EXPECT_EQ_INT(parse_args(cfg, 4, argv, positional_args, &positional_count), 0);
|
||||
EXPECT_TRUE(cfg->skip_compress_set);
|
||||
EXPECT_EQ_INT(cfg->skip_compress_count, 2);
|
||||
EXPECT_EQ_STR(cfg->skip_compress_suffixes[0], ".ZIP");
|
||||
EXPECT_EQ_STR(cfg->skip_compress_suffixes[1], ".GZ");
|
||||
config_delete(cfg);
|
||||
}
|
||||
|
||||
static void test_parse_args_empty_skip_compress() {
|
||||
Config* cfg = config_create();
|
||||
char* argv[] = {"fastsync", "--skip-compress=", "/src", "/dst"};
|
||||
int positional_args[2];
|
||||
int positional_count = 0;
|
||||
|
||||
EXPECT_EQ_INT(parse_args(cfg, 4, argv, positional_args, &positional_count), 0);
|
||||
EXPECT_TRUE(cfg->skip_compress_set);
|
||||
EXPECT_EQ_INT(cfg->skip_compress_count, 0);
|
||||
config_delete(cfg);
|
||||
}
|
||||
|
||||
/* Test parse_args unknown option returns error */
|
||||
static void test_parse_args_unknown_option() {
|
||||
Config* cfg = config_create();
|
||||
@@ -357,6 +383,8 @@ void test_client_cli() {
|
||||
test_parse_args_invalid_server_port();
|
||||
test_parse_args_invalid_compression_level();
|
||||
test_parse_args_valid_compression_level();
|
||||
test_parse_args_skip_compress();
|
||||
test_parse_args_empty_skip_compress();
|
||||
test_parse_args_unknown_option();
|
||||
test_parse_args_rejects_unimplemented_options();
|
||||
test_parse_args_archive();
|
||||
|
||||
@@ -55,6 +55,14 @@ static void test_data_compress_decompress_large() {
|
||||
data_destroy(decompressed);
|
||||
}
|
||||
|
||||
static void test_skip_compress_suffix_matching() {
|
||||
char* suffixes[] = {".ZIP", ".GZ"};
|
||||
EXPECT_TRUE(compression_should_skip_with_suffixes("archive.zip", suffixes, 2));
|
||||
EXPECT_TRUE(compression_should_skip_with_suffixes("backup.TAR.GZ", suffixes, 2));
|
||||
EXPECT_FALSE(compression_should_skip_with_suffixes("notes.txt", suffixes, 2));
|
||||
EXPECT_FALSE(compression_should_skip_with_suffixes("archive.zip", suffixes, 0));
|
||||
}
|
||||
|
||||
static void test_chunk_compress_decompress_roundtrip() {
|
||||
char* path1 = "temp_comp_test_1.txt";
|
||||
char* content1 = "chunk compression test file 1";
|
||||
@@ -115,5 +123,6 @@ static void test_chunk_compress_decompress_roundtrip() {
|
||||
void test_compression() {
|
||||
test_data_compress_decompress_roundtrip();
|
||||
test_data_compress_decompress_large();
|
||||
test_skip_compress_suffix_matching();
|
||||
test_chunk_compress_decompress_roundtrip();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user