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 "test72.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 ret=EXSUCCEED;
0066 long sent=0;
0067 long sentread=0;
0068 long t;
0069 char *action = getenv("TEST_ACTION");
0070 ndrx_stopwatch_t w;
0071
0072
0073
0074 if (argc < 2)
0075 {
0076 fprintf(stderr, "Usage: %s <Service_name>\n", argv[0]);
0077 EXFAIL_OUT(ret);
0078 }
0079
0080 if (NULL==action)
0081 {
0082 fprintf(stderr, "Missing env TEST_ACTION!");
0083 EXFAIL_OUT(ret);
0084 }
0085
0086 ndrx_stopwatch_reset(&w);
0087
0088
0089 #if EX_SIZEOF_LONG==4
0090 while (ndrx_stopwatch_get_delta_sec(&w) < 5)
0091 #else
0092 while (ndrx_stopwatch_get_delta_sec(&w) < 200)
0093 #endif
0094 {
0095 if (EXFAIL==CBchg(p_ub, T_STRING_FLD, 0, VALUE_EXPECTED, 0, BFLD_STRING))
0096 {
0097 NDRX_LOG(log_debug, "Failed to set T_STRING_FLD[0]: %s", Bstrerror(Berror));
0098 EXFAIL_OUT(ret);
0099 }
0100
0101
0102 if (EXFAIL == tpacall(argv[1], (char *)p_ub, 0L, TPNOREPLY|TPNOTIME))
0103 {
0104 NDRX_LOG(log_error, "%s failed: %s", argv[1], tpstrerror(tperrno));
0105 EXFAIL_OUT(ret);
0106 }
0107
0108 sent++;
0109 }
0110
0111
0112
0113 ndrx_stopwatch_reset(&w);
0114
0115
0116 while (sentread!=sent && (t=ndrx_stopwatch_get_delta_sec(&w)) < 1000)
0117 {
0118 NDRX_LOG(log_warn, "Waiting sent=%ld got=%ld for queues to flush at bridges... (spent: %lds)",
0119 sent, sentread, t);
0120
0121
0122
0123
0124 if (EXFAIL == tpcall(argv[2], (char *)p_ub, 0L, (char **)&p_ub, &rsplen, 0))
0125 {
0126 NDRX_LOG(log_error, "%s failed: %s", argv[2], tpstrerror(tperrno));
0127 EXFAIL_OUT(ret);
0128 }
0129
0130
0131 if (EXSUCCEED!=Bget(p_ub, T_LONG_FLD, 0, (char *)&sentread, 0L))
0132 {
0133 NDRX_LOG(log_error, "TESTERROR: Failed to get T_LONG_FLD: %s", Bstrerror(Berror));
0134 EXFAIL_OUT(ret);
0135 }
0136
0137 sleep(1);
0138 }
0139
0140 if (sentread!=sent)
0141 {
0142 NDRX_LOG(log_error, "error: sent: %ld but server have seen: %ld",
0143 sent, sentread);
0144 userlog("testcl finished - failed");
0145
0146 if ('1' == action[0])
0147 {
0148 EXFAIL_OUT(ret);
0149 }
0150 }
0151
0152 userlog("testcl finished - OK");
0153
0154 out:
0155 tpterm();
0156 fprintf(stderr, "Exit with %d\n", ret);
0157
0158 return ret;
0159 }
0160
0161