diff options
author | Laurent Ghigonis <laurent@p1sec.com> | 2012-11-29 09:22:37 +0100 |
---|---|---|
committer | Laurent Ghigonis <laurent@p1sec.com> | 2012-11-29 09:22:37 +0100 |
commit | 386cb32df2308c2511085dd4f2a586457c5b4ad6 (patch) | |
tree | 13eace84e8dfc0175266a899a35649a425fc5d3a /libglouglou/tests | |
parent | add a unittest for testing sending are receiving pkts (diff) | |
download | glouglou-386cb32df2308c2511085dd4f2a586457c5b4ad6.tar.xz glouglou-386cb32df2308c2511085dd4f2a586457c5b4ad6.zip |
sending and receiving packets implemented and tested in unittest
Diffstat (limited to 'libglouglou/tests')
-rw-r--r-- | libglouglou/tests/sendrecv.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/libglouglou/tests/sendrecv.c b/libglouglou/tests/sendrecv.c index f4702e8..0127cb4 100644 --- a/libglouglou/tests/sendrecv.c +++ b/libglouglou/tests/sendrecv.c @@ -8,7 +8,7 @@ int cli_recv_ok = 0; int srv_handle_packet(struct gg_server *srv, struct gg_user *usr, struct gg_packet *pkt) { - if (usr->id == 1) + if (pkt->type == PACKET_NEWCONN) srv_recv_ok = 1; return 0; } @@ -16,7 +16,8 @@ srv_handle_packet(struct gg_server *srv, struct gg_user *usr, struct gg_packet * int cli_handle_packet(struct gg_client *cli, struct gg_packet *pkt) { - cli_recv_ok = 1; + if (pkt->type == PACKET_NEWCONN) + cli_recv_ok = 1; return 0; } @@ -42,6 +43,15 @@ main(void) event_base_loop(ev_base, EVLOOP_ONCE); event_base_loop(ev_base, EVLOOP_ONCE); + pkt.ver = PACKET_VERSION; + pkt.type = PACKET_NEWCONN; + + gg_server_send(srv, &pkt, PACKET_NEWCONN_SIZE, NULL); + event_base_loop(ev_base, EVLOOP_ONCE); + + gg_client_send(cli, &pkt, PACKET_NEWCONN_SIZE); + event_base_loop(ev_base, EVLOOP_ONCE); + if (srv_recv_ok == 0) printf("error: srv_recv_ok == 0\n"); if (cli_recv_ok == 0) |