kr / ct

(Relatively) Easy Unit Testing in C

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

not possible to run ct without env var MAKEFLAGS specified

ysmolski opened this issue · comments

Without MAKEFLAGS _ctcheck segfaults. Reason:

static int
readtokens()
{
    int n = 1;
    char c, *s;
    if ((s = strstr(getenv("MAKEFLAGS"), " --jobserver-fds="))) {
        rjobfd = (int)strtol(s+17, &s, 10);  /* skip " --jobserver-fds=" */
        wjobfd = (int)strtol(s+1, NULL, 10); /* skip comma */
    }
    if (rjobfd >= 0) {
        fcntl(rjobfd, F_SETFL, fcntl(rjobfd, F_GETFL)|O_NONBLOCK);
        while (read(rjobfd, &c, 1) > 0) {
            n++;
        }
    }
    return n;
}