static void _generate_messages(TestThreadedDestDriver *dd, gint n) { LogMessage *msg; LogPathOptions path_options = LOG_PATH_OPTIONS_INIT_NOACK; gchar buf[32]; for (gint i = 0; i < n; i++) { msg = create_sample_message(); g_snprintf(buf, sizeof(buf), "%d", i); log_msg_set_value(msg, LM_V_PID, buf, -1); log_pipe_queue(&dd->super.super.super.super, msg, &path_options); } }
static void setup() { fail_unless((settings = smf_settings_new()) != NULL); smf_settings_set_queue_dir(settings, BINARY_DIR); fail_unless((session = smf_session_new()) != NULL); queue = smf_modules_pqueue_init(error_cb, processing_error_cb, nexthop_error_cb); fail_unless(queue != NULL); create_sample_message(session, SAMPLES_DIR "/m0001.txt"); create_spoolfile(session, SAMPLES_DIR "/m0001.txt"); init_cb_data(&mod1_data); init_cb_data(&mod2_data); init_cb_data(&mod3_data); init_cb_data(&error_data); init_cb_data(&processing_error_data); init_cb_data(&nexthop_error_data); }
assert_string(result->str, expected, "multi-threaded formatting yielded invalid result (iteration: %d)", i); } g_string_free(result, TRUE); return NULL; } static void assert_template_format_multi_thread(const gchar *template, const gchar *expected) { LogTemplate *templ; LogMessage *msg; gpointer args[3]; GThread *threads[16]; gint i; msg = create_sample_message(); templ = compile_template(template); args[0] = msg; args[1] = templ; args[2] = (gpointer) expected; thread_start = FALSE; thread_ping = g_cond_new(); thread_lock = g_mutex_new(); args[1] = templ; for (i = 0; i < 16; i++) { threads[i] = g_thread_create(format_template_thread, args, TRUE, NULL); } thread_start = TRUE;