Browse Source

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.
wip/maildir-path-under-inbox
Oswald Buddenhagen 3 years ago
parent
commit
30a6015624
  1. 2
      src/common.h
  2. 2
      src/driver.h
  3. 6
      src/drv_proxy.c
  4. 5
      src/main.c
  5. 4
      src/main_list.c
  6. 4
      src/main_sync.c
  7. 7
      src/run-tests.pl

2
src/common.h

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

2
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 ); 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 #define N_DRIVERS 2
extern driver_t *drivers[N_DRIVERS]; extern driver_t *drivers[N_DRIVERS];

6
src/drv_proxy.c

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

5
src/main.c

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

4
src/main_list.c

@ -109,9 +109,9 @@ do_list_stores( list_vars_t *lvars )
uint dcaps = lvars->drv->get_caps( NULL ); uint dcaps = lvars->drv->get_caps( NULL );
store_t *ctx = lvars->drv->alloc_store( lvars->store, "" ); 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; lvars->drv = &proxy_driver;
ctx = proxy_alloc_store( ctx, "" ); ctx = proxy_alloc_store( ctx, "", DFlags & FORCEASYNC(F) );
} }
lvars->ctx = ctx; lvars->ctx = ctx;
lvars->drv->set_bad_callback( ctx, list_store_bad, lvars ); lvars->drv->set_bad_callback( ctx, list_store_bad, lvars );

4
src/main_sync.c

@ -407,9 +407,9 @@ do_sync_chans( main_vars_t *mvars )
labels[F] = labels[N] = ""; labels[F] = labels[N] = "";
for (int t = 0; t < 2; t++) { for (int t = 0; t < 2; t++) {
store_t *ctx = mvars->drv[t]->alloc_store( mvars->chan->stores[t], labels[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; 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->ctx[t] = ctx;
mvars->drv[t]->set_bad_callback( ctx, store_bad, AUX ); mvars->drv[t]->set_bad_callback( ctx, store_bad, AUX );

7
src/run-tests.pl

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

Loading…
Cancel
Save