X-Git-Url: http://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Fantithread%2Ftest%2Frun-tell_parent.c;fp=ccan%2Fantithread%2Ftest%2Frun-tell_parent.c;h=a38f8c913a35c21d614ac7cdbcff6b227dbb4838;hp=0000000000000000000000000000000000000000;hb=36e8b652d0aa045e6e427dc3851da24472ed6a95;hpb=cc1e3419b6c5e4abf1b99b0094bc3e134356525e diff --git a/ccan/antithread/test/run-tell_parent.c b/ccan/antithread/test/run-tell_parent.c new file mode 100644 index 00000000..a38f8c91 --- /dev/null +++ b/ccan/antithread/test/run-tell_parent.c @@ -0,0 +1,36 @@ +#include "antithread/antithread.c" +#include +#include "tap/tap.h" + +static void *test(struct at_pool *atp, int *pid) +{ + *pid = getpid(); + at_tell_parent(atp, test); + return NULL; +}; + +int main(int argc, char *argv[]) +{ + struct at_pool *atp; + struct athread *at; + int *pid; + + plan_tests(4); + + atp = at_pool(1*1024*1024); + assert(atp); + pid = talloc(at_pool_ctx(atp), int); + assert(pid); + ok1((char *)pid >= (char *)atp->pool + && (char *)pid < (char *)atp->pool + atp->poolsize); + at = at_run(atp, test, pid); + assert(at); + + ok1(at_read(at) == test); + talloc_free(at); + + ok1(*pid != 0); + ok1(*pid != getpid()); + + return exit_status(); +}