3338. [bug] Address race condition in units tests: asyncload_zone

and asyncload_zt. [RT #26100]
This commit is contained in:
Mark Andrews 2012-06-14 15:15:57 +10:00
parent e8373787c5
commit ca48cdf0ac
2 changed files with 39 additions and 3 deletions

View file

@ -1,3 +1,6 @@
3338. [bug] Address race condition in units tests: asyncload_zone
and asyncload_zt. [RT #26100]
3337. [bug] Change #3294 broke support for the multiple keys
in controls. [RT #29694]

View file

@ -37,6 +37,11 @@
#include "dnstest.h"
struct args {
void *arg1;
void *arg2;
};
/*
* Helper functions
*/
@ -72,6 +77,27 @@ all_done(void *arg) {
return (ISC_R_SUCCESS);
}
static void
start_zt_asyncload(isc_task_t *task, isc_event_t *event) {
struct args *args = (struct args *)(event->ev_arg);
UNUSED(task);
dns_zt_asyncload(args->arg1, all_done, args->arg2);
isc_event_free(&event);
}
static void
start_zone_asyncload(isc_task_t *task, isc_event_t *event) {
struct args *args = (struct args *)(event->ev_arg);
UNUSED(task);
dns_zone_asyncload(args->arg1, load_done, args->arg2);
isc_event_free(&event);
}
/*
* Individual unit tests
*/
@ -127,6 +153,7 @@ ATF_TC_BODY(asyncload_zone, tc) {
dns_db_t *db = NULL;
isc_boolean_t done = ISC_FALSE;
int i = 0;
struct args args;
UNUSED(tc);
@ -147,8 +174,10 @@ ATF_TC_BODY(asyncload_zone, tc) {
ATF_CHECK(!dns__zone_loadpending(zone));
ATF_CHECK(!done);
dns_zone_setfile(zone, "testdata/zt/zone1.db");
dns_zone_asyncload(zone, load_done, (void *) &done);
ATF_CHECK(dns__zone_loadpending(zone));
args.arg1 = zone;
args.arg2 = &done;
isc_app_onrun(mctx, maintask, start_zone_asyncload, &args);
isc_app_run();
while (dns__zone_loadpending(zone) && i++ < 5000)
@ -183,6 +212,7 @@ ATF_TC_BODY(asyncload_zt, tc) {
dns_db_t *db = NULL;
isc_boolean_t done = ISC_FALSE;
int i = 0;
struct args args;
UNUSED(tc);
@ -218,7 +248,10 @@ ATF_TC_BODY(asyncload_zt, tc) {
ATF_CHECK(!dns__zone_loadpending(zone1));
ATF_CHECK(!dns__zone_loadpending(zone2));
ATF_CHECK(!done);
dns_zt_asyncload(zt, all_done, (void *) &done);
args.arg1 = zt;
args.arg2 = &done;
isc_app_onrun(mctx, maintask, start_zt_asyncload, &args);
isc_app_run();
while (!done && i++ < 5000)