diff --git a/tests/ibus_test.c b/tests/ibus_test.c index ca04b7f..faa5d09 100644 --- a/tests/ibus_test.c +++ b/tests/ibus_test.c @@ -13,6 +13,8 @@ struct Ibusfix { Channel *oldreply; Pump pump; + /* A fake connection is nothing but an address to tell two apart. */ + char fake[2]; DBusConnection *c1; DBusConnection *c2; }; @@ -81,8 +83,8 @@ cleanup: CT_CHECK(t, rmdir(root) == 0); } -static int -ibusbegin(struct ct *t, Ibusfix *f) +static void +ibusbegin(Ibusfix *f) { Drawcmd dc; @@ -97,9 +99,8 @@ ibusbegin(struct ct *t, Ibusfix *f) f->oldreply = replyc; replyc = chancreate(sizeof(Keyres), 0); pumpstart(&f->pump, Maxcontexts); - f->c1 = malloc(1); - f->c2 = malloc(1); - return CT_CHECK(t, f->c1 != nil && f->c2 != nil); + f->c1 = (DBusConnection*)&f->fake[0]; + f->c2 = (DBusConnection*)&f->fake[1]; } static void @@ -119,8 +120,6 @@ ibusend(Ibusfix *f) testengineinit(LangEN); while(channbrecv(drawc, &dc) > 0) ; - free(f->c1); - free(f->c2); chanfree(replyc); replyc = f->oldreply; } @@ -168,8 +167,7 @@ ibus_capability_policy(struct ct *t) Ictx *a, *b; Keyres res; - if(!ibusbegin(t, &f)) - goto cleanup; + ibusbegin(&f); a = newcontext(f.c1, "/context/cap-a"); b = newcontext(f.c2, "/context/cap-b"); if(!CT_CHECK(t, a != nil && b != nil)) @@ -223,8 +221,7 @@ ibus_private_input_policy(struct ct *t) char text[Maxutf]; int i; - if(!ibusbegin(t, &f)) - goto cleanup; + ibusbegin(&f); ctx = newcontext(f.c1, "/context/private"); if(!CT_CHECK(t, ctx != nil)) goto cleanup; @@ -274,8 +271,7 @@ ibus_context_lifecycle(struct ct *t) Caret at; char text[Maxutf]; - if(!ibusbegin(t, &f)) - goto cleanup; + ibusbegin(&f); a = newcontext(f.c1, "/context/one"); b = newcontext(f.c2, "/context/one"); if(!CT_CHECK(t, a != nil && b != nil && a != b)) @@ -387,8 +383,7 @@ ibus_active_release_lifecycle(struct ct *t) Ictx *ctx, *reused; Keyres res; - if(!ibusbegin(t, &f)) - goto cleanup; + ibusbegin(&f); ctx = newcontext(f.c1, "/context/reset"); if(!CT_CHECK(t, ctx != nil)) goto cleanup; diff --git a/tests/xim_adapter_test.c b/tests/xim_adapter_test.c index 5840084..04dc8c5 100644 --- a/tests/xim_adapter_test.c +++ b/tests/xim_adapter_test.c @@ -398,8 +398,8 @@ struct Freejob Channel *done; }; -static int -ximbegin(struct ct *t, Ximfix *f, int lang) +static void +ximbegin(Ximfix *f, int lang) { Drawcmd dc; @@ -410,8 +410,6 @@ ximbegin(struct ct *t, Ximfix *f, int lang) f->oldreply = replyc; replyc = chancreate(sizeof(Keyres), 0); pumpstart(&f->pump, 16); - USED(t); - return 1; } static void @@ -466,8 +464,7 @@ xim_adapter_key_contract(struct ct *t) u32int allmod; memset(&state, 0, sizeof state); - if(!ximbegin(t, &f, LangJP)) - goto cleanup; + ximbegin(&f, LangJP); allmod = ~0; keypress(&state, 'x', allmod, &res); req = nexttrace(t, &f, Keypress, &state); @@ -487,7 +484,6 @@ xim_adapter_key_contract(struct ct *t) CT_CHECK(t, !res.eaten); checkstr(t, "preedit", "か", &res.commit); checkstr(t, "preedit", "", &res.preedit); -cleanup: ximend(&f); } @@ -502,8 +498,7 @@ xim_adapter_release_lifecycle(struct ct *t) memset(&a, 0, sizeof a); memset(&b, 0, sizeof b); dead = nil; - if(!ximbegin(t, &f, LangJP)) - goto cleanup; + ximbegin(&f, LangJP); keypress(&a, 'k', 0, &res); nexttrace(t, &f, Keypress, &a); keypress(&a, 'a', 0, &res); @@ -580,8 +575,7 @@ xim_adapter_free_waits_for_release(struct ct *t) state = nil; freed = nil; workeractive = 0; - if(!ximbegin(t, &f, LangJP)) - goto cleanup; + ximbegin(&f, LangJP); state = calloc(1, sizeof *state); freed = chancreate(sizeof(uchar), 0); if(!CT_CHECK(t, state != nil && freed != nil)) @@ -736,8 +730,7 @@ xim_adapter_placement_updates(struct ct *t) ic = (xcb_im_input_context_t*)(uintptr)71; memset(&state, 0, sizeof state); oldstate = kstate; - if(!ximbegin(t, &f, LangJP)) - goto cleanup; + ximbegin(&f, LangJP); kstate = testkeystate("us"); if(!CT_CHECK(t, kstate != nil)) goto cleanup; @@ -891,8 +884,7 @@ xim_adapter_callback_cleanup(struct ct *t) ic = (xcb_im_input_context_t*)(uintptr)29; memset(&state, 0, sizeof state); - if(!ximbegin(t, &f, LangJP)) - return; + ximbegin(&f, LangJP); wireclear(); wirebind(0, ic, &state); state.xic = ic; @@ -980,8 +972,7 @@ xim_adapter_callback_transfer(struct ct *t) aic = (xcb_im_input_context_t*)(uintptr)50; memset(&a, 0, sizeof a); memset(&b, 0, sizeof b); - if(!ximbegin(t, &f, LangJP)) - goto cleanup; + ximbegin(&f, LangJP); wireclear(); a.xic = aic; a.clientpre = 1; @@ -996,7 +987,6 @@ xim_adapter_callback_transfer(struct ct *t) CT_EQ_PTR(t, nil, preowner); release(&b); nexttrace(t, &f, Keyrelease, &b); -cleanup: preowner = nil; ximend(&f); } @@ -1016,8 +1006,7 @@ xim_adapter_callback_owner_loss(struct ct *t) ic = (xcb_im_input_context_t*)(uintptr)51; memset(&state, 0, sizeof state); foreign = 0; - if(!ximbegin(t, &f, LangJP)) - goto cleanup; + ximbegin(&f, LangJP); wireclear(); wirebind(0, ic, &state); state.xic = ic; @@ -1086,7 +1075,6 @@ xim_adapter_callback_owner_loss(struct ct *t) CT_CHECK(t, channbrecv(f.pump.trace, &trace) > 0); CT_EQ_INT(t, Keyrelease, trace.op); CT_EQ_PTR(t, &foreign, trace.owner); -cleanup: preowner = nil; ximend(&f); }