]> git.ozlabs.org Git - ccan/blobdiff - ccan/antithread/test/run-tell.c
Add antithread. Not finished, but useful as example of module whose
[ccan] / ccan / antithread / test / run-tell.c
diff --git a/ccan/antithread/test/run-tell.c b/ccan/antithread/test/run-tell.c
new file mode 100644 (file)
index 0000000..fc42095
--- /dev/null
@@ -0,0 +1,30 @@
+#include "antithread/antithread.c"
+#include <assert.h>
+#include "tap/tap.h"
+
+static void *test(struct at_pool *atp, void *unused)
+{
+       char *p;
+       p = at_read_parent(atp);
+       at_tell_parent(atp, p + 1);
+       return NULL;
+};
+
+int main(int argc, char *argv[])
+{
+       struct at_pool *atp;
+       struct athread *at;
+
+       plan_tests(1);
+
+       atp = at_pool(1*1024*1024);
+       assert(atp);
+       at = at_run(atp, test, NULL);
+       assert(at);
+
+       at_tell(at, argv[0]);
+       ok1(at_read(at) == argv[0] + 1);
+       talloc_free(at);
+
+       return exit_status();
+}