ibus: die where startup fails; print the Plan 9 way; drop what said nothing
ibusinit unwound its server and un-registered its atexit handler on a failure whose only sequel was ibusthread dying anyway; now each failure dies with its own message, and the test that existed to walk that unwind goes with it. Also gone: an empty watch-toggle callback where libdbus takes nil, Maxconns as a second name for Maxclients, fprintf and strerror where the rest of the daemon says fprint and %r, USED() where a parameter can simply be unnamed, a second findcontext() for the Properties branch, and emitcommit() taking a connection and path apart from the context that has both. Ownerpoll lives once, in dat.h.
This commit is contained in:
@@ -3,7 +3,6 @@
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
Testctrlmask = 1<<2,
|
||||
@@ -79,85 +78,6 @@ cleanup:
|
||||
CT_CHECK(t, rmdir(root) == 0);
|
||||
}
|
||||
|
||||
void
|
||||
ibus_startup_requires_ownership(struct ct *t)
|
||||
{
|
||||
char root[] = "/tmp/strans-ibus-startup.XXXXXX";
|
||||
char busdir[128], ibusdir[128], path[512], *old, *saved;
|
||||
struct stat st;
|
||||
int i, made, rv;
|
||||
|
||||
made = 0;
|
||||
busdir[0] = '\0';
|
||||
ibusdir[0] = '\0';
|
||||
path[0] = '\0';
|
||||
old = getenv("XDG_CONFIG_HOME");
|
||||
saved = old == nil ? nil : strdup(old);
|
||||
if(old != nil && !CT_CHECK(t, saved != nil))
|
||||
return;
|
||||
/* An IBus desktop names a live address file; the path must be ours. */
|
||||
unsetenv("IBUS_ADDRESS_FILE");
|
||||
if(!CT_CHECK(t, mkdtemp(root) != nil))
|
||||
goto cleanup;
|
||||
made = 1;
|
||||
if(!CT_CHECK(t, snprintf(busdir, sizeof busdir, "%s/ibus/bus", root)
|
||||
< (int)sizeof busdir) ||
|
||||
!CT_CHECK(t, snprintf(ibusdir, sizeof ibusdir, "%s/ibus", root)
|
||||
< (int)sizeof ibusdir) ||
|
||||
!CT_CHECK(t, setenv("XDG_CONFIG_HOME", root, 1) == 0) ||
|
||||
!CT_CHECK(t, buildaddrpath(path, sizeof path) == 0))
|
||||
goto cleanup;
|
||||
|
||||
memset(watches, 0, sizeof watches);
|
||||
for(i = 0; i < nelem(watches); i++)
|
||||
watches[i] = (DBusWatch*)1;
|
||||
nwatches = nelem(watches);
|
||||
rv = ibusinit();
|
||||
CT_EQ_INT(t, -1, rv);
|
||||
CT_EQ_PTR(t, nil, srv);
|
||||
CT_CHECK(t, lstat(path, &st) < 0 && errno == ENOENT);
|
||||
if(rv == 0){
|
||||
dbus_server_disconnect(srv);
|
||||
dbus_server_unref(srv);
|
||||
srv = nil;
|
||||
unlinkaddr();
|
||||
atexitdont(unlinkaddr);
|
||||
}
|
||||
|
||||
memset(watches, 0, sizeof watches);
|
||||
nwatches = 0;
|
||||
while(atexit(unlinkaddr))
|
||||
continue;
|
||||
CT_EQ_INT(t, -1, ibusinit());
|
||||
CT_EQ_PTR(t, nil, srv);
|
||||
CT_CHECK(t, lstat(path, &st) < 0 && errno == ENOENT);
|
||||
cleanup:
|
||||
if(srv != nil){
|
||||
dbus_server_disconnect(srv);
|
||||
dbus_server_unref(srv);
|
||||
srv = nil;
|
||||
}
|
||||
unlinkaddr();
|
||||
atexitdont(unlinkaddr);
|
||||
memset(watches, 0, sizeof watches);
|
||||
nwatches = 0;
|
||||
addrfile[0] = '\0';
|
||||
if(saved != nil){
|
||||
setenv("XDG_CONFIG_HOME", saved, 1);
|
||||
free(saved);
|
||||
}else
|
||||
unsetenv("XDG_CONFIG_HOME");
|
||||
if(made){
|
||||
if(path[0] != '\0')
|
||||
unlink(path);
|
||||
if(busdir[0] != '\0')
|
||||
CT_CHECK(t, rmdir(busdir) == 0 || errno == ENOENT);
|
||||
if(ibusdir[0] != '\0')
|
||||
CT_CHECK(t, rmdir(ibusdir) == 0 || errno == ENOENT);
|
||||
CT_CHECK(t, rmdir(root) == 0);
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
ibusbegin(struct ct *t, Ibusfix *f)
|
||||
{
|
||||
|
||||
@@ -108,7 +108,6 @@ void server_connection_ownership(struct ct*);
|
||||
void server_extension_stream(struct ct*);
|
||||
void server_rejects_unknown_extension(struct ct*);
|
||||
void ibus_machine_id_fallback(struct ct*);
|
||||
void ibus_startup_requires_ownership(struct ct*);
|
||||
void ibus_capability_policy(struct ct*);
|
||||
void ibus_private_input_policy(struct ct*);
|
||||
void ibus_context_lifecycle(struct ct*);
|
||||
|
||||
@@ -131,7 +131,6 @@ static const struct ct_test tests[] = {
|
||||
{ "server/extension-stream", server_extension_stream },
|
||||
{ "server/rejects-unknown-extension", server_rejects_unknown_extension },
|
||||
{ "ibus/machine-id-fallback", ibus_machine_id_fallback },
|
||||
{ "ibus/startup-requires-ownership", ibus_startup_requires_ownership },
|
||||
{ "ibus/capability-policy", ibus_capability_policy },
|
||||
{ "ibus/private-input-policy", ibus_private_input_policy },
|
||||
{ "ibus/context-lifecycle", ibus_context_lifecycle },
|
||||
|
||||
Reference in New Issue
Block a user