]> git.ozlabs.org Git - ccan/blob - ccan/antithread/test/run-tell_parent.c
antithread: fix -Wwrite-strings warning in test, and trailing whitespace.
[ccan] / ccan / antithread / test / run-tell_parent.c
1 #include <ccan/antithread/antithread.c>
2 #include <assert.h>
3 #include <ccan/tap/tap.h>
4
5 static void *test(struct at_pool *atp, int *pid)
6 {
7         *pid = getpid();
8         at_tell_parent(atp, test);
9         return NULL;
10 };
11
12 int main(int argc, char *argv[])
13 {
14         struct at_pool *atp;
15         struct athread *at;
16         int *pid;
17
18         plan_tests(4);
19
20         atp = at_pool(1*1024*1024);
21         assert(atp);
22         pid = talloc(at_pool_ctx(atp), int);
23         assert(pid);
24         ok1((char *)pid >= (char *)atp->p->pool
25             && (char *)pid < (char *)atp->p->pool + atp->p->poolsize);
26         at = at_run(atp, test, pid);
27         assert(at);
28
29         ok1(at_read(at) == test);
30         talloc_free(at);
31
32         ok1(*pid != 0);
33         ok1(*pid != getpid());
34
35         return exit_status();
36 }