test also one-sided async operation

this tests only the common case of the far side being async - adding
100% instead of 50% to the runtime of the test to cover a corner case
didn't seem worth it.
This commit is contained in:
Oswald Buddenhagen 2022-06-01 13:54:48 +02:00
parent 3a8f8a8391
commit 30a6015624
7 changed files with 21 additions and 11 deletions

View File

@ -115,7 +115,7 @@ BIT_ENUM(
ZERODELAY,
KEEPJOURNAL,
FORCEASYNC,
FORCEASYNC(2),
)
#define DEBUG_ANY (DEBUG_MAILDIR | DEBUG_NET | DEBUG_SYNC | DEBUG_MAIN | DEBUG_DRV)

View File

@ -294,7 +294,7 @@ void free_generic_messages( message_t * );
void parse_generic_store( store_conf_t *store, conffile_t *cfg, const char *type );
store_t *proxy_alloc_store( store_t *real_ctx, const char *label );
store_t *proxy_alloc_store( store_t *real_ctx, const char *label, int force_async );
#define N_DRIVERS 2
extern driver_t *drivers[N_DRIVERS];

View File

@ -23,6 +23,7 @@ typedef union proxy_store {
gen_cmd_t *pending_cmds, **pending_cmds_append;
gen_cmd_t *check_cmds, **check_cmds_append;
wakeup_t wakeup;
char force_async;
void (*bad_callback)( void *aux );
void *bad_callback_aux;
@ -89,8 +90,8 @@ proxy_wakeup( void *aux )
static void
proxy_invoke( gen_cmd_t *cmd, int checked, const char *name )
{
if (DFlags & FORCEASYNC) {
proxy_store_t *ctx = cmd->ctx;
if (ctx->force_async) {
debug( "%s[% 2d] Queue %s%s\n", ctx->label, cmd->tag, name, checked ? " (checked)" : "" );
cmd->next = NULL;
if (checked) {
@ -343,7 +344,7 @@ proxy_invoke_bad_callback( proxy_store_t *ctx )
//# EXCLUDE alloc_store
store_t *
proxy_alloc_store( store_t *real_ctx, const char *label )
proxy_alloc_store( store_t *real_ctx, const char *label, int force_async )
{
proxy_store_t *ctx;
@ -352,6 +353,7 @@ proxy_alloc_store( store_t *real_ctx, const char *label )
ctx->gen.conf = real_ctx->conf;
ctx->ref_count = 1;
ctx->label = label;
ctx->force_async = force_async;
ctx->pending_cmds_append = &ctx->pending_cmds;
ctx->check_cmds_append = &ctx->check_cmds;
ctx->real_driver = real_ctx->driver;

View File

@ -423,7 +423,10 @@ main( int argc, char **argv )
for (; *ochar; ) {
switch (*ochar++) {
case 'a':
DFlags |= FORCEASYNC;
DFlags |= FORCEASYNC(F);
break;
case 'A':
DFlags |= FORCEASYNC(F) | FORCEASYNC(N);
break;
case 'j':
DFlags |= KEEPJOURNAL;

View File

@ -109,9 +109,9 @@ do_list_stores( list_vars_t *lvars )
uint dcaps = lvars->drv->get_caps( NULL );
store_t *ctx = lvars->drv->alloc_store( lvars->store, "" );
if ((DFlags & DEBUG_DRV) || ((DFlags & FORCEASYNC) && !(dcaps & DRV_ASYNC))) {
if ((DFlags & DEBUG_DRV) || ((DFlags & FORCEASYNC(F)) && !(dcaps & DRV_ASYNC))) {
lvars->drv = &proxy_driver;
ctx = proxy_alloc_store( ctx, "" );
ctx = proxy_alloc_store( ctx, "", DFlags & FORCEASYNC(F) );
}
lvars->ctx = ctx;
lvars->drv->set_bad_callback( ctx, list_store_bad, lvars );

View File

@ -407,9 +407,9 @@ do_sync_chans( main_vars_t *mvars )
labels[F] = labels[N] = "";
for (int t = 0; t < 2; t++) {
store_t *ctx = mvars->drv[t]->alloc_store( mvars->chan->stores[t], labels[t] );
if ((DFlags & DEBUG_DRV) || ((DFlags & FORCEASYNC) && !(dcaps[t] & DRV_ASYNC))) {
if ((DFlags & DEBUG_DRV) || ((DFlags & FORCEASYNC(t)) && !(dcaps[t] & DRV_ASYNC))) {
mvars->drv[t] = &proxy_driver;
ctx = proxy_alloc_store( ctx, labels[t] );
ctx = proxy_alloc_store( ctx, labels[t], DFlags & FORCEASYNC(t) );
}
mvars->ctx[t] = ctx;
mvars->drv[t]->set_bad_callback( ctx, store_bad, AUX );

View File

@ -329,7 +329,11 @@ sub runsync($$$)
} else {
$flags .= " -D";
}
$flags .= " -Ta" if ($async);
if ($async == 2) {
$flags .= " -TA";
} elsif ($async == 1) {
$flags .= " -Ta";
}
$cmd .= "$mbsync -Tz $flags -c .mbsyncrc test";
open FILE, "$cmd 2>&1 |";
my @out = <FILE>;
@ -890,6 +894,7 @@ sub test($$$$)
test_impl(0, $sx, $tx, $sfx);
test_impl(1, $sx, $tx, $sfx);
test_impl(2, $sx, $tx, $sfx);
killcfg();
}