test: make clean checks trustworthy

This commit is contained in:
2026-08-14 22:06:54 +09:00
parent 0471d58dec
commit 77c6dd66ca
4 changed files with 25 additions and 10 deletions

View File

@@ -59,7 +59,7 @@ docker: docker-image
check: verify-map test
$(MAKE) -C xim check
test: $(PROG)
test: $(PROG) gtk
$(MAKE) -C tests check TESTARGS="$(TESTARGS)"
verify-map:

View File

@@ -33,7 +33,7 @@ OBJS = $(TESTOBJ) $(PARENTOBJ) $(XIMOBJ)
all: $(PROG) $(LIVE)
check test: $(PROG) $(LIVE)
check test: $(PROG) $(LIVE) ../gtk/im-strans.so
./$(PROG) $(TESTARGS)
./ibus_live_test ../strans ../map ./ibus_client_smoke
./gtk_live_test ../gtk/im-strans.so
@@ -57,6 +57,9 @@ gtk_live_test: gtk_live_test.c ../ipc.c ../ipc.h
$(HOSTCC) -std=c99 -Wall -Wextra -O2 -g -I.. $(GTK_CFLAGS) -o $@ \
gtk_live_test.c ../ipc.c $(GTK_LIBS) -pthread
../gtk/im-strans.so: ../gtk/main.c ../ipc.c ../ipc.h
$(MAKE) -C ../gtk
xim_live_test: xim_live_test.c ../ipc.c ../ipc.h
$(HOSTCC) -std=c99 -Wall -Wextra -O2 -g -I.. $(X11_CFLAGS) -o $@ \
xim_live_test.c ../ipc.c $(X11_LIBS)

View File

@@ -624,11 +624,15 @@ main(int argc, char **argv)
rootmade = 0;
serverup = 0;
ok = 0;
if(argc != 2)
return fail("usage: gtk_live_test /path/to/im-strans.so");
if(argc != 2){
fail("usage: gtk_live_test /path/to/im-strans.so");
return 1;
}
module = realpath(argv[1], NULL);
if(module == NULL)
return fail("realpath %s: %s", argv[1], strerror(errno));
if(module == NULL){
fail("realpath %s: %s", argv[1], strerror(errno));
return 1;
}
Check(mkdtemp(root) != NULL, "mkdtemp: %s", strerror(errno));
rootmade = 1;
Check(snprintf(runtime, sizeof runtime, "%s/runtime", root) <

View File

@@ -408,7 +408,7 @@ ximend(Ximfix *f)
}
static Keyreq
nexttrace(struct ct *t, Ximfix *f, int op, Ic *state)
nexttracecap(struct ct *t, Ximfix *f, int op, Ic *owner, int cap)
{
Keyreq req;
@@ -416,12 +416,18 @@ nexttrace(struct ct *t, Ximfix *f, int op, Ic *state)
if(!CT_CHECK(t, channbrecv(f->trace, &req) > 0))
return req;
CT_EQ_INT(t, op, req.op);
CT_EQ_PTR(t, state, req.owner);
CT_EQ_INT(t, state->cap, req.cap);
CT_EQ_PTR(t, owner, req.owner);
CT_EQ_INT(t, cap, req.cap);
CT_EQ_PTR(t, replyc, req.reply);
return req;
}
static Keyreq
nexttrace(struct ct *t, Ximfix *f, int op, Ic *state)
{
return nexttracecap(t, f, op, state, state->cap);
}
static void
notrace(struct ct *t, Ximfix *f)
{
@@ -489,6 +495,7 @@ xim_adapter_release_lifecycle(struct ct *t)
Ximfix f;
Ic a, b, *dead;
Keyres res;
int deadcap;
memset(&a, 0, sizeof a);
memset(&b, 0, sizeof b);
@@ -530,8 +537,9 @@ xim_adapter_release_lifecycle(struct ct *t)
keypress(dead, 'n', 0, &res);
nexttrace(t, &f, Keypress, dead);
CT_EQ_PTR(t, dead, testengineowner());
deadcap = dead->cap;
icfree(dead);
nexttrace(t, &f, Keyrelease, dead);
nexttracecap(t, &f, Keyrelease, dead, deadcap);
dead = nil;
CT_EQ_PTR(t, nil, ics);
CT_EQ_PTR(t, nil, testengineowner());