static void stub_equal_error (void) { error1 = g_error_new(G_FILE_ERROR, G_FILE_ERROR_NOENT, "not found"); error2 = g_error_new(G_FILE_ERROR, G_FILE_ERROR_NOENT, "not found"); gcut_assert_equal_error(error1, error2); g_error_free(error2); error2 = g_error_new(G_FILE_ERROR, G_FILE_ERROR_NOENT, "no entry"); MARK_FAIL(gcut_assert_equal_error(error1, error2)); }
void test_not_remove_unix_socket_on_create (void) { const gchar *path; GError *error = NULL; path = cut_take_printf("%s/milter.sock", tmp_dir); spec = cut_take_printf("unix:%s", path); g_file_set_contents(path, "", 0, &error); gcut_assert_error(error); milter_client_set_remove_unix_socket_on_create(client, FALSE); cut_trace(setup_client()); cut_assert_false(milter_client_run(client, &error)); gcut_assert_error(actual_error); actual_error = error; expected_error = g_error_new(MILTER_CONNECTION_ERROR, MILTER_CONNECTION_ERROR_BIND_FAILURE, "failed to bind(): %s: %s", spec, g_strerror(EADDRINUSE)); gcut_assert_equal_error(expected_error, actual_error); }
void test_flags (void) { GError *error = NULL; process = gcut_process_new("echo", "XXX", NULL); setup_process(process); gcut_process_set_flags(process, 0); cut_assert_false(gcut_process_get_flags(process) & G_SPAWN_SEARCH_PATH); cut_assert_false(gcut_process_run(process, &actual_error)); expected_error = g_error_new(G_SPAWN_ERROR, G_SPAWN_ERROR_NOENT, "Failed to execute child process \"%s\" (%s)", "echo", g_strerror(ENOENT)); gcut_assert_equal_error(expected_error, actual_error); gcut_process_set_flags(process, G_SPAWN_SEARCH_PATH); gcut_process_run(process, &error); gcut_assert_error(error); wait_exited(); cut_assert_equal_string("XXX\n", output_string->str); cut_assert_equal_string("", error_string->str); }
void test_get_flags (gconstpointer data) { const EnumTestData *test_data = data; GError *error = NULL; guint flags_value; g_key_file_load_from_data(key_file, test_data->data, strlen(test_data->data), 0, &error); gcut_assert_error(error); flags_value = gcut_key_file_get_flags(key_file, test_data->group_name, test_data->key_name, test_data->type, &error); if (test_data->expected_error) { actual_error = error; gcut_assert_equal_error(test_data->expected_error, actual_error); } else { gcut_assert_error(error); } gcut_assert_equal_flags(test_data->type, test_data->expected_flags_value, flags_value); }
void test_open_no_device (void) { expected_error = g_error_new(GPDS_XINPUT_UTILS_ERROR, GPDS_XINPUT_UTILS_ERROR_NO_DEVICE, "No Invalid device found."); device = gpds_xinput_utils_open_device("Invalid device", &error); gcut_assert_equal_error(expected_error, error); }
void test_set_reply (gconstpointer data) { const ReplyTestData *test_data = data; actual_error = set_reply(test_data->code, test_data->extended_code, test_data->message); gcut_assert_equal_error(test_data->expected_error, actual_error); }
void test_wait_before_run (void) { process = gcut_process_new(cuttest_echo_path, "XXX", NULL); cut_assert_equal_int(-1, gcut_process_wait(process, 0, &actual_error)); expected_error = g_error_new(GCUT_PROCESS_ERROR, GCUT_PROCESS_ERROR_NOT_RUNNING, "not running: <%s XXX>", cuttest_echo_path); gcut_assert_equal_error(expected_error, actual_error); }
void test_decode_unknown (void) { gchar unknown_command[] = "unknown"; g_string_append(buffer, unknown_command); g_string_append_c(buffer, '\0'); expected_error = g_error_new( MILTER_MANAGER_CONTROL_COMMAND_DECODER_ERROR, MILTER_MANAGER_CONTROL_COMMAND_DECODER_ERROR_UNEXPECTED_COMMAND, "unexpected command was received: <%s>", unknown_command); actual_error = decode(); gcut_assert_equal_error(expected_error, actual_error); }
void grn_test_assert_fail_open_hash_helper(grn_hash **hash, GrnTestHashFactory *factory) { GError *expected_error = NULL; GError *actual_error = NULL; *hash = grn_test_hash_factory_open(factory, &actual_error); expected_error = g_error_new(GRN_TEST_HASH_FACTORY_ERROR, GRN_TEST_HASH_FACTORY_ERROR_NULL, "failed to open grn_hash"); gcut_take_error(expected_error); gcut_take_error(actual_error); gcut_assert_equal_error(expected_error, actual_error); cut_assert_null(*hash); }
void test_wait_timeout (void) { GError *error = NULL; process = gcut_process_new("sleep", "1", NULL); gcut_process_run(process, &error); gcut_assert_error(error); cut_assert_equal_int(-1, gcut_process_wait(process, 0, &actual_error)); expected_error = g_error_new(GCUT_PROCESS_ERROR, GCUT_PROCESS_ERROR_TIMEOUT, "timeout while waiting reaped: <sleep 1>"); gcut_assert_equal_error(expected_error, actual_error); }
void test_wait_after_reaped (void) { GError *error = NULL; process = gcut_process_new(cuttest_echo_path, "XXX", NULL); gcut_process_run(process, &error); gcut_assert_error(error); wait_exited(); cut_assert_equal_int(-1, gcut_process_wait(process, 0, &actual_error)); expected_error = g_error_new(GCUT_PROCESS_ERROR, GCUT_PROCESS_ERROR_NOT_RUNNING, "not running: <%s XXX>", cuttest_echo_path); gcut_assert_equal_error(expected_error, actual_error); }
static GError * feed (const gchar *packet, gsize packet_size) { GError *error = NULL; gcut_assert_error(error_in_callback); milter_client_context_feed(context, packet, packet_size, &error); if (expected_error_in_callback) { gcut_assert_equal_error(expected_error_in_callback, error_in_callback); } else { gcut_assert_error(error_in_callback); } if (MILTER_IS_LIBEV_EVENT_LOOP(loop)) cut_omit("MilterLibevEventLoop doesn't support GCutStringIOChannel."); milter_test_pump_all_events(loop); return error; }
void test_negotiated_newer_version (void) { MilterOption *option, *reply_option; MilterMacrosRequests *macros_requests; const gchar *packet; gsize packet_size; GError *error = NULL; option = milter_option_new(2, MILTER_ACTION_ADD_HEADERS, MILTER_STEP_NONE); gcut_take_object(G_OBJECT(option)); cut_assert_true(milter_server_context_negotiate(context, option)); pump_all_events(); milter_test_assert_state(NEGOTIATE); milter_test_assert_status(NOT_CHANGE); reply_option = milter_option_new(6, MILTER_ACTION_ADD_HEADERS, MILTER_STEP_NONE); gcut_take_object(G_OBJECT(reply_option)); macros_requests = milter_macros_requests_new(); gcut_take_object(G_OBJECT(macros_requests)); milter_reply_encoder_encode_negotiate(reply_encoder, &packet, &packet_size, reply_option, macros_requests); milter_decoder_decode(decoder, packet, packet_size, &error); gcut_assert_error(error); expected_error = g_error_new(MILTER_SERVER_CONTEXT_ERROR, MILTER_SERVER_CONTEXT_ERROR_NEWER_VERSION_REQUESTED, "unsupported newer version is requested: 2 < 6"); gcut_assert_equal_error(expected_error, actual_error); cut_assert_equal_uint(0, n_message_processed); }