0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034 #include <string.h>
0035 #include <stdio.h>
0036 #include <stdlib.h>
0037 #include <memory.h>
0038 #include <math.h>
0039
0040 #include <atmi.h>
0041 #include <ubf.h>
0042 #include <ndebug.h>
0043 #include <test.fd.h>
0044 #include <ndrstandard.h>
0045 #include <nstopwatch.h>
0046 #include <fcntl.h>
0047 #include <unistd.h>
0048 #include <nstdutil.h>
0049 #include "test99.h"
0050 #include <test_view.h>
0051 #include <exassert.h>
0052
0053
0054
0055
0056
0057 typedef struct
0058 {
0059 char *ptr;
0060 long len;
0061 } test_buffer_t;
0062
0063
0064
0065
0066
0067
0068
0069 int main(int argc, char** argv)
0070 {
0071
0072 char *p_ub = tpalloc("UBF", NULL, 56000);
0073 char *str = tpalloc("STRING", NULL, 56000);
0074 char *carr = tpalloc("CARRAY", NULL, 56000);
0075 char *json = tpalloc("JSON", NULL, 56000);
0076 char *view = tpalloc("VIEW", "UBTESTVIEW1", sizeof(struct UBTESTVIEW1));
0077 char *ret_buf = NULL;
0078 long rsplen, revent;
0079 int cd, i;
0080 int ret=EXSUCCEED;
0081
0082 NDRX_ASSERT_VAL_OUT(NULL!=p_ub, "p_ub failed to alloc");
0083 NDRX_ASSERT_VAL_OUT(NULL!=str, "str failed to alloc");
0084 NDRX_ASSERT_VAL_OUT(NULL!=json, "json failed to alloc");
0085 NDRX_ASSERT_VAL_OUT(NULL!=view, "view failed to alloc");
0086
0087 test_buffer_t bufs[] = {{p_ub, 0}, {str, 0}, {carr, 5}, {json, 0}, {view, 0}, {NULL, 0}};
0088 char *p;
0089
0090 strcpy(str, "hello");
0091 strcpy(carr, "world");
0092 strcpy(json, "{}");
0093
0094 for (i=0; i<N_DIM(bufs); i++)
0095 {
0096 if (EXFAIL == tpcall("TESTSV", bufs[i].ptr, bufs[i].len, (char **)&ret_buf, &rsplen,0))
0097 {
0098 NDRX_LOG(log_error, "TESTSV failed (%d): %s", i, tpstrerror(tperrno));
0099 ret=EXFAIL;
0100 goto out;
0101 }
0102 }
0103
0104
0105 for (i=0; i<N_DIM(bufs); i++)
0106 {
0107
0108 if (EXFAIL==(cd = tpconnect("TESTSV", bufs[i].ptr, bufs[i].len, TPRECVONLY)))
0109 {
0110 NDRX_LOG(log_error, "TESTSV tpconnect failed (%d): %s", i, tpstrerror(tperrno));
0111 ret=EXFAIL;
0112 goto out;
0113 }
0114
0115 revent=0;
0116 if (EXFAIL==tprecv(cd, (char **)&p_ub, &rsplen, 0, &revent))
0117 {
0118 if (TPEEVENT!=tperrno || TPEV_SVCSUCC!=revent)
0119 {
0120 NDRX_LOG(log_error, "TESTSV tprecv failed (%d): %s %ld", i, tpstrerror(tperrno), revent);
0121 ret=EXFAIL;
0122 goto out;
0123 }
0124 }
0125 }
0126
0127 out:
0128 tpterm();
0129 fprintf(stderr, "Exit with %d\n", ret);
0130
0131 return ret;
0132 }
0133
0134