testing: add comprehensive test suite for test-driven development
CI / lint (push) Failing after 3s
CI / build-and-test (push) Has been skipped
CI / sanitizers (address) (push) Has been skipped
CI / coverage (push) Has been skipped
CI / valgrind (push) Has been skipped
CI / lint (pull_request) Failing after 2s
CI / build-and-test (pull_request) Has been skipped
CI / sanitizers (address) (pull_request) Has been skipped
CI / coverage (pull_request) Has been skipped
CI / valgrind (pull_request) Has been skipped
CI / lint (push) Failing after 3s
CI / build-and-test (push) Has been skipped
CI / sanitizers (address) (push) Has been skipped
CI / coverage (push) Has been skipped
CI / valgrind (push) Has been skipped
CI / lint (pull_request) Failing after 2s
CI / build-and-test (pull_request) Has been skipped
CI / sanitizers (address) (pull_request) Has been skipped
CI / coverage (pull_request) Has been skipped
CI / valgrind (pull_request) Has been skipped
Add unit tests for previously untested modules (protocol, data, metadata, file, glob), robustness tests for deserialization of malformed inputs, thread safety stress tests, property-based roundtrip tests, and 6 fuzz targets. Update CI with CTest integration, coverage reporting, and valgrind memory checking. New test files: - test_data.c: Data type lifecycle (5 tests) - test_protocol.c: Protocol I/O roundtrips and error paths (9 tests) - test_metadata.c: Metadata serialization roundtrips (6 tests) - test_file.c: File operations and send/receive (12 tests) - test_glob.c: Glob pattern matching (10 tests) - test_robustness.c: Malformed input handling for chunk/delta/protocol (11 tests) - test_stress.c: MPMC queue stress, backpressure, rapid create/destroy (3 tests) - test_property.c: Compress, delta, chunk, glob roundtrip properties (4 tests) - tests/fuzz/: 6 libFuzzer targets for deserialization functions Extended existing tests: - test_config.c: config_send/config_receive roundtrip via fork+pipe - test_shared_utils.c: mkdir_r, glob_match, delete_extras Infrastructure: - CTest integration in CMakeLists.txt - Coverage support (-DENABLE_COVERAGE=ON) - Fuzz target support (-DENABLE_FUZZ=ON) - CI: coverage, valgrind, address sanitizer jobs - Fixed MPMC stress test race condition (cnd_signal -> cnd_broadcast)
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
#include "test_glob.h"
|
||||
#include "utils.h"
|
||||
#include "test_utils.h"
|
||||
#include <string.h>
|
||||
|
||||
static void test_glob_exact_match() {
|
||||
EXPECT_TRUE(glob_match("foo", "foo"));
|
||||
}
|
||||
|
||||
static void test_glob_question_mark() {
|
||||
EXPECT_TRUE(glob_match("f?o", "foo"));
|
||||
EXPECT_FALSE(glob_match("f?o", "fo"));
|
||||
}
|
||||
|
||||
static void test_glob_star() {
|
||||
EXPECT_TRUE(glob_match("*.txt", "foo.txt"));
|
||||
EXPECT_TRUE(glob_match("*.txt", "a.txt"));
|
||||
}
|
||||
|
||||
static void test_glob_star_mid() {
|
||||
EXPECT_TRUE(glob_match("f*o", "foo"));
|
||||
EXPECT_TRUE(glob_match("f*o", "fxxo"));
|
||||
EXPECT_FALSE(glob_match("f*o", "bar"));
|
||||
}
|
||||
|
||||
static void test_glob_no_match() {
|
||||
EXPECT_FALSE(glob_match("foo", "bar"));
|
||||
}
|
||||
|
||||
static void test_glob_empty_pattern() {
|
||||
EXPECT_TRUE(glob_match("", ""));
|
||||
EXPECT_FALSE(glob_match("", "foo"));
|
||||
}
|
||||
|
||||
static void test_glob_star_all() {
|
||||
EXPECT_TRUE(glob_match("*", "anything"));
|
||||
}
|
||||
|
||||
static void test_glob_slash_not_matched() {
|
||||
EXPECT_FALSE(glob_match("f*o", "f/o"));
|
||||
}
|
||||
|
||||
static void test_glob_complex() {
|
||||
EXPECT_TRUE(glob_match("*.c", "main.c"));
|
||||
EXPECT_FALSE(glob_match("*.c", "main.h"));
|
||||
}
|
||||
|
||||
static void test_glob_question_star() {
|
||||
EXPECT_TRUE(glob_match("?*.txt", "a.txt"));
|
||||
}
|
||||
|
||||
void test_glob() {
|
||||
test_glob_exact_match();
|
||||
test_glob_question_mark();
|
||||
test_glob_star();
|
||||
test_glob_star_mid();
|
||||
test_glob_no_match();
|
||||
test_glob_empty_pattern();
|
||||
test_glob_star_all();
|
||||
test_glob_slash_not_matched();
|
||||
test_glob_complex();
|
||||
test_glob_question_star();
|
||||
}
|
||||
Reference in New Issue
Block a user