Mercurial > hg > Members > kono > Cerium
changeset 921:58b5bbacb207
add test_linda
author | kazz <kazz@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 26 Jul 2010 00:39:15 +0900 |
parents | dd060540f50e |
children | 655e11f6e437 |
files | Renderer/Test/test_linda.cc |
diffstat | 1 files changed, 33 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Renderer/Test/test_linda.cc Mon Jul 26 00:39:15 2010 +0900 @@ -0,0 +1,33 @@ +#include <stdio.h> +#include <stdlib.h> +#include "lindaapi.h" +#include "aquarium.pb.h" + +int main(int argc, char *argv[]) { + init_linda(); + srandom(time(0)); + aqua::Width *width = new aqua::Width(); + width->set_width(random() % 30); + printf("send: %d\n", width->width()); + int size = width->ByteSize(); + unsigned char *msg = (unsigned char *) malloc(sizeof(char) * size); + width->SerializeToArray(msg, size); + + int linda = open_linda_java("localhost", 10000); + int seq = psx_update(linda, 1, msg, size); + unsigned char *reply = NULL; + while (true) { + psx_sync_n(); + reply = psx_reply(seq); + if (reply != NULL) + break; + } + int len = psx_get_datalength(reply); + if (len != 0) { + width->ParseFromArray(reply + LINDA_HEADER_SIZE, len); + printf("recv: %d\n", width->width()); + } + delete width; + + return 0; +}