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 "test84.h"
0050 #include <unistd.h>
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062 int main(int argc, char** argv)
0063 {
0064 UBFH *p_ub = (UBFH *)tpalloc("UBF", NULL, 56000);
0065 long rsplen;
0066 int ret=EXSUCCEED;
0067 char svcnm_proc[1024]={EXEOS};
0068 int e=0;
0069 int c;
0070 char svcnm[XATMI_SERVICE_NAME_LENGTH+1]={EXEOS};
0071 char tmp[1024];
0072 int do_conv=EXFALSE;
0073 int do_null=EXFALSE;
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084 while ((c = getopt(argc, argv, "S:s:l:d:e:g:Cc:N")) != -1) {
0085
0086 switch (c)
0087 {
0088 case 'N':
0089 do_null=EXTRUE;
0090 break;
0091 case 'C':
0092 NDRX_LOG(log_debug, "Doing conv");
0093 do_conv=EXTRUE;
0094 break;
0095 case 'S':
0096 NDRX_STRCPY_SAFE(svcnm, optarg);
0097 break;
0098 case 'g':
0099 NDRX_STRCPY_SAFE(svcnm_proc, optarg);
0100 break;
0101 case 'e':
0102 e = atoi(optarg);
0103 break;
0104 case 'l':
0105 if (EXFAIL==CBchg(p_ub, T_LONG_2_FLD, 0, optarg, 0, BFLD_STRING))
0106 {
0107 NDRX_LOG(log_debug, "Failed to set T_LONG_2_FLD[0]: %s", Bstrerror(Berror));
0108 ret=EXFAIL;
0109 goto out;
0110 }
0111 break;
0112 case 's':
0113 if (EXFAIL==CBchg(p_ub, T_STRING_2_FLD, 0, optarg, 0, BFLD_STRING))
0114 {
0115 NDRX_LOG(log_debug, "Failed to set T_STRING_2_FLD[0]: %s", Bstrerror(Berror));
0116 ret=EXFAIL;
0117 goto out;
0118 }
0119 break;
0120 case 'c':
0121 if (EXFAIL==CBchg(p_ub, T_CARRAY_2_FLD, 0, optarg, 0, BFLD_STRING))
0122 {
0123
0124 NDRX_LOG(log_debug, "Failed to set T_CARRAY_2_FLD[0]: %s", Bstrerror(Berror));
0125 ret=EXFAIL;
0126 goto out;
0127 }
0128 break;
0129 case 'd':
0130 if (EXFAIL==CBchg(p_ub, T_DOUBLE_2_FLD, 0, optarg, 0, BFLD_STRING))
0131 {
0132 NDRX_LOG(log_debug, "Failed to set T_DOUBLE_2_FLD[0]: %s", Bstrerror(Berror));
0133 ret=EXFAIL;
0134 goto out;
0135 }
0136 break;
0137 default:
0138 fprintf(stderr, "Usage: %s -S <service_name> -e <errcode_expt> -g <proc_service> -l <long_val>|-s <string_val>|-d <double_val> [-N]\n",
0139 argv[0]);
0140 exit(EXIT_FAILURE);
0141 }
0142 }
0143
0144 tplogprintubf(log_debug, "UBF buffer", p_ub);
0145
0146
0147 if (do_conv)
0148 {
0149 long ev;
0150 int cd;
0151 long rcvlen;
0152
0153 if (EXFAIL == (cd=tpconnect(svcnm, (char *)p_ub, 0L, TPRECVONLY)))
0154 {
0155 NDRX_LOG(log_error, "%s failed: %s", svcnm, tpstrerror(tperrno));
0156
0157 if (tperrno!=e)
0158 {
0159 NDRX_LOG(log_error, "TESTERROR: Expected error %d got %d", e, tperrno);
0160 ret=EXFAIL;
0161 }
0162 goto out;
0163 }
0164
0165 if (EXSUCCEED==tprecv(cd, (char **)&p_ub, &rcvlen, 0, &ev))
0166 {
0167 NDRX_LOG(log_error, "TESTERROR: Expected con error!");
0168 EXFAIL_OUT(ret);
0169 }
0170 else if (tperrno!=TPEEVENT)
0171 {
0172 NDRX_LOG(log_error, "%s failed: %s", svcnm, tpstrerror(tperrno));
0173
0174 if (tperrno!=e)
0175 {
0176 NDRX_LOG(log_error, "TESTERROR: Expected error %d got %d", e, tperrno);
0177 EXFAIL_OUT(ret);
0178 }
0179 }
0180 }
0181 else if (EXFAIL == tpcall(svcnm, do_null?NULL:((char *)p_ub), 0L, (char **)&p_ub, &rsplen,0))
0182 {
0183 NDRX_LOG(log_error, "%s failed: %s", svcnm, tpstrerror(tperrno));
0184
0185
0186 if (tperrno!=e)
0187 {
0188 NDRX_LOG(log_error, "TESTERROR: Expected error %d got %d", e, tperrno);
0189 ret=EXFAIL;
0190 }
0191 goto out;
0192 }
0193
0194 if (!do_null)
0195 {
0196 if (EXSUCCEED!=Bget(p_ub, T_STRING_FLD, 0, tmp, 0L))
0197 {
0198 NDRX_LOG(log_debug, "Failed to get T_STRING_FLD[0]: %s", Bstrerror(Berror));
0199 ret=EXFAIL;
0200 goto out;
0201 }
0202
0203 if (0!=strcmp(tmp, svcnm_proc))
0204 {
0205 NDRX_LOG(log_error, "TESTERROR: Expected service [%s] to process request, but got [%s]",
0206 svcnm_proc, tmp);
0207 EXFAIL_OUT(ret);
0208 }
0209 }
0210
0211 out:
0212 tpterm();
0213 fprintf(stderr, "Exit with %d\n", ret);
0214
0215 return ret;
0216 }
0217
0218