diff --git a/src/test/check_getdns_address.h b/src/test/check_getdns_address.h index 65f76b8b..2c59d992 100644 --- a/src/test/check_getdns_address.h +++ b/src/test/check_getdns_address.h @@ -149,6 +149,7 @@ * rcode = 0 */ void verify_getdns_address_6(struct extracted_response *ex_response); + fn_cont fn_ref = { verify_getdns_address_6 }; struct getdns_context *context = NULL; \ void* eventloop = NULL; \ getdns_transaction_t transaction_id = 0; @@ -157,7 +158,7 @@ EVENT_BASE_CREATE; ASSERT_RC(getdns_address(context, "google.com", NULL, - verify_getdns_address_6, &transaction_id, callbackfn), + &fn_ref, &transaction_id, callbackfn), GETDNS_RETURN_GOOD, "Return code from getdns_address()"); RUN_EVENT_LOOP; @@ -183,6 +184,7 @@ * ancount = 1 (number of records in ANSWER section) */ void verify_getdns_address_7(struct extracted_response *ex_response); + fn_cont fn_ref = { verify_getdns_address_7 }; struct getdns_context *context = NULL; \ void* eventloop = NULL; \ getdns_transaction_t transaction_id = 0; @@ -191,7 +193,7 @@ EVENT_BASE_CREATE; ASSERT_RC(getdns_address(context, "localhost", NULL, - verify_getdns_address_7, &transaction_id, callbackfn), + &fn_ref, &transaction_id, callbackfn), GETDNS_RETURN_GOOD, "Return code from getdns_address()"); RUN_EVENT_LOOP; @@ -213,6 +215,7 @@ * rcode = 3 (NXDOMAIN) */ void verify_getdns_address_8(struct extracted_response *ex_response); + fn_cont fn_ref = { verify_getdns_address_8 }; struct getdns_context *context = NULL; \ void* eventloop = NULL; \ getdns_transaction_t transaction_id = 0; @@ -222,7 +225,7 @@ EVENT_BASE_CREATE; ASSERT_RC(getdns_address(context, "hostnamedoesntexist", NULL, - verify_getdns_address_8, &transaction_id, callbackfn), + &fn_ref, &transaction_id, callbackfn), GETDNS_RETURN_GOOD, "Return code from getdns_address()"); RUN_EVENT_LOOP; diff --git a/src/test/check_getdns_cancel_callback.h b/src/test/check_getdns_cancel_callback.h index 08331771..facf31bc 100644 --- a/src/test/check_getdns_cancel_callback.h +++ b/src/test/check_getdns_cancel_callback.h @@ -55,6 +55,7 @@ * expect: GETDNS_RETURN_UNKNOWN_TRANSACTION */ void verify_getdns_cancel_callback(struct extracted_response *ex_response); + fn_cont fn_ref = { verify_getdns_cancel_callback }; struct getdns_context *context = NULL; void* eventloop = NULL; getdns_transaction_t transaction_id = 0; @@ -65,7 +66,7 @@ EVENT_BASE_CREATE; ASSERT_RC(getdns_general(context, "google.com", GETDNS_RRTYPE_A, NULL, - verify_getdns_cancel_callback, &transaction_id, callbackfn), + &fn_ref, &transaction_id, callbackfn), GETDNS_RETURN_GOOD, "Return code from getdns_general()"); RUN_EVENT_LOOP; @@ -86,6 +87,7 @@ * expect: GETDNS_RETURN_UNKNOWN_TRANSACTION */ void verify_getdns_cancel_callback(struct extracted_response *ex_response); + fn_cont fn_ref = { verify_getdns_cancel_callback }; struct getdns_context *context = NULL; void* eventloop = NULL; getdns_transaction_t transaction_id = 0; @@ -96,7 +98,7 @@ EVENT_BASE_CREATE; ASSERT_RC(getdns_general(context, "google.com", GETDNS_RRTYPE_A, NULL, - verify_getdns_cancel_callback, &transaction_id, callbackfn), + &fn_ref, &transaction_id, callbackfn), GETDNS_RETURN_GOOD, "Return code from getdns_general()"); RUN_EVENT_LOOP; @@ -133,7 +135,8 @@ struct getdns_context *context = NULL; void* eventloop = NULL; getdns_transaction_t transaction_id = 0; - getdns_transaction_t transaction_id_array[10] = {}; + getdns_transaction_t transaction_id_array[10] + = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; int i; int odd = 0; int even = 0; @@ -212,7 +215,8 @@ struct getdns_context *context = NULL; void* eventloop = NULL; getdns_transaction_t transaction_id = 0; - getdns_transaction_t transaction_id_array[10] = {}; + getdns_transaction_t transaction_id_array[10] + = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; int i; int odd = 0; int even = 0; @@ -295,7 +299,8 @@ struct getdns_bindata address_data = { 4, (void *)"\x08\x08\x08\x08" }; struct getdns_dict *address = NULL; getdns_transaction_t transaction_id = 0; - getdns_transaction_t transaction_id_array[10] = {}; + getdns_transaction_t transaction_id_array[10] + = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; int i; int odd = 0; int even = 0; @@ -381,7 +386,8 @@ struct getdns_context *context = NULL; void* eventloop = NULL; getdns_transaction_t transaction_id = 0; - getdns_transaction_t transaction_id_array[10] = {}; + getdns_transaction_t transaction_id_array[10] + = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; int i; int odd = 0; int even = 0; diff --git a/src/test/check_getdns_common.c b/src/test/check_getdns_common.c index 87f0727e..20310f93 100644 --- a/src/test/check_getdns_common.c +++ b/src/test/check_getdns_common.c @@ -339,7 +339,7 @@ void callbackfn(struct getdns_context *context, getdns_transaction_t transaction_id) { typedef void (*fn_ptr)(struct extracted_response *ex_response); - fn_ptr fn = userarg; + fn_ptr fn = ((fn_cont *)userarg)->fn; (void)context; (void)transaction_id; /* diff --git a/src/test/check_getdns_common.h b/src/test/check_getdns_common.h index e2d77f44..6fb3b555 100644 --- a/src/test/check_getdns_common.h +++ b/src/test/check_getdns_common.h @@ -211,6 +211,10 @@ struct getdns_dict *response, void *userarg, getdns_transaction_t transaction_id); + + typedef struct fn_cont { + void (*fn)(struct extracted_response *ex_response); + } fn_cont; /* * callbackfn is the callback function given to all * asynchronous query tests. It is expected to only diff --git a/src/test/check_getdns_context_destroy.h b/src/test/check_getdns_context_destroy.h index 381da9f8..65a0a8c3 100644 --- a/src/test/check_getdns_context_destroy.h +++ b/src/test/check_getdns_context_destroy.h @@ -68,6 +68,7 @@ * expect: callback should be called before getdns_context_destroy() returns */ void verify_getdns_context_destroy(struct extracted_response *ex_response); + fn_cont fn_ref = { verify_getdns_context_destroy }; struct getdns_context *context = NULL; void* eventloop = NULL; getdns_transaction_t transaction_id = 0; @@ -78,7 +79,7 @@ EVENT_BASE_CREATE; ASSERT_RC(getdns_general(context, "google.com", GETDNS_RRTYPE_A, NULL, - verify_getdns_context_destroy, &transaction_id, callbackfn), + &fn_ref, &transaction_id, callbackfn), GETDNS_RETURN_GOOD, "Return code from getdns_general()"); RUN_EVENT_LOOP; @@ -95,6 +96,7 @@ * expect: callback should be called before getdns_context_destroy() returns */ void verify_getdns_context_destroy(struct extracted_response *ex_response); + fn_cont fn_ref = { verify_getdns_context_destroy }; struct getdns_context *context = NULL; void* eventloop = NULL; getdns_transaction_t transaction_id = 0; @@ -105,7 +107,7 @@ EVENT_BASE_CREATE; ASSERT_RC(getdns_address(context, "google.com", NULL, - verify_getdns_context_destroy, &transaction_id, callbackfn), + &fn_ref, &transaction_id, callbackfn), GETDNS_RETURN_GOOD, "Return code from getdns_address()"); RUN_EVENT_LOOP; @@ -122,6 +124,7 @@ * expect: callback should be called before getdns_context_destroy() returns */ void verify_getdns_context_destroy(struct extracted_response *ex_response); + fn_cont fn_ref = { verify_getdns_context_destroy }; struct getdns_context *context = NULL; void* eventloop = NULL; struct getdns_bindata address_type = { 5, (void *)"IPv4" }; @@ -141,7 +144,7 @@ GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata"); ASSERT_RC(getdns_hostname(context, address, NULL, - verify_getdns_context_destroy, &transaction_id, callbackfn), + &fn_ref, &transaction_id, callbackfn), GETDNS_RETURN_GOOD, "Return code from getdns_address()"); RUN_EVENT_LOOP; @@ -159,6 +162,7 @@ * expect: callback should be called before getdns_context_destroy() returns */ void verify_getdns_context_destroy(struct extracted_response *ex_response); + fn_cont fn_ref = { verify_getdns_context_destroy }; struct getdns_context *context = NULL; void* eventloop = NULL; getdns_transaction_t transaction_id = 0; @@ -169,7 +173,7 @@ EVENT_BASE_CREATE; ASSERT_RC(getdns_service(context, "google.com", NULL, - verify_getdns_context_destroy, &transaction_id, callbackfn), + &fn_ref, &transaction_id, callbackfn), GETDNS_RETURN_GOOD, "Return code from getdns_service()"); RUN_EVENT_LOOP; diff --git a/src/test/check_getdns_general.h b/src/test/check_getdns_general.h index 6a19bdfb..f073cd86 100644 --- a/src/test/check_getdns_general.h +++ b/src/test/check_getdns_general.h @@ -151,6 +151,7 @@ * ancount = 0 (number of records in ANSWER section) */ void verify_getdns_general_6(struct extracted_response *ex_response); + fn_cont fn_ref = { verify_getdns_general_6 }; struct getdns_context *context = NULL; \ void* eventloop = NULL; \ getdns_transaction_t transaction_id = 0; @@ -159,7 +160,7 @@ EVENT_BASE_CREATE; ASSERT_RC(getdns_general(context, "google.com", 0, NULL, - verify_getdns_general_6, &transaction_id, callbackfn), + &fn_ref, &transaction_id, callbackfn), GETDNS_RETURN_GOOD, "Return code from getdns_general()"); RUN_EVENT_LOOP; @@ -184,6 +185,7 @@ * ancount = 0 (number of records in ANSWER section) */ void verify_getdns_general_7(struct extracted_response *ex_response); + fn_cont fn_ref = { verify_getdns_general_7 }; struct getdns_context *context = NULL; \ void* eventloop = NULL; \ getdns_transaction_t transaction_id = 0; @@ -192,7 +194,7 @@ EVENT_BASE_CREATE; ASSERT_RC(getdns_general(context, "google.com", 65279, NULL, - verify_getdns_general_7, &transaction_id, callbackfn), + &fn_ref, &transaction_id, callbackfn), GETDNS_RETURN_GOOD, "Return code from getdns_general()"); RUN_EVENT_LOOP; @@ -218,6 +220,7 @@ * and equals number of A records ("type": 1) in "answer" list */ void verify_getdns_general_8(struct extracted_response *ex_response); + fn_cont fn_ref = { verify_getdns_general_8 }; struct getdns_context *context = NULL; \ void* eventloop = NULL; \ getdns_transaction_t transaction_id = 0; @@ -226,7 +229,7 @@ EVENT_BASE_CREATE; ASSERT_RC(getdns_general(context, "google.com", GETDNS_RRTYPE_A, NULL, - verify_getdns_general_8, &transaction_id, callbackfn), + &fn_ref, &transaction_id, callbackfn), GETDNS_RETURN_GOOD, "Return code from getdns_general()"); RUN_EVENT_LOOP; @@ -252,6 +255,7 @@ * and equals number of AAAA records ("type": 28) in "answer" list */ void verify_getdns_general_9(struct extracted_response *ex_response); + fn_cont fn_ref = { verify_getdns_general_9 }; struct getdns_context *context = NULL; \ void* eventloop = NULL; \ getdns_transaction_t transaction_id = 0; @@ -260,7 +264,7 @@ EVENT_BASE_CREATE; ASSERT_RC(getdns_general(context, "google.com", GETDNS_RRTYPE_AAAA, NULL, - verify_getdns_general_9, &transaction_id, callbackfn), + &fn_ref, &transaction_id, callbackfn), GETDNS_RETURN_GOOD, "Return code from getdns_general()"); RUN_EVENT_LOOP; @@ -287,6 +291,7 @@ * and SOA record ("type": 6) present in "authority" list */ void verify_getdns_general_10(struct extracted_response *ex_response); + fn_cont fn_ref = { verify_getdns_general_10 }; struct getdns_context *context = NULL; \ void* eventloop = NULL; \ getdns_transaction_t transaction_id = 0; @@ -296,7 +301,7 @@ EVENT_BASE_CREATE; ASSERT_RC(getdns_general(context, name, GETDNS_RRTYPE_TXT, NULL, - verify_getdns_general_10, &transaction_id, callbackfn), + &fn_ref, &transaction_id, callbackfn), GETDNS_RETURN_GOOD, "Return code from getdns_general()"); RUN_EVENT_LOOP; @@ -322,6 +327,7 @@ * ancount = 0 (number of records in ANSWER section) */ void verify_getdns_general_11(struct extracted_response *ex_response); + fn_cont fn_ref = { verify_getdns_general_11 }; struct getdns_context *context = NULL; \ void* eventloop = NULL; \ getdns_transaction_t transaction_id = 0; @@ -330,7 +336,7 @@ EVENT_BASE_CREATE; ASSERT_RC(getdns_general(context, "willem.getdnsapi.net", GETDNS_RRTYPE_MX, NULL, - verify_getdns_general_11, &transaction_id, callbackfn), + &fn_ref, &transaction_id, callbackfn), GETDNS_RETURN_GOOD, "Return code from getdns_general()"); RUN_EVENT_LOOP; @@ -356,6 +362,7 @@ * and equals number of A records ("type": 1) in "answer" list */ void verify_getdns_general_12(struct extracted_response *ex_response); + fn_cont fn_ref = { verify_getdns_general_12 }; struct getdns_context *context = NULL; \ void* eventloop = NULL; \ getdns_transaction_t transaction_id = 0; @@ -364,7 +371,7 @@ EVENT_BASE_CREATE; ASSERT_RC(getdns_general(context, "google.com", GETDNS_RRTYPE_A, NULL, - verify_getdns_general_12, &transaction_id, callbackfn), + &fn_ref, &transaction_id, callbackfn), GETDNS_RETURN_GOOD, "Return code from getdns_general()"); RUN_EVENT_LOOP; diff --git a/src/test/check_getdns_hostname.h b/src/test/check_getdns_hostname.h index 461ad373..7193fec9 100644 --- a/src/test/check_getdns_hostname.h +++ b/src/test/check_getdns_hostname.h @@ -315,6 +315,7 @@ * expect: response with correct hostname */ void verify_getdns_hostname_10(struct extracted_response *ex_response); + fn_cont fn_ref = { verify_getdns_hostname_10 }; struct getdns_context *context = NULL; struct getdns_dict *address = NULL; struct getdns_bindata address_type = { 5, (void *)"IPv4" }; @@ -333,7 +334,7 @@ EVENT_BASE_CREATE; ASSERT_RC(getdns_hostname(context, address, NULL, - verify_getdns_hostname_10, &transaction_id, callbackfn), + &fn_ref, &transaction_id, callbackfn), GETDNS_RETURN_GOOD, "Return code from getdns_hostname()"); RUN_EVENT_LOOP; @@ -356,6 +357,7 @@ * expect: response with no hostname */ void verify_getdns_hostname_11(struct extracted_response *ex_response); + fn_cont fn_ref = { verify_getdns_hostname_11 }; struct getdns_context *context = NULL; struct getdns_dict *address = NULL; struct getdns_bindata address_type = { 5, (void *)"IPv4" }; @@ -374,7 +376,7 @@ EVENT_BASE_CREATE; ASSERT_RC(getdns_hostname(context, address, NULL, - verify_getdns_hostname_11, &transaction_id, callbackfn), + &fn_ref, &transaction_id, callbackfn), GETDNS_RETURN_GOOD, "Return code from getdns_hostname()"); RUN_EVENT_LOOP; @@ -398,6 +400,7 @@ * expect: response with correct hostname */ void verify_getdns_hostname_12(struct extracted_response *ex_response); + fn_cont fn_ref = { verify_getdns_hostname_12 }; struct getdns_context *context = NULL; struct getdns_dict *address = NULL; struct getdns_bindata address_type = { 5, (void *)"IPv6" }; @@ -419,7 +422,7 @@ EVENT_BASE_CREATE; ASSERT_RC(getdns_hostname(context, address, NULL, - verify_getdns_hostname_12, &transaction_id, callbackfn), + &fn_ref, &transaction_id, callbackfn), GETDNS_RETURN_GOOD, "Return code from getdns_hostname()"); RUN_EVENT_LOOP; @@ -442,6 +445,7 @@ * expect: response with no hostname */ void verify_getdns_hostname_13(struct extracted_response *ex_response); + fn_cont fn_ref = { verify_getdns_hostname_13 }; struct getdns_context *context = NULL; struct getdns_dict *address = NULL; struct getdns_bindata address_type = { 5, (void *)"IPv6" }; @@ -460,7 +464,7 @@ EVENT_BASE_CREATE; ASSERT_RC(getdns_hostname(context, address, NULL, - verify_getdns_hostname_13, &transaction_id, callbackfn), + &fn_ref, &transaction_id, callbackfn), GETDNS_RETURN_GOOD, "Return code from getdns_hostname()"); RUN_EVENT_LOOP; diff --git a/src/test/check_getdns_service.h b/src/test/check_getdns_service.h index c9545c0c..c93cab0e 100644 --- a/src/test/check_getdns_service.h +++ b/src/test/check_getdns_service.h @@ -148,6 +148,7 @@ * expect: NXDOMAIN response (with SOA record) */ void verify_getdns_service_7(struct extracted_response *ex_response); + fn_cont fn_ref = { verify_getdns_service_7 }; struct getdns_context *context = NULL; \ void* eventloop = NULL; \ getdns_transaction_t transaction_id = 0; @@ -157,7 +158,7 @@ EVENT_BASE_CREATE; ASSERT_RC(getdns_service(context, "nitinsinghit.com", NULL, - verify_getdns_address_8, &transaction_id, callbackfn), + &fn_ref, &transaction_id, callbackfn), GETDNS_RETURN_GOOD, "Return code from getdns_service()"); RUN_EVENT_LOOP;