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 #include <unistd.h>
0040
0041 #include <oatmi.h>
0042 #include <oubf.h>
0043 #include <ubf.h>
0044 #include <atmi.h>
0045 #include <ndebug.h>
0046 #include <test.fd.h>
0047 #include <ndrstandard.h>
0048 #include <nstdutil.h>
0049 #include <odebug.h>
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061 int main(int argc, char** argv)
0062 {
0063 int ret = EXSUCCEED;
0064 UBFH *p_ub1 = NULL;
0065 UBFH *p_ub2 = NULL;
0066 UBFH *p_ub3 = NULL;
0067
0068 int ret_ctx;
0069 int cd1, cd2, cd3;
0070 long rsplen;
0071 long l;
0072 int i;
0073
0074 #if defined(EX_OS_DARWIN) || defined(EX_OS_SUNOS)
0075
0076 for (i=0; i<50; i++)
0077 #else
0078 for (i=0; i<10000; i++)
0079 #endif
0080 {
0081
0082 TPCONTEXT_T ctx1 = tpnewctxt(0,0);
0083 TPCONTEXT_T ctx2 = tpnewctxt(0,0);
0084 TPCONTEXT_T ctx3 = tpnewctxt(0,0);
0085
0086 TPCONTEXT_T tmpt;
0087
0088 if (NULL==ctx1 || NULL==ctx2 || NULL==ctx3)
0089 {
0090 NDRX_LOG(log_error, "TESTERROR: Failed to get new context (%p/%p/%p): %s",
0091 ctx1, ctx2, ctx3, tpstrerror(tperrno));
0092 EXFAIL_OUT(ret);
0093 }
0094
0095
0096 if (EXSUCCEED!=Otpinit(&ctx1, NULL))
0097 {
0098 ONDRX_LOG(&ctx1, log_error, "TESTERROR: Failed to Otpinit 1: %s",
0099 Otpstrerror(&ctx1, Otperrno(&ctx1)));
0100 EXFAIL_OUT(ret);
0101 }
0102
0103 if (EXSUCCEED!=Otpinit(&ctx2, NULL))
0104 {
0105 ONDRX_LOG(&ctx2, log_error, "TESTERROR: Failed to Otpinit 2: %s",
0106 Otpstrerror(&ctx2, Otperrno(&ctx2)));
0107 EXFAIL_OUT(ret);
0108 }
0109
0110 if (EXSUCCEED!=Otpinit(&ctx3, NULL))
0111 {
0112 ONDRX_LOG(&ctx3, log_error, "TESTERROR: Failed to Otpinit 3: %s",
0113 Otpstrerror(&ctx3, Otperrno(&ctx3)));
0114 EXFAIL_OUT(ret);
0115 }
0116
0117 ONDRX_LOG(&ctx1, log_always, "Hello from CTX1");
0118 ONDRX_LOG(&ctx2, log_always, "Hello from CTX2");
0119 ONDRX_LOG(&ctx3, log_always, "Hello from CTX3");
0120
0121 if (NULL==(p_ub1 = (UBFH *)Otpalloc(&ctx1, "UBF", NULL, 8192)))
0122 {
0123 NDRX_LOG(log_error, "TESTERROR: Failed to Otpalloc ub1: %s",
0124 Otpstrerror(&ctx1, Otperrno(&ctx1)));
0125 EXFAIL_OUT(ret);
0126 }
0127
0128 if (NULL==(p_ub2 = (UBFH *)Otpalloc(&ctx2, "UBF", NULL, 8192)))
0129 {
0130 NDRX_LOG(log_error, "TESTERROR: Failed to Otpalloc ub2: %s",
0131 Otpstrerror(&ctx2, Otperrno(&ctx2)));
0132 EXFAIL_OUT(ret);
0133 }
0134
0135 if (NULL==(p_ub3 = (UBFH *)Otpalloc(&ctx3, "UBF", NULL, 8192)))
0136 {
0137 NDRX_LOG(log_error, "TESTERROR: Failed to Otpalloc ub3: %s",
0138 Otpstrerror(&ctx3, Otperrno(&ctx3)));
0139 EXFAIL_OUT(ret);
0140 }
0141
0142
0143 if (TPNULLCONTEXT!=(ret_ctx=tpgetctxt(&tmpt, 0)))
0144 {
0145 NDRX_LOG(log_error, "TESTERROR: tpgetctxt() NOT %d", ret_ctx);
0146 EXFAIL_OUT(ret);
0147 }
0148
0149
0150
0151
0152
0153
0154
0155
0156
0157
0158 if (EXSUCCEED!=OCBchg(&ctx1, p_ub1, T_LONG_FLD, 0, "1", 0L, BFLD_STRING))
0159 {
0160 NDRX_LOG(log_error, "TESTERROR: OCBchg() failed %s",
0161 OBstrerror(&ctx1, OBerror(&ctx1)));
0162 EXFAIL_OUT(ret);
0163 }
0164
0165 if (EXSUCCEED!=OCBchg(&ctx2, p_ub2, T_LONG_FLD, 0, "2", 0L, BFLD_STRING))
0166 {
0167 NDRX_LOG(log_error, "TESTERROR: OCBchg() failed %s",
0168 OBstrerror(&ctx2, OBerror(&ctx2)));
0169 EXFAIL_OUT(ret);
0170 }
0171
0172 if (EXSUCCEED!=OCBchg(&ctx3, p_ub3, T_LONG_FLD, 0, "3", 0L, BFLD_STRING))
0173 {
0174 NDRX_LOG(log_error, "TESTERROR: OCBchg() failed %s",
0175 OBstrerror(&ctx3, OBerror(&ctx3)));
0176 EXFAIL_OUT(ret);
0177 }
0178
0179
0180 if (EXFAIL==(cd1=Otpacall(&ctx1, "TEST32_1ST", (char *)p_ub1, 0L, 0L)))
0181 {
0182 NDRX_LOG(log_error, "TESTERROR: Failed to Otpacall 1: %s",
0183 Otpstrerror(&ctx1, Otperrno(&ctx1)));
0184 EXFAIL_OUT(ret);
0185 }
0186
0187 if (EXFAIL==(cd2=Otpacall(&ctx2, "TEST32_1ST", (char *)p_ub2, 0L, 0L)))
0188 {
0189 NDRX_LOG(log_error, "TESTERROR: Failed to Otpacall 2: %s",
0190 Otpstrerror(&ctx2, Otperrno(&ctx2)));
0191 EXFAIL_OUT(ret);
0192 }
0193
0194 if (EXFAIL==(cd3=Otpacall(&ctx3, "TEST32_1ST", (char *)p_ub3, 0L, 0L)))
0195 {
0196 NDRX_LOG(log_error, "TESTERROR: Failed to Otpacall 3: %s",
0197 Otpstrerror(&ctx3, Otperrno(&ctx3)));
0198 EXFAIL_OUT(ret);
0199 }
0200
0201
0202
0203
0204 if (EXSUCCEED!=Otpgetrply(&ctx1, &cd1, (char **)&p_ub1, &rsplen, 0L))
0205 {
0206 NDRX_LOG(log_error, "TESTERROR: Failed to Otpgetrply 1: %s",
0207 Otpstrerror(&ctx1, Otperrno(&ctx1)));
0208 EXFAIL_OUT(ret);
0209 }
0210
0211 if (EXSUCCEED!=OBget(&ctx1, p_ub1, T_LONG_FLD, 1, (char *)&l, 0L))
0212 {
0213 NDRX_LOG(log_error, "TESTERROR: Failed to get T_LONG_FLD[1]!");
0214 EXFAIL_OUT(ret);
0215 }
0216
0217 if (l!=1)
0218 {
0219 NDRX_LOG(log_error, "TESTERROR: got l=%ld, but must 1", l);
0220 EXFAIL_OUT(ret);
0221 }
0222
0223
0224 if (EXSUCCEED!=Otpgetrply(&ctx2, &cd2, (char **)&p_ub2, &rsplen, 0L))
0225 {
0226 NDRX_LOG(log_error, "TESTERROR: Failed to Otpgetrply 2: %s",
0227 Otpstrerror(&ctx2, Otperrno(&ctx2)));
0228 EXFAIL_OUT(ret);
0229 }
0230
0231 if (EXSUCCEED!=OBget(&ctx2, p_ub2, T_LONG_FLD, 1, (char *)&l, 0L))
0232 {
0233 NDRX_LOG(log_error, "TESTERROR: Failed to get T_LONG_FLD[1]!");
0234 EXFAIL_OUT(ret);
0235 }
0236
0237 if (l!=2)
0238 {
0239 NDRX_LOG(log_error, "TESTERROR: got l=%ld, but must 2", l);
0240 EXFAIL_OUT(ret);
0241 }
0242
0243
0244 if (EXSUCCEED!=Otpgetrply(&ctx3, &cd3, (char **)&p_ub3, &rsplen, 0L))
0245 {
0246 NDRX_LOG(log_error, "TESTERROR: Failed to Otpgetrply 3: %s",
0247 Otpstrerror(&ctx3, Otperrno(&ctx3)));
0248 EXFAIL_OUT(ret);
0249 }
0250
0251 if (EXSUCCEED!=OBget(&ctx3, p_ub3, T_LONG_FLD, 1, (char *)&l, 0L))
0252 {
0253 NDRX_LOG(log_error, "TESTERROR: Failed to get T_LONG_FLD[1]!");
0254 EXFAIL_OUT(ret);
0255 }
0256
0257 if (l!=3)
0258 {
0259 NDRX_LOG(log_error, "TESTERROR: got l=%ld, but must 3", l);
0260 EXFAIL_OUT(ret);
0261 }
0262
0263 Otpfree(&ctx1, (char *)p_ub1);
0264 Otpfree(&ctx2, (char *)p_ub2);
0265 Otpfree(&ctx3, (char *)p_ub3);
0266
0267 if (EXSUCCEED!=Otpterm(&ctx1))
0268 {
0269 NDRX_LOG(log_error, "TESTERROR: Failed to terminate client 1",
0270 Otpstrerror(&ctx1, Otperrno(&ctx1)));
0271 EXFAIL_OUT(ret);
0272 }
0273
0274 if (EXSUCCEED!=Otpterm(&ctx2))
0275 {
0276 NDRX_LOG(log_error, "TESTERROR: Failed to terminate client 2",
0277 Otpstrerror(&ctx2, Otperrno(&ctx2)));
0278 EXFAIL_OUT(ret);
0279 }
0280
0281 if (EXSUCCEED!=Otpterm(&ctx3))
0282 {
0283 NDRX_LOG(log_error, "TESTERROR: Failed to terminate client 3",
0284 Otpstrerror(&ctx3, Otperrno(&ctx3)));
0285 EXFAIL_OUT(ret);
0286 }
0287
0288 tpfreectxt(ctx1);
0289 tpfreectxt(ctx2);
0290 tpfreectxt(ctx3);
0291
0292 }
0293 out:
0294
0295 return ret;
0296 }
0297
0298