diff options
author | Amitay Isaacs <amitay@gmail.com> | 2017-07-07 17:21:54 +1000 |
---|---|---|
committer | Martin Schwenke <martins@samba.org> | 2017-09-01 08:52:07 +0200 |
commit | 1787a4b63292aee0e9df4e4031188ac239d804d8 (patch) | |
tree | e8a30034ab27dff14ca078c8918cff031ce48bbc /ctdb/tests | |
parent | 15c91774d943fba1985f33d10e24030264ce64c8 (diff) | |
download | samba-1787a4b63292aee0e9df4e4031188ac239d804d8.tar.gz |
ctdb-protocol: Add a generic packet header
This will avoid duplication when new daemons (and new client-server
protocols) are created out of the main ctdb daemon.
Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
Diffstat (limited to 'ctdb/tests')
-rw-r--r-- | ctdb/tests/src/protocol_common.c | 13 | ||||
-rw-r--r-- | ctdb/tests/src/protocol_common.h | 4 | ||||
-rw-r--r-- | ctdb/tests/src/protocol_types_test.c | 5 |
3 files changed, 22 insertions, 0 deletions
diff --git a/ctdb/tests/src/protocol_common.c b/ctdb/tests/src/protocol_common.c index f5fe3c7901b..e9ba658259c 100644 --- a/ctdb/tests/src/protocol_common.c +++ b/ctdb/tests/src/protocol_common.c @@ -1383,3 +1383,16 @@ void verify_ctdb_g_lock_list(struct ctdb_g_lock_list *p1, verify_ctdb_g_lock(&p1->lock[i], &p2->lock[i]); } } + +void fill_sock_packet_header(struct sock_packet_header *p) +{ + p->length = rand32(); + p->reqid = rand32(); +} + +void verify_sock_packet_header(struct sock_packet_header *p1, + struct sock_packet_header *p2) +{ + assert(p1->length == p2->length); + assert(p1->reqid == p2->reqid); +} diff --git a/ctdb/tests/src/protocol_common.h b/ctdb/tests/src/protocol_common.h index 5a270328b5f..01b1e34a440 100644 --- a/ctdb/tests/src/protocol_common.h +++ b/ctdb/tests/src/protocol_common.h @@ -350,4 +350,8 @@ void fill_ctdb_g_lock_list(TALLOC_CTX *mem_ctx, struct ctdb_g_lock_list *p); void verify_ctdb_g_lock_list(struct ctdb_g_lock_list *p1, struct ctdb_g_lock_list *p2); +void fill_sock_packet_header(struct sock_packet_header *p); +void verify_sock_packet_header(struct sock_packet_header *p1, + struct sock_packet_header *p2); + #endif /* __CTDB_PROTOCOL_COMMON_H__ */ diff --git a/ctdb/tests/src/protocol_types_test.c b/ctdb/tests/src/protocol_types_test.c index 15ccd49999f..7dbc99edfc6 100644 --- a/ctdb/tests/src/protocol_types_test.c +++ b/ctdb/tests/src/protocol_types_test.c @@ -24,6 +24,7 @@ #include "protocol/protocol_basic.c" #include "protocol/protocol_types.c" +#include "protocol/protocol_sock.c" #include "tests/src/protocol_common.h" @@ -75,6 +76,8 @@ PROTOCOL_TYPE1_TEST(struct ctdb_server_id, ctdb_server_id); PROTOCOL_TYPE1_TEST(struct ctdb_g_lock, ctdb_g_lock); PROTOCOL_TYPE3_TEST(struct ctdb_g_lock_list, ctdb_g_lock_list); +PROTOCOL_TYPE1_TEST(struct sock_packet_header, sock_packet_header); + static void test_ctdb_rec_buffer_read_write(void) { TALLOC_CTX *mem_ctx = talloc_new(NULL); @@ -176,6 +179,8 @@ int main(int argc, char *argv[]) TEST_FUNC(ctdb_g_lock)(); TEST_FUNC(ctdb_g_lock_list)(); + TEST_FUNC(sock_packet_header)(); + test_ctdb_rec_buffer_read_write(); return 0; |