diff options
Diffstat (limited to 'innobase/com/ts')
-rw-r--r-- | innobase/com/ts/makefile | 19 | ||||
-rw-r--r-- | innobase/com/ts/tscli.c | 96 | ||||
-rw-r--r-- | innobase/com/ts/tscom.c | 94 |
3 files changed, 209 insertions, 0 deletions
diff --git a/innobase/com/ts/makefile b/innobase/com/ts/makefile new file mode 100644 index 00000000000..01c14737c78 --- /dev/null +++ b/innobase/com/ts/makefile @@ -0,0 +1,19 @@ + + + +include ..\..\makefile.i + +doall: tscom tscli + +tscom: ..\com.lib tscom.c makefile + $(CCOM) $(CFL) -I.. -I..\.. ..\com.lib ..\..\ut.lib ..\..\mem.lib ..\..\sync.lib ..\..\os.lib tscom.c $(LFL) + +tscli: ..\com.lib tscli.c makefile + $(CCOM) $(CFL) -I.. -I..\.. ..\com.lib ..\..\ut.lib ..\..\mem.lib ..\..\sync.lib ..\..\os.lib tscli.c $(LFL) + + + + + + + diff --git a/innobase/com/ts/tscli.c b/innobase/com/ts/tscli.c new file mode 100644 index 00000000000..27a787a0e5c --- /dev/null +++ b/innobase/com/ts/tscli.c @@ -0,0 +1,96 @@ +/************************************************************************ +The test module for communication + +(c) 1995 Innobase Oy + +Created 9/26/1995 Heikki Tuuri +*************************************************************************/ + +#include "../com0com.h" +#include "../com0shm.h" +#include "ut0ut.h" +#include "mem0mem.h" +#include "os0thread.h" +#include "sync0ipm.h" +#include "sync0sync.h" + +byte buf[10000]; +char addr[150]; + +void +test1(void) +/*=======*/ +{ + com_endpoint_t* ep; + ulint ret; + ulint size; + ulint len; + ulint addr_len; + ulint i; + + ep = com_endpoint_create(COM_SHM); + + ut_a(ep); + + size = 8192; + + ret = com_endpoint_set_option(ep, COM_OPT_MAX_DGRAM_SIZE, + (byte*)&size, 0); + + ut_a(ret == 0); + + ret = com_bind(ep, "CLI", 3); + + ut_a(ret == 0); + + printf("Client endpoint created!\n"); + + for (i = 0; i < 10000; i++) { + + ret = com_sendto(ep, (byte*)"Hello from client!\n", 18, "SRV", 3); + + ut_a(ret == 0); + + ret = com_recvfrom(ep, buf, 10000, &len, addr, 150, &addr_len); + + ut_a(ret == 0); + + buf[len] = '\0'; + addr[addr_len] = '\0'; +/* + printf( + "Message of len %lu\n%s \nreceived from address %s of len %lu\n", + len, buf, addr, addr_len); +*/ + } + + ret = com_endpoint_free(ep); + + ut_ad(ret == 0); + + + printf("Count of extra system calls in com_shm %lu\n", + com_shm_system_call_count); + printf("Count of extra system calls in ip_mutex %lu\n", + ip_mutex_system_call_count); +} + +void +main(void) +/*======*/ +{ + ulint tm, oldtm; + + sync_init(); + mem_init(); + + oldtm = ut_clock(); + + test1(); + + ut_ad(mem_all_freed()); + + tm = ut_clock(); + printf("Wall clock time for test %ld milliseconds\n", tm - oldtm); + printf("TESTS COMPLETED SUCCESSFULLY!\n"); +} diff --git a/innobase/com/ts/tscom.c b/innobase/com/ts/tscom.c new file mode 100644 index 00000000000..a02db40efa7 --- /dev/null +++ b/innobase/com/ts/tscom.c @@ -0,0 +1,94 @@ +/************************************************************************ +The test module for communication + +(c) 1995 Innobase Oy + +Created 9/26/1995 Heikki Tuuri +*************************************************************************/ + +#include "../com0com.h" +#include "../com0shm.h" +#include "ut0ut.h" +#include "mem0mem.h" +#include "os0thread.h" +#include "sync0ipm.h" +#include "sync0sync.h" + +byte buf[10000]; +char addr[150]; + +void +test1(void) +/*=======*/ +{ + com_endpoint_t* ep; + ulint ret; + ulint size; + ulint len; + ulint addr_len; + ulint i; + + ep = com_endpoint_create(COM_SHM); + + ut_a(ep); + + size = 8192; + + ret = com_endpoint_set_option(ep, COM_OPT_MAX_DGRAM_SIZE, + (byte*)&size, 0); + + ut_a(ret == 0); + + ret = com_bind(ep, "SRV", 3); + + ut_a(ret == 0); + + printf("Server endpoint created!\n"); + + for (i = 0; i < 50000; i++) { + + ret = com_recvfrom(ep, buf, 10000, &len, addr, 150, &addr_len); + + ut_a(ret == 0); + + buf[len] = '\0'; + addr[addr_len] = '\0'; +/* + printf( + "Message of len %lu\n%s \nreceived from address %s of len %lu\n", + len, buf, addr, addr_len); +*/ + ret = com_sendto(ep, (byte*)"Hello from server!\n", 18, "CLI", 3); + + ut_a(ret == 0); + } + + ret = com_endpoint_free(ep); + + ut_ad(ret == 0); + + printf("Count of extra system calls in com_shm %lu\n", + com_shm_system_call_count); + printf("Count of extra system calls in ip_mutex %lu\n", + ip_mutex_system_call_count); +} + +void +main(void) +/*======*/ +{ + ulint tm, oldtm; + + sync_init(); + mem_init(); + + oldtm = ut_clock(); + + test1(); + + ut_ad(mem_all_freed()); + + tm = ut_clock(); + printf("Wall clock time for test %ld milliseconds\n", tm - oldtm); + printf("TESTS COMPLETED SUCCESSFULLY!\n"); +} |