czmq: add test (#993)
Adaptation of the Hello World! example from http://czmq.zeromq.org/ that uses an in-process channel, sends a string, receives it, and prints it.
This commit is contained in:
parent
12fe5cec80
commit
4d2373410e
1 changed files with 30 additions and 0 deletions
|
@ -46,4 +46,34 @@ class Czmq < Formula
|
|||
system "make", "install"
|
||||
rm Dir["#{bin}/*.gsl"]
|
||||
end
|
||||
|
||||
test do
|
||||
(testpath/"test.c").write <<-EOS.undent
|
||||
#include <czmq.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
zsock_t *push = zsock_new_push("inproc://hello-world");
|
||||
zsock_t *pull = zsock_new_pull("inproc://hello-world");
|
||||
|
||||
zstr_send(push, "Hello, World!");
|
||||
char *string = zstr_recv(pull);
|
||||
puts(string);
|
||||
zstr_free(&string);
|
||||
|
||||
zsock_destroy(&pull);
|
||||
zsock_destroy(&push);
|
||||
|
||||
return 0;
|
||||
}
|
||||
EOS
|
||||
|
||||
flags = ENV.cflags.to_s.split + %W[
|
||||
-I#{include}
|
||||
-L#{lib}
|
||||
-lczmq
|
||||
]
|
||||
system ENV.cc, "-o", "test", "test.c", *flags
|
||||
assert_equal "Hello, World!\n", shell_output("./test")
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue