run-simple.c 638 B

1234567891011121314151617181920212223242526272829303132333435
  1. #include <ccan/antithread/antithread.c>
  2. #include <assert.h>
  3. #include <ccan/tap/tap.h>
  4. static void *test(struct at_pool *atp, int *pid)
  5. {
  6. *pid = getpid();
  7. return NULL;
  8. };
  9. int main(int argc, char *argv[])
  10. {
  11. struct at_pool *atp;
  12. struct athread *at;
  13. int *pid;
  14. plan_tests(4);
  15. atp = at_pool(1*1024*1024);
  16. assert(atp);
  17. pid = talloc(at_pool_ctx(atp), int);
  18. assert(pid);
  19. ok1((char *)pid >= (char *)atp->p->pool
  20. && (char *)pid < (char *)atp->p->pool + atp->p->poolsize);
  21. at = at_run(atp, test, pid);
  22. assert(at);
  23. ok1(at_read(at) == NULL);
  24. talloc_free(at);
  25. ok1(*pid != 0);
  26. ok1(*pid != getpid());
  27. return exit_status();
  28. }