The XIM test carried its own Xvfb and daemon spawner, its own child struct, log files and process-group teardown, and the GTK test a second Xvfb launcher, because live.c's startdaemon always unset DISPLAY. Live now carries the display its own startxvfb reports, startdaemon passes it on, and both tests use the shared pair: 300 lines fewer, one place that knows how a child is started, watched, and stopped.
76 lines
1.6 KiB
C
76 lines
1.6 KiB
C
#include <stddef.h>
|
|
#include <stdint.h>
|
|
#include <sys/types.h>
|
|
|
|
/*
|
|
* Harness shared by the live tests: a strans daemon started in a private
|
|
* XDG_RUNTIME_DIR with its output captured, the endpoints it publishes,
|
|
* and the IPC probe used to prove the daemon answers.
|
|
* Set testname before anything else; fail prefixes it to every message.
|
|
*/
|
|
|
|
typedef struct Daemon Daemon;
|
|
typedef struct Live Live;
|
|
|
|
enum
|
|
{
|
|
Calltimeout = 4000,
|
|
Starttimeout = 8000,
|
|
Stoptimeout = 3000,
|
|
Errmax = 8192,
|
|
};
|
|
|
|
struct Daemon
|
|
{
|
|
pid_t pid;
|
|
int errfd;
|
|
char *name;
|
|
char err[Errmax];
|
|
size_t nerr;
|
|
};
|
|
|
|
struct Live
|
|
{
|
|
char root[256];
|
|
char runtime[320];
|
|
char config[320];
|
|
char ibus[384];
|
|
char bus[448];
|
|
char home[320];
|
|
char socket[384];
|
|
char addrfile[512];
|
|
char display[32];
|
|
};
|
|
|
|
extern char *testname;
|
|
|
|
int fail(char*, ...);
|
|
int64_t nowms(void);
|
|
int leftms(int64_t);
|
|
void pausems(int);
|
|
int makedir(char*);
|
|
int cleardir(char*);
|
|
|
|
int livesetup(Live*, char*);
|
|
int liveclean(Live*);
|
|
|
|
void daemoninit(Daemon*, char*);
|
|
int startxvfb(Live*, Daemon*, char*);
|
|
int startdaemon(Live*, Daemon*, char*, char*);
|
|
int waitready(Live*, Daemon*, char*, size_t);
|
|
int daemonalive(Daemon*);
|
|
int stopdaemon(Daemon*);
|
|
int killdaemon(Daemon*, int*);
|
|
void readerrors(Daemon*);
|
|
void showerrors(Daemon*);
|
|
int closeerrors(Daemon*);
|
|
|
|
int findaddress(Live*);
|
|
int readfile(char*, char*, size_t, size_t*);
|
|
int parseaddress(char*, size_t, char*, size_t, pid_t*);
|
|
|
|
int connectsocket(char*, int64_t);
|
|
int readuntil(int, void*, size_t, int64_t);
|
|
int ipcrequest(int, uint32_t, uint32_t, unsigned char*, size_t, char*);
|
|
int ipcprobe(int, char*);
|