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
0039 #include <atmi.h>
0040 #include <ubf.h>
0041 #include <ndebug.h>
0042 #include <test.fd.h>
0043 #include <ndrstandard.h>
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055 int main(int argc, char** argv) {
0056
0057 UBFH *p_ub = NULL;
0058 int i, j;
0059 int ret=EXSUCCEED;
0060 int cd;
0061 long revent;
0062 char tmp[126];
0063
0064 if (EXSUCCEED!=tpopen())
0065 {
0066 NDRX_LOG(log_error, "TESTERROR: tpopen() fail: %d:[%s]",
0067 tperrno, tpstrerror(tperrno));
0068 ret=EXFAIL;
0069 goto out;
0070 }
0071
0072 for (j=0; j<1000; j++)
0073 {
0074 p_ub = (UBFH *)tpalloc("UBF", NULL, 1024);
0075
0076 if (EXSUCCEED!=tpbegin(40, 0))
0077 {
0078 NDRX_LOG(log_error, "TESTERROR: tpbegin() fail: %d:[%s]",
0079 tperrno, tpstrerror(tperrno));
0080 ret=EXFAIL;
0081 goto out;
0082 }
0083
0084 if (EXFAIL==(cd=tpconnect("CONVSV", (char *)p_ub, 0L, TPRECVONLY)))
0085 {
0086 NDRX_LOG(log_error, "TESTSV connect failed!: %s",
0087 tpstrerror(tperrno));
0088 ret=EXFAIL;
0089 goto out;
0090 }
0091
0092
0093 NDRX_LOG(log_debug, "About to tprecv!");
0094
0095 while (EXSUCCEED==tprecv(cd, (char **)&p_ub, 0L, 0L, &revent))
0096 {
0097 NDRX_LOG(log_info, "MSG RECEIVED OK %ld!", revent);
0098 }
0099
0100
0101 if (TPEEVENT==tperrno)
0102 {
0103 if (TPEV_SENDONLY==revent)
0104 {
0105 int i=0;
0106
0107 for (i=0; i<10 && EXSUCCEED==ret; i++)
0108 {
0109 snprintf(tmp, sizeof(tmp), "CLT: %d\n", i);
0110 Bchg(p_ub, T_STRING_FLD, 0, tmp, 0L);
0111 ret=tpsend(cd, (char *)p_ub, 0L, 0L, &revent);
0112 }
0113 }
0114 }
0115
0116
0117 if (EXFAIL==tpsend(cd, (char *)p_ub, 0L, TPRECVONLY, &revent))
0118 {
0119 NDRX_LOG(log_debug, "Failed to give server control!!");
0120 ret=EXFAIL;
0121 goto out;
0122 }
0123
0124 NDRX_LOG(log_debug, "Get response from tprecv!");
0125 Bfprint(p_ub, stderr);
0126
0127
0128 ret=tprecv(cd, (char **)&p_ub, 0L, 0L, &revent);
0129 NDRX_LOG(log_error, "tprecv failed with ret=%d errno=%d revent=%ld",
0130 ret, tperrno, revent);
0131
0132 if (EXFAIL==ret && TPEEVENT==tperrno && TPEV_SVCSUCC==revent)
0133 {
0134 NDRX_LOG(log_error, "Service finished with TPEV_SVCSUCC!");
0135 if (EXSUCCEED!=(ret=tpcommit(0)))
0136 {
0137 NDRX_LOG(log_error, "TESTERROR: tpcommit()==%d fail: %d:[%s]",
0138 ret, tperrno, tpstrerror(tperrno));
0139 ret=EXFAIL;
0140 goto out;
0141 }
0142 ret=EXSUCCEED;
0143 }
0144 else
0145 {
0146 if (EXSUCCEED!=(ret=tpabort(0)))
0147 {
0148 NDRX_LOG(log_error, "TESTERROR: tpabort()==%d fail: %d:[%s]",
0149 ret, tperrno, tpstrerror(tperrno));
0150 ret=EXFAIL;
0151 goto out;
0152 }
0153 }
0154
0155 tpdiscon(cd);
0156
0157 if (NULL!=p_ub)
0158 {
0159 tpfree((char *)p_ub);
0160 p_ub = NULL;
0161 }
0162 }
0163
0164 out:
0165
0166 if (EXSUCCEED!=tpclose())
0167 {
0168 NDRX_LOG(log_error, "TESTERROR: tpclose() fail: %d:[%s]",
0169 tperrno, tpstrerror(tperrno));
0170 }
0171
0172 if (EXSUCCEED!=tpterm())
0173 {
0174 NDRX_LOG(log_error, "tpterm failed with: %s", tpstrerror(tperrno));
0175 ret=EXFAIL;
0176 }
0177
0178 if (NULL!=p_ub)
0179 {
0180 tpfree((char *)p_ub);
0181 }
0182
0183 return ret;
0184 }
0185
0186