]> git.ozlabs.org Git - ccan/blob - ccan/antithread/test/run-simple.c
ccanlint clean and move endian.h to top of #includes (tests that it doesn't need...
[ccan] / ccan / antithread / test / run-simple.c
1 #include "antithread/antithread.c"
2 #include <assert.h>
3 #include "tap/tap.h"
4
5 static void *test(struct at_pool *atp, int *pid)
6 {
7         *pid = getpid();
8         return NULL;
9 };
10
11 int main(int argc, char *argv[])
12 {
13         struct at_pool *atp;
14         struct athread *at;
15         int *pid;
16
17         plan_tests(4);
18
19         atp = at_pool(1*1024*1024);
20         assert(atp);
21         pid = talloc(at_pool_ctx(atp), int);
22         assert(pid);
23         ok1((char *)pid >= (char *)atp->p->pool
24             && (char *)pid < (char *)atp->p->pool + atp->p->poolsize);
25         at = at_run(atp, test, pid);
26         assert(at);
27
28         ok1(at_read(at) == NULL);
29         talloc_free(at);
30
31         ok1(*pid != 0);
32         ok1(*pid != getpid());
33
34         return exit_status();
35 }