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 "test51.h"
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061 int main(int argc, char** argv)
0062 {
0063 UBFH *p_ub = (UBFH *)tpalloc("UBF", NULL, 56000);
0064 long rsplen;
0065 int cd;
0066 int ret=EXSUCCEED;
0067 int err;
0068
0069 if (EXSUCCEED!=tpinit(NULL))
0070 {
0071 NDRX_LOG(log_debug, "TESTERROR: Failed to init: %s",
0072 tpstrerror(tperrno));
0073 EXFAIL_OUT(ret);
0074 }
0075
0076 NDRX_LOG(log_debug, "running of the case");
0077
0078
0079 if (EXSUCCEED!=tptoutset(1))
0080 {
0081 NDRX_LOG(log_debug, "TESTERROR: Failed to set timeout to 1: %s",
0082 tpstrerror(tperrno));
0083 EXFAIL_OUT(ret);
0084 }
0085
0086 if (EXFAIL==CBchg(p_ub, T_STRING_FLD, 0, VALUE_EXPECTED, 0, BFLD_STRING))
0087 {
0088 NDRX_LOG(log_debug, "Failed to set T_STRING_FLD[0]: %s", Bstrerror(Berror));
0089 ret=EXFAIL;
0090 goto out;
0091 }
0092
0093
0094 if (EXSUCCEED == tpcall("TESTSV", (char *)p_ub, 0L, (char **)&p_ub, &rsplen,0))
0095 {
0096 NDRX_LOG(log_error, "TESTERROR! Call succeed but must fail!");
0097 ret=EXFAIL;
0098 goto out;
0099 }
0100
0101 err = tperrno;
0102
0103 if (tperrno!=TPETIME)
0104 {
0105 NDRX_LOG(log_error, "TESTERROR! Expected TPETIME, but got: %d!", err);
0106 ret=EXFAIL;
0107 goto out;
0108 }
0109
0110
0111
0112
0113
0114
0115 if (EXSUCCEED!=tptoutset(6))
0116 {
0117 NDRX_LOG(log_debug, "TESTERROR: Failed to set timeout to 6: %s",
0118 tpstrerror(tperrno));
0119 EXFAIL_OUT(ret);
0120 }
0121
0122
0123 if (EXFAIL == tpcall("TESTSV", (char *)p_ub, 0L, (char **)&p_ub, &rsplen,0))
0124 {
0125 NDRX_LOG(log_error, "TESTERROR! Second call failed: %s",
0126 tpstrerror(tperrno));
0127 ret=EXFAIL;
0128 goto out;
0129 }
0130
0131
0132
0133
0134
0135
0136 if (EXSUCCEED!=tptoutset(2))
0137 {
0138 NDRX_LOG(log_debug, "TESTERROR: Failed to set timeout to 2: %s",
0139 tpstrerror(tperrno));
0140 EXFAIL_OUT(ret);
0141 }
0142
0143
0144
0145
0146
0147
0148
0149 if (EXFAIL == tpacall("TESTSV", (char *)p_ub, 0L, 0))
0150 {
0151 NDRX_LOG(log_error, "TESTERROR! tpacall failed (1): %s",
0152 tpstrerror(tperrno));
0153 ret=EXFAIL;
0154 goto out;
0155 }
0156
0157 if (EXFAIL == tpacall("TESTSV", (char *)p_ub, 0L, 0))
0158 {
0159 NDRX_LOG(log_error, "TESTERROR! tpacall failed (2): %s",
0160 tpstrerror(tperrno));
0161 ret=EXFAIL;
0162 goto out;
0163 }
0164
0165 if (EXFAIL == tpacall("TESTSV", (char *)p_ub, 0L, 0))
0166 {
0167 NDRX_LOG(log_error, "TESTERROR! tpacall failed (3): %s",
0168 tpstrerror(tperrno));
0169 ret=EXFAIL;
0170 goto out;
0171 }
0172
0173
0174 if (EXSUCCEED!=tptoutset(5))
0175 {
0176 NDRX_LOG(log_debug, "TESTERROR: Failed to set timeout to 5: %s",
0177 tpstrerror(tperrno));
0178 EXFAIL_OUT(ret);
0179 }
0180
0181
0182
0183
0184
0185
0186 if (EXSUCCEED!=tpgetrply(&cd, (char **)&p_ub, &rsplen, TPGETANY))
0187 {
0188 NDRX_LOG(log_error, "TESTERROR! tpgetrply (1) failed: %s",
0189 tpstrerror(tperrno));
0190 ret=EXFAIL;
0191 goto out;
0192 }
0193
0194
0195
0196
0197
0198
0199
0200
0201
0202
0203
0204
0205 if (EXSUCCEED==tpgetrply(&cd, (char **)&p_ub, &rsplen, TPGETANY))
0206 {
0207 NDRX_LOG(log_error, "TESTERROR! tpgetrply (2) SUCCEED but must fail!");
0208 ret=EXFAIL;
0209 goto out;
0210 }
0211
0212 err = tperrno;
0213 if (tperrno!=TPETIME)
0214 {
0215 NDRX_LOG(log_error, "TESTERROR! Expected TPETIME (2), but got: %d!", err);
0216 ret=EXFAIL;
0217 goto out;
0218 }
0219
0220 if (EXSUCCEED==tpgetrply(&cd, (char **)&p_ub, &rsplen, TPGETANY))
0221 {
0222 NDRX_LOG(log_error, "TESTERROR! tpgetrply (3) SUCCEED but must fail!");
0223 ret=EXFAIL;
0224 goto out;
0225 }
0226
0227 err = tperrno;
0228 if (tperrno!=TPETIME)
0229 {
0230 NDRX_LOG(log_error, "TESTERROR! Expected TPETIME (3), but got: %d!", err);
0231 ret=EXFAIL;
0232 goto out;
0233 }
0234
0235 out:
0236 tpterm();
0237 fprintf(stderr, "Exit with %d\n", ret);
0238
0239 return ret;
0240 }
0241