fix(test): stop the valgrind hang, init per_dir_filter_count #299

Merged
TapTap merged 1 commits from fix/valgrind-hang into dev 2026-09-17 23:47:48 +02:00
3 changed files with 21 additions and 4 deletions
+1
View File
@@ -76,6 +76,7 @@ static void config_set_defaults(Config* config) {
config->from0 = false; config->from0 = false;
config->cvs_exclude = false; config->cvs_exclude = false;
config->per_dir_filter = false; config->per_dir_filter = false;
config->per_dir_filter_count = 0;
config->one_file_system = false; config->one_file_system = false;
config->no_implied_dirs = false; config->no_implied_dirs = false;
config->dirs = false; config->dirs = false;
+3
View File
@@ -213,5 +213,8 @@ void test_iconv() {
test_iconv_wire_sender_converts_local_to_remote(); test_iconv_wire_sender_converts_local_to_remote();
test_iconv_wire_receiver_converts_remote_to_local(); test_iconv_wire_receiver_converts_remote_to_local();
test_iconv_wire_disabled_passthrough(); test_iconv_wire_disabled_passthrough();
// This subtest forks to exercise the wire string handshake; the instrumented
// parent is too slow under valgrind for the child's blocking reads.
if (!is_running_under_valgrind())
test_iconv_wire_str_roundtrip(); test_iconv_wire_str_roundtrip();
} }
+16 -3
View File
@@ -6,10 +6,22 @@
#include <string.h> #include <string.h>
#include <stdbool.h> #include <stdbool.h>
// Detect if running under valgrind by checking /proc/self/maps for vgpreload. // Reset the thread-local protocol descriptor redirection installed by
// This is used to skip fork-based tests that are incompatible with valgrind // io_set_fds(), so a suite that leaks a test pipe's fds cannot redirect a later
// (the instrumented parent runs too slowly, causing pipe timeouts). // suite's raw send_n_data()/receive_n_data() to the wrong descriptor.
void io_set_fds(int read_fd, int write_fd);
// Detect if running under valgrind. The CI valgrind step exports
// FASTSYNC_UNDER_VALGRIND=1; a /proc/self/maps scan is the fallback for a local
// valgrind run (newer valgrind versions can hide their own mappings from the
// guest, so the "vgpreload" match is not reliable on every version -- set
// FASTSYNC_UNDER_VALGRIND=1 when invoking valgrind by hand). Used to skip
// fork-based tests incompatible with valgrind, whose instrumented parent runs
// too slowly and causes pipe timeouts.
static inline bool is_running_under_valgrind(void) { static inline bool is_running_under_valgrind(void) {
const char* env = getenv("FASTSYNC_UNDER_VALGRIND");
if (env && env[0] != '\0' && strcmp(env, "0") != 0)
return true;
FILE* f = fopen("/proc/self/maps", "r"); FILE* f = fopen("/proc/self/maps", "r");
if (!f) if (!f)
return false; return false;
@@ -31,6 +43,7 @@ extern bool current_test_failed;
printf("Running %s...\n", #test_func); \ printf("Running %s...\n", #test_func); \
tests_run++; \ tests_run++; \
current_test_failed = false; \ current_test_failed = false; \
io_set_fds(-1, -1); \
test_func(); \ test_func(); \
if (current_test_failed) { \ if (current_test_failed) { \
tests_failed++; \ tests_failed++; \