From 30a601562484616fc7f13dd73ea977b8f5903aff Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Wed, 1 Jun 2022 13:54:48 +0200 Subject: [PATCH] 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. --- src/common.h | 2 +- src/driver.h | 2 +- src/drv_proxy.c | 8 +++++--- src/main.c | 5 ++++- src/main_list.c | 4 ++-- src/main_sync.c | 4 ++-- src/run-tests.pl | 7 ++++++- 7 files changed, 21 insertions(+), 11 deletions(-) diff --git a/src/common.h b/src/common.h index 8cc4b84..09883e5 100644 --- a/src/common.h +++ b/src/common.h @@ -115,7 +115,7 @@ BIT_ENUM( ZERODELAY, KEEPJOURNAL, - FORCEASYNC, + FORCEASYNC(2), ) #define DEBUG_ANY (DEBUG_MAILDIR | DEBUG_NET | DEBUG_SYNC | DEBUG_MAIN | DEBUG_DRV) diff --git a/src/driver.h b/src/driver.h index 648ffa2..c091ec1 100644 --- a/src/driver.h +++ b/src/driver.h @@ -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]; diff --git a/src/drv_proxy.c b/src/drv_proxy.c index e69ab6a..bdeaa66 100644 --- a/src/drv_proxy.c +++ b/src/drv_proxy.c @@ -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; + 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; diff --git a/src/main.c b/src/main.c index 1c3524d..c24c444 100644 --- a/src/main.c +++ b/src/main.c @@ -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; diff --git a/src/main_list.c b/src/main_list.c index adda4b9..ee02906 100644 --- a/src/main_list.c +++ b/src/main_list.c @@ -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 ); diff --git a/src/main_sync.c b/src/main_sync.c index 6134631..d5783c5 100644 --- a/src/main_sync.c +++ b/src/main_sync.c @@ -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 ); diff --git a/src/run-tests.pl b/src/run-tests.pl index 00959c1..3e0f7fe 100755 --- a/src/run-tests.pl +++ b/src/run-tests.pl @@ -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 = ; @@ -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(); }