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 <unistd.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 <ubfutil.h>
0046 #include <nstopwatch.h>
0047 #include <nstdutil.h>
0048 #include <exassert.h>
0049
0050
0051
0052
0053
0054
0055
0056 exprivate int basic_q_test(void);
0057 exprivate int basic_bench_q_test();
0058 exprivate int enq_q_test(char *q1, char *q2, char *q3);
0059 exprivate int deq_q_test(int do_commit, int lifo, char *q1, char *q2, char *q3);
0060 exprivate int deqempty_q_test(void);
0061 exprivate int basic_q_msgid_test(void);
0062 exprivate int basic_q_corfifo_test(void);
0063 exprivate int basic_q_corlifo_test(void);
0064 exprivate int basic_q_corauto_test(void);
0065 exprivate int basic_q_deqdefault_test(void);
0066 exprivate int basic_q_cortran_test(void);
0067 exprivate int basic_autoq_ok(void);
0068 exprivate int basic_autoqnr_ok(void);
0069
0070 exprivate int basic_rndfail(void);
0071 exprivate int basic_enqcarray(void);
0072 exprivate int basic_autoq_deadq(void);
0073 exprivate int noabort_q_test(void);
0074
0075 exprivate int basic_q_fut_fifo_test(void);
0076 exprivate int basic_q_fut_lifo_test(void);
0077 exprivate int basic_q_fut_fifo_lifo_auto_test(void);
0078 exprivate int basic_q_fut_corfifo_test(void);
0079 exprivate int basic_q_fut_corlifo_test(void);
0080
0081 int main(int argc, char** argv)
0082 {
0083 int ret = EXSUCCEED;
0084
0085 if (argc<=1)
0086 {
0087 NDRX_LOG(log_error, "usage: %s <test_case: basic|enq|deqa|deqc|deqe>", argv[0]);
0088 return EXFAIL;
0089 }
0090 NDRX_LOG(log_error, "\n\n\n\n\n !!!!!!!!!!!!!! TEST CASE %s !!!!!!!! \n\n\n\n\n\n", argv[1]);
0091
0092 if (EXSUCCEED!=tpopen())
0093 {
0094 EXFAIL_OUT(ret);
0095 }
0096
0097 if (0==strcmp(argv[1], "basic"))
0098 {
0099 return basic_q_test();
0100 }
0101 else if (0==strcmp(argv[1], "basicbench"))
0102 {
0103 return basic_bench_q_test();
0104 }
0105 else if (0==strcmp(argv[1], "enq"))
0106 {
0107 return enq_q_test("TESTA", "TESTB", "TESTC");
0108 }
0109 else if (0==strcmp(argv[1], "lenq"))
0110 {
0111 return enq_q_test("LTESTA", "LTESTB", "LTESTC");
0112 }
0113 else if (0==strcmp(argv[1], "deqa"))
0114 {
0115 return deq_q_test(EXFALSE, EXFALSE, "TESTA", "TESTB", "TESTC");
0116 }
0117 else if (0==strcmp(argv[1], "deqc"))
0118 {
0119 return deq_q_test(EXTRUE, EXFALSE, "TESTA", "TESTB", "TESTC");
0120 }
0121 else if (0==strcmp(argv[1], "ldeqa"))
0122 {
0123 return deq_q_test(EXFALSE, EXTRUE, "LTESTA", "LTESTB", "LTESTC");
0124 }
0125 else if (0==strcmp(argv[1], "ldeqc"))
0126 {
0127 return deq_q_test(EXTRUE, EXTRUE, "LTESTA", "LTESTB", "LTESTC");
0128 }
0129 else if (0==strcmp(argv[1], "deqe"))
0130 {
0131 return deqempty_q_test();
0132 }
0133 else if (0==strcmp(argv[1], "msgid"))
0134 {
0135 return basic_q_msgid_test();
0136 }
0137 else if (0==strcmp(argv[1], "corfifo"))
0138 {
0139 return basic_q_corfifo_test();
0140 }
0141 else if (0==strcmp(argv[1], "corlifo"))
0142 {
0143 return basic_q_corlifo_test();
0144 }
0145 else if (0==strcmp(argv[1], "corauto"))
0146 {
0147 return basic_q_corauto_test();
0148 }
0149 else if (0==strcmp(argv[1], "deqdefault"))
0150 {
0151 return basic_q_deqdefault_test();
0152 }
0153 else if (0==strcmp(argv[1], "cortran"))
0154 {
0155 return basic_q_cortran_test();
0156 }
0157 else if (0==strcmp(argv[1], "autoqok"))
0158 {
0159 return basic_autoq_ok();
0160 }
0161 else if (0==strcmp(argv[1], "autoqnr"))
0162 {
0163 return basic_autoqnr_ok();
0164 }
0165 else if (0==strcmp(argv[1], "autodeadq"))
0166 {
0167 return basic_autoq_deadq();
0168 }
0169 else if (0==strcmp(argv[1], "rndfail"))
0170 {
0171 return basic_rndfail();
0172 }
0173 else if (0==strcmp(argv[1], "carr"))
0174 {
0175 return basic_enqcarray();
0176 }
0177 else if (0==strcmp(argv[1], "noabort"))
0178 {
0179 return noabort_q_test();
0180 }
0181 else if (0==strcmp(argv[1], "futfifotrans"))
0182 {
0183 return basic_q_fut_fifo_test();
0184 }
0185 else if (0==strcmp(argv[1], "futlifotrans"))
0186 {
0187 return basic_q_fut_lifo_test();
0188 }
0189 else if (0==strcmp(argv[1], "futauto"))
0190 {
0191 return basic_q_fut_fifo_lifo_auto_test();
0192 }
0193 else if (0==strcmp(argv[1], "futcorfifotrans"))
0194 {
0195 return basic_q_fut_corfifo_test();
0196 }
0197 else if (0==strcmp(argv[1], "futcorlifotrans"))
0198 {
0199 return basic_q_fut_corlifo_test();
0200 }
0201 else
0202 {
0203 NDRX_LOG(log_error, "Invalid test case!");
0204 return EXFAIL;
0205 }
0206
0207 out:
0208
0209 tpclose();
0210
0211 return ret;
0212 }
0213
0214
0215
0216
0217 exprivate int basic_bench_q_test(void)
0218 {
0219
0220 int ret = EXSUCCEED;
0221 TPQCTL qc;
0222 int i, j;
0223 ndrx_stopwatch_t timer;
0224 int call_num = 5000;
0225 int callsz;
0226 int first= EXTRUE;
0227 double cps;
0228
0229
0230 for (j=1; j<56; j+=4)
0231 {
0232 callsz = j*1024;
0233
0234 char *buf = tpalloc("CARRAY", "", callsz);
0235 char *testbuf_ref = tpalloc("CARRAY", "", callsz);
0236
0237 warmed_up:
0238 ndrx_stopwatch_reset(&timer);
0239
0240 for (i=0; i<call_num; i++)
0241 {
0242 long len=callsz;
0243
0244
0245 memset(&qc, 0, sizeof(qc));
0246 if (EXSUCCEED!=tpenqueue("MYSPACE", "TEST1", &qc, testbuf_ref,
0247 len, TPNOTRAN))
0248 {
0249 NDRX_LOG(log_error, "TESTERROR: tpenqueue() failed %s diag: %d:%s",
0250 tpstrerror(tperrno), qc.diagnostic, qc.diagmsg);
0251 EXFAIL_OUT(ret);
0252 }
0253
0254
0255
0256 memset(&qc, 0, sizeof(qc));
0257
0258 len = 10;
0259 if (EXSUCCEED!=tpdequeue("MYSPACE", "TEST1", &qc, &buf,
0260 &len, TPNOTRAN))
0261 {
0262 NDRX_LOG(log_error, "TESTERROR: tpenqueue() failed %s diag: %d:%s",
0263 tpstrerror(tperrno), qc.diagnostic, qc.diagmsg);
0264 EXFAIL_OUT(ret);
0265 }
0266
0267
0268 if (0!=memcmp(testbuf_ref, buf, len))
0269 {
0270 NDRX_LOG(log_error, "TESTERROR: Buffers not equal!");
0271 NDRX_DUMP(log_error, "original buffer", testbuf_ref, sizeof(testbuf_ref));
0272 NDRX_DUMP(log_error, "got form q", buf, len);
0273 EXFAIL_OUT(ret);
0274 }
0275 }
0276
0277
0278 if (first)
0279 {
0280 first = EXFALSE;
0281 goto warmed_up;
0282 }
0283
0284 cps = (double)(call_num)/(double)((double)ndrx_stopwatch_get_delta(&timer)/1000.0f);
0285
0286 fflush(stdout);
0287
0288 if (EXSUCCEED!=ndrx_bench_write_stats((double)j, cps))
0289 {
0290 NDRX_LOG(log_always, "Failed to write stats!");
0291 EXFAIL_OUT(ret);
0292 }
0293 tpfree(buf);
0294 tpfree(testbuf_ref);
0295 }
0296
0297 if (EXSUCCEED!=tpterm())
0298 {
0299 NDRX_LOG(log_error, "tpterm failed with: %s", tpstrerror(tperrno));
0300 ret=EXFAIL;
0301 goto out;
0302 }
0303
0304 out:
0305 return ret;
0306 }
0307
0308
0309
0310
0311 exprivate int basic_q_test(void)
0312 {
0313
0314 int ret = EXSUCCEED;
0315 TPQCTL qc;
0316 int i;
0317
0318
0319 for (i=0; i<1000; i++)
0320 {
0321 char *buf = tpalloc("CARRAY", "", 1);
0322 char *testbuf_ref = tpalloc("CARRAY", "", 10);
0323 long len=10;
0324
0325 testbuf_ref[0]=0;
0326 testbuf_ref[1]=1;
0327 testbuf_ref[2]=2;
0328 testbuf_ref[3]=3;
0329 testbuf_ref[4]=4;
0330 testbuf_ref[5]=5;
0331 testbuf_ref[6]=6;
0332 testbuf_ref[7]=7;
0333 testbuf_ref[8]=8;
0334 testbuf_ref[9]=9;
0335
0336
0337 if (NULL==buf)
0338 {
0339 NDRX_LOG(log_error, "TESTERROR: tpalloc() failed %s",
0340 tpstrerror(tperrno));
0341 EXFAIL_OUT(ret);
0342 }
0343
0344
0345 memset(&qc, 0, sizeof(qc));
0346 if (EXSUCCEED!=tpenqueue("MYSPACE", "TEST1", &qc, testbuf_ref,
0347 len, TPNOTRAN))
0348 {
0349 NDRX_LOG(log_error, "TESTERROR: tpenqueue() failed %s diag: %d:%s",
0350 tpstrerror(tperrno), qc.diagnostic, qc.diagmsg);
0351 EXFAIL_OUT(ret);
0352 }
0353
0354
0355
0356 memset(&qc, 0, sizeof(qc));
0357
0358 len = 10;
0359 if (EXSUCCEED!=tpdequeue("MYSPACE", "TEST1", &qc, &buf,
0360 &len, TPNOTRAN))
0361 {
0362 NDRX_LOG(log_error, "TESTERROR: tpdequeue() failed %s diag: %d:%s",
0363 tpstrerror(tperrno), qc.diagnostic, qc.diagmsg);
0364 EXFAIL_OUT(ret);
0365 }
0366
0367
0368 if (0!=memcmp(testbuf_ref, buf, len))
0369 {
0370 NDRX_LOG(log_error, "TESTERROR: Buffers not equal!");
0371 NDRX_DUMP(log_error, "original buffer", testbuf_ref, sizeof(testbuf_ref));
0372 NDRX_DUMP(log_error, "got form q", buf, len);
0373 EXFAIL_OUT(ret);
0374 }
0375
0376 tpfree(buf);
0377 tpfree(testbuf_ref);
0378 }
0379
0380 if (EXSUCCEED!=tpterm())
0381 {
0382 NDRX_LOG(log_error, "tpterm failed with: %s", tpstrerror(tperrno));
0383 ret=EXFAIL;
0384 goto out;
0385 }
0386
0387 out:
0388 return ret;
0389 }
0390
0391
0392
0393
0394
0395
0396 exprivate int enq_q_test(char *q1, char *q2, char *q3)
0397 {
0398 int ret = EXSUCCEED;
0399 TPQCTL qc;
0400 int i;
0401
0402 UBFH *buf = (UBFH *)tpalloc("UBF", "", 8192);
0403
0404 if (EXSUCCEED!=tpbegin(180, 0))
0405 {
0406 NDRX_LOG(log_error, "TESTERROR! Failed to start transaction!");
0407 EXFAIL_OUT(ret);
0408 }
0409
0410
0411
0412 for (i=1; i<=300; i++)
0413 {
0414
0415 if (EXSUCCEED!=Badd(buf, T_STRING_FLD, "TEST HELLO", 0L))
0416 {
0417 NDRX_LOG(log_error, "TESTERROR: failed to set T_STRING_FLD");
0418 EXFAIL_OUT(ret);
0419 }
0420
0421
0422 memset(&qc, 0, sizeof(qc));
0423
0424 if (EXSUCCEED!=tpenqueue("MYSPACE", q1, &qc, (char *)buf, 0, 0))
0425 {
0426 NDRX_LOG(log_error, "TESTERROR: tpenqueue() failed %s diag: %d:%s",
0427 tpstrerror(tperrno), qc.diagnostic, qc.diagmsg);
0428 EXFAIL_OUT(ret);
0429 }
0430
0431 memset(&qc, 0, sizeof(qc));
0432
0433 if (EXSUCCEED!=tpenqueue("MYSPACE", q2, &qc, (char *)buf, 0, 0))
0434 {
0435 NDRX_LOG(log_error, "TESTERROR: tpenqueue() failed %s diag: %d:%s",
0436 tpstrerror(tperrno), qc.diagnostic, qc.diagmsg);
0437 EXFAIL_OUT(ret);
0438 }
0439
0440 memset(&qc, 0, sizeof(qc));
0441
0442 if (EXSUCCEED!=tpenqueue("MYSPACE", q3, &qc, (char *)buf, 0, 0))
0443 {
0444 NDRX_LOG(log_error, "TESTERROR: tpenqueue() failed %s diag: %d:%s",
0445 tpstrerror(tperrno), qc.diagnostic, qc.diagmsg);
0446 EXFAIL_OUT(ret);
0447 }
0448
0449 }
0450 tpfree((char *)buf);
0451
0452 out:
0453
0454 if (EXSUCCEED==ret && EXSUCCEED!=tpcommit(0))
0455 {
0456 NDRX_LOG(log_error, "TESTERROR: Failed to commit!");
0457 ret=EXFAIL;
0458 }
0459 else
0460 {
0461 tpabort(0);
0462 }
0463
0464 return ret;
0465 }
0466
0467
0468
0469
0470
0471
0472
0473 exprivate int deq_q_test(int do_commit, int lifo, char *q1, char *q2, char *q3)
0474 {
0475 int ret = EXSUCCEED;
0476 TPQCTL qc;
0477 int i, j;
0478 long len;
0479 UBFH *buf = NULL;
0480 if (EXSUCCEED!=tpbegin(180, 0))
0481 {
0482 NDRX_LOG(log_error, "TESTERROR! Failed to start transaction!");
0483 EXFAIL_OUT(ret);
0484 }
0485
0486 if (lifo)
0487 {
0488 i = 300;
0489 }
0490 else
0491 {
0492 i = 1;
0493 }
0494
0495
0496
0497 for (; (lifo?i>=1:i<=300); (lifo?i--:i++))
0498 {
0499
0500 memset(&qc, 0, sizeof(qc));
0501
0502 buf = (UBFH *)tpalloc("UBF", "", 100);
0503 if (EXSUCCEED!=tpdequeue("MYSPACE", q1, &qc, (char **)&buf, &len, 0))
0504 {
0505 NDRX_LOG(log_error, "TESTERROR: tpdequeue() %d failed %s diag: %d:%s",
0506 i, tpstrerror(tperrno), qc.diagnostic, qc.diagmsg);
0507 EXFAIL_OUT(ret);
0508 }
0509
0510 ndrx_debug_dump_UBF(log_debug, "TESTA rcv buf", buf);
0511
0512 if (i!=Boccur(buf, T_STRING_FLD))
0513 {
0514 NDRX_LOG(log_error, "TESTERROR: invalid count for TESTA %d vs %d",
0515 i, Boccur(buf, T_STRING_FLD));
0516 EXFAIL_OUT(ret);
0517 }
0518 tpfree((char *)buf);
0519
0520 memset(&qc, 0, sizeof(qc));
0521
0522 buf = (UBFH *)tpalloc("UBF", "", 100);
0523
0524 if (EXSUCCEED!=tpdequeue("MYSPACE", q2, &qc, (char **)&buf, &len, 0))
0525 {
0526 NDRX_LOG(log_error, "TESTERROR: tpdequeue() failed %s diag: %d:%s",
0527 tpstrerror(tperrno), qc.diagnostic, qc.diagmsg);
0528 EXFAIL_OUT(ret);
0529 }
0530
0531 ndrx_debug_dump_UBF(log_debug, "TESTB rcv buf", buf);
0532
0533 if (i!=Boccur(buf, T_STRING_FLD))
0534 {
0535 NDRX_LOG(log_error, "TESTERROR: invalid count for TESTB %d vs %d",
0536 i, Boccur(buf, T_STRING_FLD));
0537 EXFAIL_OUT(ret);
0538 }
0539
0540 tpfree((char *)buf);
0541
0542
0543 for (j=0; j<2; j++)
0544 {
0545 memset(&qc, 0, sizeof(qc));
0546
0547 if (0==j)
0548 {
0549 qc.flags|=TPQPEEK;
0550 }
0551
0552 buf = (UBFH *)tpalloc("UBF", "", 100);
0553
0554 if (EXSUCCEED!=tpdequeue("MYSPACE", q3, &qc, (char **)&buf, &len, 0))
0555 {
0556 NDRX_LOG(log_error, "TESTERROR: tpdequeue() failed %s diag: %d:%s i=%d j=%d",
0557 tpstrerror(tperrno), qc.diagnostic, qc.diagmsg, i, j);
0558 EXFAIL_OUT(ret);
0559 }
0560
0561 ndrx_debug_dump_UBF(log_debug, "TESTC rcv buf", buf);
0562
0563 if (i!=Boccur(buf, T_STRING_FLD))
0564 {
0565 NDRX_LOG(log_error, "TESTERROR: invalid count for TESTC %d vs %d",
0566 i, Boccur(buf, T_STRING_FLD));
0567 EXFAIL_OUT(ret);
0568 }
0569
0570 tpfree((char *)buf);
0571 }
0572
0573 }
0574
0575
0576 out:
0577
0578 if (do_commit)
0579 {
0580 if (EXSUCCEED!=tpcommit(0))
0581 {
0582 NDRX_LOG(log_error, "TESTERROR: Failed to commit!");
0583 ret=EXFAIL;
0584 }
0585 }
0586 else
0587 {
0588 tpabort(0);
0589 }
0590
0591 return ret;
0592 }
0593
0594
0595
0596
0597
0598
0599 exprivate int deqempty_q_test(void)
0600 {
0601 int ret = EXSUCCEED;
0602 TPQCTL qc;
0603 long len;
0604 UBFH *buf = NULL;
0605
0606 if (EXSUCCEED!=tpbegin(90, 0))
0607 {
0608 NDRX_LOG(log_error, "TESTERROR! Failed to start transaction!");
0609 EXFAIL_OUT(ret);
0610 }
0611
0612 buf = (UBFH *)tpalloc("UBF", "", 100);
0613 memset(&qc, 0, sizeof(qc));
0614
0615 if (EXSUCCEED==tpdequeue("MYSPACE", "TESTA", &qc, (char **)&buf, &len, 0))
0616 {
0617 NDRX_LOG(log_error, "TESTERROR: TESTA not empty!");
0618 EXFAIL_OUT(ret);
0619 }
0620
0621 memset(&qc, 0, sizeof(qc));
0622
0623 if (EXSUCCEED==tpdequeue("MYSPACE", "TESTB", &qc, (char **)&buf, &len, 0))
0624 {
0625 NDRX_LOG(log_error, "TESTERROR: TESTB not empty!");
0626 EXFAIL_OUT(ret);
0627 }
0628
0629 memset(&qc, 0, sizeof(qc));
0630
0631 if (EXSUCCEED==tpdequeue("MYSPACE", "TESTC", &qc, (char **)buf, &len, 0))
0632 {
0633 NDRX_LOG(log_error, "TESTERROR: TESTC not empty!");
0634 EXFAIL_OUT(ret);
0635 }
0636
0637 out:
0638
0639 tpabort(0);
0640
0641 return ret;
0642 }
0643
0644
0645
0646
0647
0648 exprivate int noabort_q_test(void)
0649 {
0650 int ret = EXSUCCEED;
0651 TPQCTL qc;
0652 long len;
0653 UBFH *buf = (UBFH *)tpalloc("UBF", "", 1024);
0654 int i;
0655
0656 if (NULL==buf)
0657 {
0658 NDRX_LOG(log_error, "TESTERROR: failed to allocate buffer: %s",
0659 tpstrerror(tperrno));
0660 EXFAIL_OUT(ret);
0661 }
0662
0663 for (i=0; i<5000; i++)
0664 {
0665
0666 NDRX_LOG(log_warn, "No abort on empty Q");
0667
0668 if (EXSUCCEED!=tpbegin(90, 0))
0669 {
0670 NDRX_LOG(log_error, "TESTERROR! Failed to start transaction!");
0671 EXFAIL_OUT(ret);
0672 }
0673
0674 memset(&qc, 0, sizeof(qc));
0675
0676 if (EXSUCCEED==tpdequeue("MYSPACE", "TESTA", &qc, (char **)&buf, &len, 0))
0677 {
0678 NDRX_LOG(log_error, "TESTERROR: TESTA not empty!");
0679 EXFAIL_OUT(ret);
0680 }
0681
0682 if (EXSUCCEED!=tpcommit(0L))
0683 {
0684 NDRX_LOG(log_error, "TESTERROR! Transaction MUST BE committed but fail: %s",
0685 tpstrerror(tperrno));
0686 EXFAIL_OUT(ret);
0687 }
0688
0689 }
0690 out:
0691 if (NULL!=buf)
0692 {
0693 tpfree((char *)buf);
0694 }
0695
0696 return ret;
0697 }
0698
0699
0700
0701
0702 exprivate int basic_q_msgid_test(void)
0703 {
0704
0705 int ret = EXSUCCEED;
0706 TPQCTL qc1, qc2;
0707 int i, j;
0708
0709
0710 for (i=0; i<1000; i++)
0711 {
0712 char *buf = tpalloc("CARRAY", "", 1);
0713 char *testbuf_ref = tpalloc("CARRAY", "", 1);
0714 long len=1;
0715
0716
0717 if (NULL==buf || NULL==testbuf_ref)
0718 {
0719 NDRX_LOG(log_error, "TESTERROR: tpalloc() failed %s",
0720 tpstrerror(tperrno));
0721 EXFAIL_OUT(ret);
0722 }
0723
0724 testbuf_ref[0]=101;
0725
0726
0727 memset(&qc1, 0, sizeof(qc1));
0728 if (EXSUCCEED!=tpenqueue("MYSPACE", "TEST1", &qc1, testbuf_ref,
0729 len, TPNOTRAN))
0730 {
0731 NDRX_LOG(log_error, "TESTERROR: tpenqueue() failed %s diag: %d:%s",
0732 tpstrerror(tperrno), qc1.diagnostic, qc1.diagmsg);
0733 EXFAIL_OUT(ret);
0734 }
0735
0736 testbuf_ref[0]=102;
0737
0738
0739 memset(&qc2, 0, sizeof(qc2));
0740 if (EXSUCCEED!=tpenqueue("MYSPACE", "TEST1", &qc2, testbuf_ref,
0741 len, TPNOTRAN))
0742 {
0743 NDRX_LOG(log_error, "TESTERROR: tpenqueue() failed %s diag: %d:%s",
0744 tpstrerror(tperrno), qc2.diagnostic, qc2.diagmsg);
0745 EXFAIL_OUT(ret);
0746 }
0747
0748
0749
0750 for (j=0; j<2; j++)
0751 {
0752 len = 1;
0753 buf[0] = 0;
0754
0755 if (0 == j)
0756 {
0757 qc2.flags|=(TPQGETBYMSGID | TPQPEEK);
0758 }
0759 else
0760 {
0761
0762 qc2.flags|=TPQGETBYMSGID;
0763 }
0764
0765 NDRX_LOG(log_info, "Calling with flags: %ld", qc2.flags);
0766 if (EXSUCCEED!=tpdequeue("MYSPACE", "TEST1", &qc2, &buf,
0767 &len, TPNOTRAN))
0768 {
0769 NDRX_LOG(log_error, "TESTERROR: tpenqueue() failed %s diag: %d:%s i=%d j=%d",
0770 tpstrerror(tperrno), qc1.diagnostic, qc1.diagmsg, i, j);
0771 EXFAIL_OUT(ret);
0772 }
0773
0774 if (102!=buf[0])
0775 {
0776 NDRX_LOG(log_error, "TESTERROR: Got %d expected 102", buf[0]);
0777 EXFAIL_OUT(ret);
0778
0779 }
0780 }
0781
0782 for (j=0; j<2; j++)
0783 {
0784 len = 1;
0785 buf[0] = 0;
0786
0787 if (0 == j)
0788 {
0789 qc1.flags|=(TPQGETBYMSGID | TPQPEEK);
0790 }
0791 else
0792 {
0793
0794 qc1.flags |= TPQGETBYMSGID;
0795 }
0796 if (EXSUCCEED!=tpdequeue("MYSPACE", "TEST1", &qc1, &buf,
0797 &len, TPNOTRAN))
0798 {
0799 NDRX_LOG(log_error, "TESTERROR: tpenqueue() failed %s diag: %d:%s i=%d j=%d",
0800 tpstrerror(tperrno), qc1.diagnostic, qc1.diagmsg, i, j);
0801 EXFAIL_OUT(ret);
0802 }
0803
0804 if (101!=buf[0])
0805 {
0806 NDRX_LOG(log_error, "TESTERROR: Got %d expected 101", buf[0]);
0807 EXFAIL_OUT(ret);
0808 }
0809 }
0810
0811 tpfree(buf);
0812 tpfree(testbuf_ref);
0813 }
0814
0815 if (EXSUCCEED!=tpterm())
0816 {
0817 NDRX_LOG(log_error, "tpterm failed with: %s", tpstrerror(tperrno));
0818 ret=EXFAIL;
0819 goto out;
0820 }
0821
0822 out:
0823 return ret;
0824 }
0825
0826
0827
0828
0829
0830
0831
0832
0833
0834
0835
0836 exprivate int basic_q_corfifo_test(void)
0837 {
0838
0839 int ret = EXSUCCEED;
0840 TPQCTL qc1;
0841 int test;
0842 char c,cor;
0843 long len;
0844 char *buf = tpalloc("CARRAY", "", 3);
0845
0846 if (NULL==buf)
0847 {
0848 NDRX_LOG(log_error, "TESTERROR: failed to malloc 3 bytes: %s",
0849 tpstrerror(tperrno));
0850 EXFAIL_OUT(ret);
0851 }
0852
0853
0854 for (test=0; test<2; test++)
0855 {
0856
0857 for (cor=2; cor<5; cor++)
0858 {
0859
0860 for (c=5; c<126; c++)
0861 {
0862 buf[0]=1;
0863 buf[1]=c;
0864 buf[2]=cor;
0865
0866 memset(&qc1, 0, sizeof(qc1));
0867 qc1.flags|=TPQCORRID;
0868 qc1.corrid[0]=cor;
0869
0870 if (EXSUCCEED!=tpenqueue("MYSPACE", "CORFIFO", &qc1, buf, 3, 0))
0871 {
0872 NDRX_LOG(log_error, "TESTERROR: tpenqueue() failed %s diag: %d:%s",
0873 tpstrerror(tperrno), qc1.diagnostic, qc1.diagmsg);
0874 EXFAIL_OUT(ret);
0875 }
0876
0877 }
0878 }
0879
0880
0881 for (c=0; c<126; c++)
0882 {
0883 buf[0]=0;
0884 buf[1]=c;
0885 buf[2]=0;
0886
0887 memset(&qc1, 0, sizeof(qc1));
0888 if (EXSUCCEED!=tpenqueue("MYSPACE", "CORFIFO", &qc1, buf, 3, 0))
0889 {
0890 NDRX_LOG(log_error, "TESTERROR: tpenqueue() failed %s diag: %d:%s",
0891 tpstrerror(tperrno), qc1.diagnostic, qc1.diagmsg);
0892 EXFAIL_OUT(ret);
0893 }
0894 }
0895
0896
0897 if (1==test)
0898 {
0899 if (EXSUCCEED!=system("xadmin restart tmqueue"))
0900 {
0901 NDRX_LOG(log_error, "TESTERROR: failed to restart tmqueue",
0902 strerror(errno));
0903 EXFAIL_OUT(ret);
0904 }
0905 }
0906
0907
0908 memset(&qc1, 0, sizeof(qc1));
0909 len=3;
0910 if (EXSUCCEED!=tpdequeue("MYSPACE", "CORFIFO", &qc1, &buf, &len, 0))
0911 {
0912 NDRX_LOG(log_error, "TESTERROR: tpdequeue() failed %s diag: %d:%s",
0913 tpstrerror(tperrno), qc1.diagnostic, qc1.diagmsg);
0914 EXFAIL_OUT(ret);
0915 }
0916
0917
0918 NDRX_ASSERT_VAL_OUT((buf[0]==1 && buf[1]==5 && buf[2]==2 && len==3 && (qc1.flags & TPQCORRID)),
0919 "Invalid buffer %d %d %d %ld %lx",
0920 (int)buf[0], (int)buf[1], (int)buf[2], len, qc1.flags);
0921
0922
0923 NDRX_ASSERT_VAL_OUT(qc1.corrid[0]==2,
0924 "Invalid cor %d",
0925 (int)qc1.corrid[0]);
0926
0927
0928 for (cor=2; cor<5; cor++)
0929 {
0930
0931
0932
0933 for (c=5; c<127; c++)
0934 {
0935 if (5==c && 2==cor)
0936 {
0937 continue;
0938 }
0939
0940 memset(&qc1, 0, sizeof(qc1));
0941 len=3;
0942
0943 qc1.flags|=TPQGETBYCORRID;
0944 qc1.corrid[0]=cor;
0945 if (EXSUCCEED!=tpdequeue("MYSPACE", "CORFIFO", &qc1, &buf, &len, 0))
0946 {
0947 if (!(c==126 && TPEDIAGNOSTIC==tperrno && QMENOMSG==qc1.diagnostic))
0948 {
0949 NDRX_LOG(log_error, "TESTERROR: tpdequeue() failed %s diag: %d:%s",
0950 tpstrerror(tperrno), qc1.diagnostic, qc1.diagmsg);
0951 EXFAIL_OUT(ret);
0952 }
0953 else
0954 {
0955 continue;
0956 }
0957 }
0958
0959
0960 NDRX_ASSERT_VAL_OUT((buf[0]==1 && buf[1]==c && buf[2]==cor && len==3 && (qc1.flags & TPQCORRID)),
0961 "Invalid buffer %d (exp %d) %d (exp %d) %d (exp %d) %ld %lx",
0962 (int)buf[0], 1, (int)buf[1], (int)c, (int)buf[2], (int)cor, len, qc1.flags);
0963
0964
0965 NDRX_ASSERT_VAL_OUT(qc1.corrid[0]==cor,
0966 "Invalid cor %d (exp %d)",
0967 (int)qc1.corrid[0], (int)cor);
0968 }
0969 }
0970
0971
0972 for (c=0; c<127; c++)
0973 {
0974 memset(&qc1, 0, sizeof(qc1));
0975 len=3;
0976
0977 if (EXSUCCEED!=tpdequeue("MYSPACE", "CORFIFO", &qc1, &buf, &len, 0))
0978 {
0979
0980 if (!(c==126 && TPEDIAGNOSTIC==tperrno && QMENOMSG==qc1.diagnostic))
0981 {
0982 NDRX_LOG(log_error, "TESTERROR: tpdequeue() failed %s diag: %d:%s",
0983 tpstrerror(tperrno), qc1.diagnostic, qc1.diagmsg);
0984 EXFAIL_OUT(ret);
0985 }
0986 else
0987 {
0988 continue;
0989 }
0990 }
0991
0992
0993 NDRX_ASSERT_VAL_OUT((buf[0]==0 && buf[1]==c && buf[2]==0 && len==3),
0994 "Invalid buffer %d (exp %d) %d (exp %d) %d (exp %d) %ld",
0995 (int)buf[0], 0, (int)buf[1], (int)c, (int)buf[2], 0, len);
0996
0997
0998 NDRX_ASSERT_VAL_OUT(qc1.corrid[0]==0 && !(qc1.flags & TPQCORRID),
0999 "Invalid cor %d (exp %d) %lx",
1000 (int)qc1.corrid[0], 0, qc1.flags);
1001 }
1002 }
1003
1004
1005
1006 out:
1007
1008
1009 if (NULL!=buf)
1010 {
1011 tpfree(buf);
1012 }
1013
1014 if (EXSUCCEED!=tpterm())
1015 {
1016 NDRX_LOG(log_error, "tpterm failed with: %s", tpstrerror(tperrno));
1017 ret=EXFAIL;
1018 goto out;
1019 }
1020
1021 return ret;
1022 }
1023
1024
1025
1026
1027
1028 exprivate int basic_q_cortran_test(void)
1029 {
1030 int ret = EXSUCCEED;
1031 TPQCTL qc1;
1032 long len;
1033 char *buf = tpalloc("CARRAY", "", 3);
1034
1035 if (NULL==buf)
1036 {
1037 NDRX_LOG(log_error, "TESTERROR: failed to malloc 3 bytes: %s",
1038 tpstrerror(tperrno));
1039 EXFAIL_OUT(ret);
1040 }
1041
1042 buf[0]=1;
1043 buf[1]=2;
1044 buf[2]=3;
1045
1046 memset(&qc1, 0, sizeof(qc1));
1047 qc1.flags|=TPQCORRID;
1048 qc1.corrid[0]=3;
1049
1050 if (EXSUCCEED!=tpenqueue("MYSPACE", "CORFIFO", &qc1, buf, 3, 0))
1051 {
1052 NDRX_LOG(log_error, "TESTERROR: tpenqueue() failed %s diag: %d:%s",
1053 tpstrerror(tperrno), qc1.diagnostic, qc1.diagmsg);
1054 EXFAIL_OUT(ret);
1055 }
1056
1057 NDRX_ASSERT_TP_OUT(EXSUCCEED==tpbegin(60, 0), "Failed to start tran...");
1058
1059 memset(&qc1, 0, sizeof(qc1));
1060 len=3;
1061
1062 qc1.flags|=TPQGETBYCORRID;
1063 qc1.corrid[0]=3;
1064 if (EXSUCCEED!=tpdequeue("MYSPACE", "CORFIFO", &qc1, &buf, &len, 0))
1065 {
1066 NDRX_LOG(log_error, "TESTERROR: tpdequeue() failed %s diag: %d:%s",
1067 tpstrerror(tperrno), qc1.diagnostic, qc1.diagmsg);
1068 EXFAIL_OUT(ret);
1069 }
1070
1071 memset(&qc1, 0, sizeof(qc1));
1072 len=3;
1073
1074 qc1.flags|=TPQGETBYCORRID;
1075 qc1.corrid[0]=3;
1076 if (EXSUCCEED==tpdequeue("MYSPACE", "CORFIFO", &qc1, &buf, &len, 0))
1077 {
1078 NDRX_LOG(log_error, "TESTERROR: tpdequeue() must fail but succeed!");
1079 EXFAIL_OUT(ret);
1080 }
1081
1082 NDRX_ASSERT_VAL_OUT(TPEDIAGNOSTIC==tperrno && QMENOMSG==qc1.diagnostic,
1083 "Expected QMENOMSG got %d %ld", tperrno, qc1.diagnostic);
1084
1085 NDRX_ASSERT_TP_OUT(EXSUCCEED==tpcommit(0), "Failed to commit...");
1086
1087
1088 memset(&qc1, 0, sizeof(qc1));
1089 len=3;
1090 if (EXSUCCEED==tpdequeue("MYSPACE", "CORFIFO", &qc1, &buf, &len, 0))
1091 {
1092 NDRX_LOG(log_error, "TESTERROR: tpdequeue() must fail but succeed!");
1093 EXFAIL_OUT(ret);
1094 }
1095
1096 NDRX_ASSERT_VAL_OUT(TPEDIAGNOSTIC==tperrno && QMENOMSG==qc1.diagnostic,
1097 "Expected QMENOMSG got %d %ld", tperrno, qc1.diagnostic);
1098
1099 out:
1100
1101
1102 if (NULL!=buf)
1103 {
1104 tpfree(buf);
1105 }
1106
1107 if (EXSUCCEED!=tpterm())
1108 {
1109 NDRX_LOG(log_error, "tpterm failed with: %s", tpstrerror(tperrno));
1110 ret=EXFAIL;
1111 goto out;
1112 }
1113
1114 return ret;
1115 }
1116
1117
1118
1119
1120
1121
1122 exprivate int basic_q_corlifo_test(void)
1123 {
1124
1125 int ret = EXSUCCEED;
1126 TPQCTL qc1;
1127 int test;
1128 signed char c,cor;
1129 long len;
1130 char *buf = tpalloc("CARRAY", "", 3);
1131
1132 if (NULL==buf)
1133 {
1134 NDRX_LOG(log_error, "TESTERROR: failed to malloc 3 bytes: %s",
1135 tpstrerror(tperrno));
1136 EXFAIL_OUT(ret);
1137 }
1138
1139
1140 for (test=0; test<2; test++)
1141 {
1142
1143
1144 for (c=1; c<126; c++)
1145 {
1146 buf[0]=0;
1147 buf[1]=c;
1148 buf[2]=0;
1149
1150 memset(&qc1, 0, sizeof(qc1));
1151 if (EXSUCCEED!=tpenqueue("MYSPACE", "CORLIFO", &qc1, buf, 3, 0))
1152 {
1153 NDRX_LOG(log_error, "TESTERROR: tpenqueue() failed %s diag: %d:%s",
1154 tpstrerror(tperrno), qc1.diagnostic, qc1.diagmsg);
1155 EXFAIL_OUT(ret);
1156 }
1157 }
1158
1159
1160 for (cor=2; cor<5; cor++)
1161 {
1162
1163 for (c=5; c<126; c++)
1164 {
1165 buf[0]=1;
1166 buf[1]=c;
1167 buf[2]=cor;
1168
1169 memset(&qc1, 0, sizeof(qc1));
1170 qc1.flags|=TPQCORRID;
1171 qc1.corrid[0]=cor;
1172
1173 if (EXSUCCEED!=tpenqueue("MYSPACE", "CORLIFO", &qc1, buf, 3, 0))
1174 {
1175 NDRX_LOG(log_error, "TESTERROR: tpenqueue() failed %s diag: %d:%s",
1176 tpstrerror(tperrno), qc1.diagnostic, qc1.diagmsg);
1177 EXFAIL_OUT(ret);
1178 }
1179
1180 }
1181 }
1182
1183
1184 if (1==test)
1185 {
1186 if (EXSUCCEED!=system("xadmin restart tmqueue"))
1187 {
1188 NDRX_LOG(log_error, "TESTERROR: failed to restart tmqueue",
1189 strerror(errno));
1190 EXFAIL_OUT(ret);
1191 }
1192 }
1193
1194
1195 memset(&qc1, 0, sizeof(qc1));
1196 len=3;
1197 if (EXSUCCEED!=tpdequeue("MYSPACE", "CORLIFO", &qc1, &buf, &len, 0))
1198 {
1199 NDRX_LOG(log_error, "TESTERROR: tpdequeue() failed %s diag: %d:%s",
1200 tpstrerror(tperrno), qc1.diagnostic, qc1.diagmsg);
1201 EXFAIL_OUT(ret);
1202 }
1203
1204
1205 NDRX_ASSERT_VAL_OUT((buf[0]==1 && buf[1]==125 && buf[2]==4 && len==3 && (qc1.flags & TPQCORRID)),
1206 "Invalid buffer %d %d %d %ld %lx",
1207 (int)buf[0], (int)buf[1], (int)buf[2], len, qc1.flags);
1208
1209
1210 NDRX_ASSERT_VAL_OUT(qc1.corrid[0]==4,
1211 "Invalid cor %d",
1212 (int)qc1.corrid[0]);
1213
1214
1215 for (cor=2; cor<5; cor++)
1216 {
1217
1218
1219
1220 for (c=125; c>=4; c--)
1221 {
1222 if (125==c && 4==cor)
1223 {
1224 continue;
1225 }
1226
1227 memset(&qc1, 0, sizeof(qc1));
1228 len=3;
1229
1230 qc1.flags|=TPQGETBYCORRID;
1231 qc1.corrid[0]=cor;
1232 if (EXSUCCEED!=tpdequeue("MYSPACE", "CORLIFO", &qc1, &buf, &len, 0))
1233 {
1234 if (!(c==4 && TPEDIAGNOSTIC==tperrno && QMENOMSG==qc1.diagnostic))
1235 {
1236 NDRX_LOG(log_error, "TESTERROR: tpdequeue() failed %s diag: %d:%s",
1237 tpstrerror(tperrno), qc1.diagnostic, qc1.diagmsg);
1238 EXFAIL_OUT(ret);
1239 }
1240 else
1241 {
1242 continue;
1243 }
1244 }
1245
1246
1247 NDRX_ASSERT_VAL_OUT((buf[0]==1 && buf[1]==c && buf[2]==cor && len==3 && (qc1.flags & TPQCORRID)),
1248 "Invalid buffer %d (exp %d) %d (exp %d) %d (exp %d) %ld %lx",
1249 (int)buf[0], 1, (int)buf[1], (int)c, (int)buf[2], (int)cor, len, qc1.flags);
1250
1251
1252 NDRX_ASSERT_VAL_OUT(qc1.corrid[0]==cor,
1253 "Invalid cor %d (exp %d)",
1254 (int)qc1.corrid[0], (int)cor);
1255 }
1256 }
1257
1258
1259 for (c=125; c>=0; c--)
1260 {
1261 memset(&qc1, 0, sizeof(qc1));
1262 len=3;
1263
1264 if (EXSUCCEED!=tpdequeue("MYSPACE", "CORLIFO", &qc1, &buf, &len, 0))
1265 {
1266
1267 if (!(0==c && TPEDIAGNOSTIC==tperrno && QMENOMSG==qc1.diagnostic))
1268 {
1269 NDRX_LOG(log_error, "TESTERROR: tpdequeue() failed on %d - %s diag: %d:%s",
1270 (int)c, tpstrerror(tperrno), qc1.diagnostic, qc1.diagmsg);
1271 EXFAIL_OUT(ret);
1272 }
1273 else
1274 {
1275 continue;
1276 }
1277 }
1278
1279
1280 NDRX_ASSERT_VAL_OUT((buf[0]==0 && buf[1]==c && buf[2]==0 && len==3),
1281 "Invalid buffer %d (exp %d) %d (exp %d) %d (exp %d) %ld",
1282 (int)buf[0], 0, (int)buf[1], (int)c, (int)buf[2], 0, len);
1283
1284
1285 NDRX_ASSERT_VAL_OUT(qc1.corrid[0]==0 && !(qc1.flags & TPQCORRID),
1286 "Invalid cor %d (exp %d) %lx",
1287 (int)qc1.corrid[0], 0, qc1.flags);
1288 }
1289 }
1290
1291
1292 out:
1293
1294
1295 if (NULL!=buf)
1296 {
1297 tpfree(buf);
1298 }
1299
1300 if (EXSUCCEED!=tpterm())
1301 {
1302 NDRX_LOG(log_error, "tpterm failed with: %s", tpstrerror(tperrno));
1303 ret=EXFAIL;
1304 goto out;
1305 }
1306
1307 return ret;
1308 }
1309
1310
1311
1312
1313
1314
1315 exprivate int basic_q_deqdefault_test(void)
1316 {
1317 int ret = EXSUCCEED;
1318 TPQCTL qc1;
1319
1320 long len;
1321 char *buf = tpalloc("CARRAY", "", 3);
1322
1323 if (NULL==buf)
1324 {
1325 NDRX_LOG(log_error, "TESTERROR: failed to malloc 3 bytes: %s",
1326 tpstrerror(tperrno));
1327 EXFAIL_OUT(ret);
1328 }
1329
1330 memset(&qc1, 0, sizeof(qc1));
1331 len=3;
1332
1333 ret=tpdequeue("MYSPACE", "NO_SUCH_Q", &qc1, &buf, &len, 0);
1334
1335 if (!(EXFAIL==ret && TPEDIAGNOSTIC==tperrno && QMENOMSG==qc1.diagnostic))
1336 {
1337 NDRX_LOG(log_error, "TESTERROR: tpdequeue() failed %s diag: %d:%s",
1338 tpstrerror(tperrno), qc1.diagnostic, qc1.diagmsg);
1339 EXFAIL_OUT(ret);
1340 }
1341
1342 ret = EXSUCCEED;
1343
1344 out:
1345
1346 if (NULL!=buf)
1347 {
1348 tpfree(buf);
1349 }
1350
1351 tpterm();
1352
1353 return ret;
1354 }
1355
1356
1357
1358
1359
1360 exprivate int basic_q_corauto_test(void)
1361 {
1362 int ret = EXSUCCEED;
1363 TPQCTL qc1;
1364 char c,cor, i;
1365 long len;
1366 char *buf = tpalloc("CARRAY", "", 3);
1367
1368 if (NULL==buf)
1369 {
1370 NDRX_LOG(log_error, "TESTERROR: failed to malloc 3 bytes: %s",
1371 tpstrerror(tperrno));
1372 EXFAIL_OUT(ret);
1373 }
1374
1375
1376 for (cor=2; cor<50; cor++)
1377 {
1378 for (i=0; i<2; i++)
1379 {
1380 buf[0]=1;
1381 buf[1]=i;
1382 buf[2]=cor;
1383
1384 memset(&qc1, 0, sizeof(qc1));
1385 qc1.flags|=TPQCORRID;
1386 qc1.corrid[0]=cor;
1387
1388 if (EXSUCCEED!=tpenqueue("MYSPACE", "CORAUTO", &qc1, buf, 3, 0))
1389 {
1390 NDRX_LOG(log_error, "TESTERROR: tpenqueue() failed %s diag: %d:%s",
1391 tpstrerror(tperrno), qc1.diagnostic, qc1.diagmsg);
1392 EXFAIL_OUT(ret);
1393 }
1394 }
1395
1396 }
1397
1398 sleep(30);
1399
1400
1401 for (cor=2; cor<50; cor++)
1402 {
1403 for (i=0; i<2; i++)
1404 {
1405 memset(&qc1, 0, sizeof(qc1));
1406 len=3;
1407
1408 qc1.flags|=TPQGETBYCORRID;
1409 qc1.corrid[0]=cor;
1410 if (EXSUCCEED!=tpdequeue("MYSPACE", "CORERR", &qc1, &buf, &len, 0))
1411 {
1412 NDRX_LOG(log_error, "TESTERROR: tpdequeue() failed %s diag: %d:%s",
1413 tpstrerror(tperrno), qc1.diagnostic, qc1.diagmsg);
1414 EXFAIL_OUT(ret);
1415 }
1416
1417
1418 NDRX_ASSERT_VAL_OUT((buf[0]==1 && (buf[1]==0||buf[1]==1)
1419 && buf[2]==cor && len==3 && (qc1.flags & TPQCORRID)),
1420 "Invalid buffer %d (exp %d) %d (exp 0|1) %d (exp %d) %ld %lx",
1421 (int)buf[0], 1, (int)buf[1], (int)buf[2], (int)cor, len, qc1.flags);
1422
1423
1424 NDRX_ASSERT_VAL_OUT(qc1.corrid[0]==cor,
1425 "Invalid cor %d (exp %d)",
1426 (int)qc1.corrid[0], (int)cor);
1427 }
1428 }
1429
1430
1431
1432 ret=tpdequeue("MYSPACE", "CORAUTO", &qc1, &buf, &len, 0);
1433
1434 if (!(EXFAIL==ret && TPEDIAGNOSTIC==tperrno && QMENOMSG==qc1.diagnostic))
1435 {
1436 NDRX_LOG(log_error, "TESTERROR: tpdequeue() failed %s diag: %d:%s",
1437 tpstrerror(tperrno), qc1.diagnostic, qc1.diagmsg);
1438 EXFAIL_OUT(ret);
1439 }
1440
1441 ret = EXSUCCEED;
1442
1443 out:
1444
1445
1446 if (NULL!=buf)
1447 {
1448 tpfree(buf);
1449 }
1450
1451 if (EXSUCCEED!=tpterm())
1452 {
1453 NDRX_LOG(log_error, "tpterm failed with: %s", tpstrerror(tperrno));
1454 ret=EXFAIL;
1455 goto out;
1456 }
1457
1458 return ret;
1459 }
1460
1461
1462
1463
1464
1465
1466 exprivate int basic_autoq_ok(void)
1467 {
1468 int ret = EXSUCCEED;
1469 TPQCTL qc1;
1470 long len = 0;
1471 char *p;
1472 int i;
1473 char strbuf[128];
1474 char *buf3=NULL;
1475
1476 for (i=0; i<100; i++)
1477 {
1478 UBFH *buf = (UBFH *)tpalloc("UBF", "", 1024);
1479 if (NULL==buf)
1480 {
1481 NDRX_LOG(log_error, "TESTERROR: tpalloc() failed %s",
1482 tpstrerror(tperrno));
1483 EXFAIL_OUT(ret);
1484 }
1485
1486 sprintf(strbuf, "HELLO FROM SENDER");
1487
1488 if (EXSUCCEED!=Bchg(buf, T_STRING_2_FLD, 0, strbuf, 0L))
1489 {
1490 NDRX_LOG(log_error, "TESTERROR: failed to set T_STRING_2_FLD %s",
1491 Bstrerror(Berror));
1492 EXFAIL_OUT(ret);
1493 }
1494
1495
1496 memset(&qc1, 0, sizeof(qc1));
1497
1498 qc1.flags|=TPQREPLYQ;
1499
1500 strcpy(qc1.replyqueue, "REPLYQ");
1501
1502 if (EXSUCCEED!=tpenqueue("MYSPACE", "OKQ1", &qc1, (char *)buf, 0, TPNOTRAN))
1503 {
1504 NDRX_LOG(log_error, "TESTERROR: tpenqueue() failed %s diag: %d:%s",
1505 tpstrerror(tperrno), qc1.diagnostic, qc1.diagmsg);
1506 EXFAIL_OUT(ret);
1507 }
1508 tpfree((char *)buf);
1509 }
1510
1511 sleep(30);
1512
1513 for (i=0; i<100; i++)
1514 {
1515 UBFH *buf2 = (UBFH *)tpalloc("UBF", "", 1024);
1516 memset(&qc1, 0, sizeof(qc1));
1517
1518 NDRX_LOG(log_warn, "LOOP: %d", i);
1519
1520 if (EXSUCCEED!=tpdequeue("MYSPACE", "REPLYQ", &qc1, (char **)&buf2,
1521 &len, TPNOTRAN))
1522 {
1523 NDRX_LOG(log_error, "TESTERROR: tpdequeue() failed %s diag: %d:%s",
1524 tpstrerror(tperrno), qc1.diagnostic, qc1.diagmsg);
1525 EXFAIL_OUT(ret);
1526 }
1527
1528
1529 if (NULL==(p = Bfind(buf2, T_STRING_2_FLD, 0, 0L)))
1530 {
1531 NDRX_LOG(log_error, "TESTERROR: failed to get T_STRING_2_FLD %s",
1532 Bstrerror(Berror));
1533 EXFAIL_OUT(ret);
1534 }
1535
1536 sprintf(strbuf, "HELLO FROM SENDER");
1537
1538 if (0!=strcmp(p, strbuf))
1539 {
1540 NDRX_LOG(log_error, "TESTERROR: Invalid value [%s]", p);
1541 EXFAIL_OUT(ret);
1542 }
1543
1544
1545 if (NULL==(p = Bfind(buf2, T_STRING_FLD, 0, 0L)))
1546 {
1547 NDRX_LOG(log_error, "TESTERROR: failed to get T_STRING_FLD %s",
1548 Bstrerror(Berror));
1549 EXFAIL_OUT(ret);
1550 }
1551
1552 if (0!=strcmp(p, "OK"))
1553 {
1554 NDRX_LOG(log_error, "TESTERROR: Invalid value [%s]", p);
1555 EXFAIL_OUT(ret);
1556 }
1557 tpfree((char *)buf2);
1558 }
1559
1560
1561 if (EXSUCCEED!=system("xadmin restart tmqueue"))
1562 {
1563 NDRX_LOG(log_error, "Failed to restart tmqueue: %s", strerror(errno));
1564 EXFAIL_OUT(ret);
1565 }
1566
1567
1568 memset(&qc1, 0, sizeof(qc1));
1569 len=0;
1570 if (EXSUCCEED==tpdequeue("MYSPACE", "OKQ1", &qc1, (char **)&buf3,
1571 &len, TPNOTRAN))
1572 {
1573 NDRX_LOG(log_error, "TESTERROR: tpdequeue() must fail but was OK!");
1574 EXFAIL_OUT(ret);
1575 }
1576
1577 if (EXSUCCEED!=tpterm())
1578 {
1579 NDRX_LOG(log_error, "tpterm failed with: %s", tpstrerror(tperrno));
1580 ret=EXFAIL;
1581 goto out;
1582 }
1583
1584 out:
1585 return ret;
1586 }
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596 exprivate int basic_autoqnr_ok(void)
1597 {
1598 int ret = EXSUCCEED;
1599 TPQCTL qc1;
1600 long len = 0;
1601 char *p;
1602 int i;
1603 char strbuf[128];
1604 char *buf3=NULL;
1605
1606 for (i=0; i<100; i++)
1607 {
1608 UBFH *buf = (UBFH *)tpalloc("UBF", "", 1024);
1609 if (NULL==buf)
1610 {
1611 NDRX_LOG(log_error, "TESTERROR: tpalloc() failed %s",
1612 tpstrerror(tperrno));
1613 EXFAIL_OUT(ret);
1614 }
1615
1616 sprintf(strbuf, "HELLO FROM SENDER");
1617
1618 if (EXSUCCEED!=Bchg(buf, T_STRING_2_FLD, 0, strbuf, 0L))
1619 {
1620 NDRX_LOG(log_error, "TESTERROR: failed to set T_STRING_2_FLD %s",
1621 Bstrerror(Berror));
1622 EXFAIL_OUT(ret);
1623 }
1624
1625
1626 memset(&qc1, 0, sizeof(qc1));
1627
1628 if (EXSUCCEED!=tpenqueue("MYSPACE", "OKQ1", &qc1, (char *)buf, 0, TPNOTRAN))
1629 {
1630 NDRX_LOG(log_error, "TESTERROR: tpenqueue() failed %s diag: %d:%s",
1631 tpstrerror(tperrno), qc1.diagnostic, qc1.diagmsg);
1632 EXFAIL_OUT(ret);
1633 }
1634 tpfree((char *)buf);
1635 }
1636
1637 sleep(30);
1638
1639
1640 if (EXSUCCEED!=system("xadmin restart tmqueue"))
1641 {
1642 NDRX_LOG(log_error, "Failed to restart tmqueue: %s", strerror(errno));
1643 EXFAIL_OUT(ret);
1644 }
1645
1646
1647 memset(&qc1, 0, sizeof(qc1));
1648 len=0;
1649 if (EXSUCCEED==tpdequeue("MYSPACE", "OKQ1", &qc1, (char **)&buf3,
1650 &len, TPNOTRAN))
1651 {
1652 NDRX_LOG(log_error, "TESTERROR: tpdequeue() must fail but was OK!");
1653 EXFAIL_OUT(ret);
1654 }
1655
1656 if (EXSUCCEED!=tpterm())
1657 {
1658 NDRX_LOG(log_error, "tpterm failed with: %s", tpstrerror(tperrno));
1659 ret=EXFAIL;
1660 goto out;
1661 }
1662
1663 out:
1664 return ret;
1665 }
1666
1667
1668
1669
1670 exprivate int basic_autoq_deadq(void)
1671 {
1672 int ret = EXSUCCEED;
1673 TPQCTL qc1;
1674 long len = 0;
1675 char *p;
1676 int i;
1677 char strbuf[128];
1678
1679
1680 for (i=0; i<100; i++)
1681 {
1682 UBFH *buf = (UBFH *)tpalloc("UBF", "", 1024);
1683 if (NULL==buf)
1684 {
1685 NDRX_LOG(log_error, "TESTERROR: tpalloc() failed %s",
1686 tpstrerror(tperrno));
1687 EXFAIL_OUT(ret);
1688 }
1689
1690 sprintf(strbuf, "HELLO FROM SENDER");
1691
1692 if (EXSUCCEED!=Bchg(buf, T_STRING_2_FLD, 0, strbuf, 0L))
1693 {
1694 NDRX_LOG(log_error, "TESTERROR: failed to set T_STRING_2_FLD %s",
1695 Bstrerror(Berror));
1696 EXFAIL_OUT(ret);
1697 }
1698
1699
1700 memset(&qc1, 0, sizeof(qc1));
1701
1702 qc1.flags|=TPQFAILUREQ;
1703
1704 strcpy(qc1.failurequeue, "DEADQ");
1705
1706 if (EXSUCCEED!=tpenqueue("MYSPACE", "BADQ1", &qc1, (char *)buf, 0, TPNOTRAN))
1707 {
1708 NDRX_LOG(log_error, "TESTERROR: tpenqueue() failed %s diag: %d:%s",
1709 tpstrerror(tperrno), qc1.diagnostic, qc1.diagmsg);
1710 EXFAIL_OUT(ret);
1711 }
1712 tpfree((char *)buf);
1713 }
1714 sleep(60);
1715
1716 for (i=0; i<100; i++)
1717 {
1718 UBFH *buf2 = (UBFH *)tpalloc("UBF", "", 1024);
1719 memset(&qc1, 0, sizeof(qc1));
1720
1721 NDRX_LOG(log_warn, "LOOP: %d", i);
1722
1723 if (EXSUCCEED!=tpdequeue("MYSPACE", "DEADQ", &qc1, (char **)&buf2,
1724 &len, TPNOTRAN))
1725 {
1726 NDRX_LOG(log_error, "TESTERROR: tpenqueue() failed %s diag: %d:%s",
1727 tpstrerror(tperrno), qc1.diagnostic, qc1.diagmsg);
1728 EXFAIL_OUT(ret);
1729 }
1730
1731
1732 if (NULL==(p = Bfind(buf2, T_STRING_2_FLD, 0, 0L)))
1733 {
1734 NDRX_LOG(log_error, "TESTERROR: failed to get T_STRING_2_FLD %s",
1735 Bstrerror(Berror));
1736 EXFAIL_OUT(ret);
1737 }
1738
1739 sprintf(strbuf, "HELLO FROM SENDER");
1740
1741 if (0!=strcmp(p, strbuf))
1742 {
1743 NDRX_LOG(log_error, "TESTERROR: Invalid value [%s]", p);
1744 EXFAIL_OUT(ret);
1745 }
1746
1747 tpfree((char *)buf2);
1748 }
1749
1750 if (EXSUCCEED!=tpterm())
1751 {
1752 NDRX_LOG(log_error, "tpterm failed with: %s", tpstrerror(tperrno));
1753 ret=EXFAIL;
1754 goto out;
1755 }
1756
1757 out:
1758 return ret;
1759 }
1760
1761
1762
1763
1764 exprivate int basic_rndfail(void)
1765 {
1766 int ret = EXSUCCEED;
1767 TPQCTL qc1;
1768 long len = 0;
1769 char *p;
1770 int i;
1771 char strbuf[128];
1772
1773 for (i=0; i<100; i++)
1774 {
1775 UBFH *buf = (UBFH *)tpalloc("UBF", "", 1024);
1776 if (NULL==buf)
1777 {
1778 NDRX_LOG(log_error, "TESTERROR: tpalloc() failed %s",
1779 tpstrerror(tperrno));
1780 EXFAIL_OUT(ret);
1781 }
1782
1783 sprintf(strbuf, "HELLO FROM SENDER");
1784
1785 if (EXSUCCEED!=Bchg(buf, T_STRING_2_FLD, 0, strbuf, 0L))
1786 {
1787 NDRX_LOG(log_error, "TESTERROR: failed to set T_STRING_2_FLD %s",
1788 Bstrerror(Berror));
1789 EXFAIL_OUT(ret);
1790 }
1791
1792
1793 memset(&qc1, 0, sizeof(qc1));
1794
1795 qc1.flags|=TPQREPLYQ;
1796
1797 strcpy(qc1.replyqueue, "REPLYQ");
1798
1799 if (EXSUCCEED!=tpenqueue("MYSPACE", "RFQ", &qc1, (char *)buf, 0, TPNOTRAN))
1800 {
1801 NDRX_LOG(log_error, "TESTERROR: tpenqueue() failed %s diag: %d:%s",
1802 tpstrerror(tperrno), qc1.diagnostic, qc1.diagmsg);
1803 EXFAIL_OUT(ret);
1804 }
1805 tpfree((char *)buf);
1806 }
1807 sleep(30);
1808
1809 for (i=0; i<100; i++)
1810 {
1811 UBFH *buf2 = (UBFH *)tpalloc("UBF", "", 1024);
1812 memset(&qc1, 0, sizeof(qc1));
1813
1814 NDRX_LOG(log_warn, "LOOP: %d", i);
1815
1816 if (EXSUCCEED!=tpdequeue("MYSPACE", "REPLYQ", &qc1, (char **)&buf2,
1817 &len, TPNOTRAN))
1818 {
1819 NDRX_LOG(log_error, "TESTERROR: tpenqueue() failed %s diag: %d:%s",
1820 tpstrerror(tperrno), qc1.diagnostic, qc1.diagmsg);
1821 EXFAIL_OUT(ret);
1822 }
1823
1824
1825 if (NULL==(p = Bfind(buf2, T_STRING_2_FLD, 0, 0L)))
1826 {
1827 NDRX_LOG(log_error, "TESTERROR: failed to get T_STRING_2_FLD %s",
1828 Bstrerror(Berror));
1829 EXFAIL_OUT(ret);
1830 }
1831
1832 sprintf(strbuf, "HELLO FROM SENDER");
1833
1834 if (0!=strcmp(p, strbuf))
1835 {
1836 NDRX_LOG(log_error, "TESTERROR: Invalid value [%s]", p);
1837 EXFAIL_OUT(ret);
1838 }
1839
1840
1841 if (NULL==(p = Bfind(buf2, T_STRING_FLD, 0, 0L)))
1842 {
1843 NDRX_LOG(log_error, "TESTERROR: failed to get T_STRING_FLD %s",
1844 Bstrerror(Berror));
1845 EXFAIL_OUT(ret);
1846 }
1847
1848 if (0!=strcmp(p, "OK"))
1849 {
1850 NDRX_LOG(log_error, "TESTERROR: Invalid value [%s]", p);
1851 EXFAIL_OUT(ret);
1852 }
1853 tpfree((char *)buf2);
1854 }
1855
1856 if (EXSUCCEED!=tpterm())
1857 {
1858 NDRX_LOG(log_error, "tpterm failed with: %s", tpstrerror(tperrno));
1859 ret=EXFAIL;
1860 goto out;
1861 }
1862
1863 out:
1864 return ret;
1865 }
1866
1867
1868
1869
1870
1871 exprivate int basic_enqcarray(void)
1872 {
1873 int ret = EXSUCCEED;
1874 TPQCTL qc1;
1875 long len = 0;
1876 char *buf = tpalloc("CARRAY", "", 8);
1877
1878 if (NULL==buf)
1879 {
1880 NDRX_LOG(log_error, "TESTERROR: tpalloc() failed %s",
1881 tpstrerror(tperrno));
1882 EXFAIL_OUT(ret);
1883 }
1884 buf[0] = 0;
1885 buf[1] = 1;
1886 buf[2] = 2;
1887 buf[3] = 3;
1888 buf[4] = 4;
1889 buf[5] = 5;
1890 buf[6] = 6;
1891 buf[7] = 7;
1892
1893 len = 8;
1894
1895
1896 memset(&qc1, 0, sizeof(qc1));
1897
1898 qc1.flags|=TPQREPLYQ;
1899 strcpy(qc1.replyqueue, "TESTREPLY");
1900
1901 qc1.flags|=TPQFAILUREQ;
1902 strcpy(qc1.failurequeue, "TESTFAIL");
1903
1904 if (EXSUCCEED!=tpenqueue("MYSPACE", "BINQ", &qc1, buf, len, TPNOTRAN))
1905 {
1906 NDRX_LOG(log_error, "TESTERROR: tpenqueue() failed %s diag: %d:%s",
1907 tpstrerror(tperrno), qc1.diagnostic, qc1.diagmsg);
1908 EXFAIL_OUT(ret);
1909 }
1910
1911 tpfree((char *)buf);
1912
1913 if (EXSUCCEED!=tpterm())
1914 {
1915 NDRX_LOG(log_error, "tpterm failed with: %s", tpstrerror(tperrno));
1916 ret=EXFAIL;
1917 goto out;
1918 }
1919
1920 out:
1921 return ret;
1922 }
1923
1924
1925
1926
1927
1928
1929
1930
1931 exprivate int basic_q_fut_fifo_test(void)
1932 {
1933 int ret = EXSUCCEED;
1934 TPQCTL qc1;
1935 long len=0;
1936 int test;
1937 long i, l;
1938 long max_msgs = 200;
1939
1940 for (test = 0; test < 2; test++)
1941 {
1942 for (i=0; i<max_msgs; i++)
1943 {
1944 UBFH *buf = (UBFH *)tpalloc("UBF", "", 1024);
1945 if (NULL==buf)
1946 {
1947 NDRX_LOG(log_error, "TESTERROR: tpalloc() failed %s",
1948 tpstrerror(tperrno));
1949 EXFAIL_OUT(ret);
1950 }
1951
1952 if (EXSUCCEED != Bchg(buf, T_LONG_FLD, 0, (char *)&i, 0L))
1953 {
1954 NDRX_LOG(log_error, "TESTERROR: failed to set T_LONG_FLD %s",
1955 Bstrerror(Berror));
1956 EXFAIL_OUT(ret);
1957 }
1958
1959
1960 memset(&qc1, 0, sizeof(qc1));
1961
1962
1963 if (0==i%2)
1964 {
1965 if (0==test)
1966 {
1967 qc1.flags|=TPQTIME_REL;
1968 qc1.deq_time = 10+(i%9);
1969 }
1970 else
1971 {
1972 qc1.flags|=TPQTIME_ABS;
1973 qc1.deq_time = time(NULL)+10;
1974 }
1975 }
1976
1977 if (EXSUCCEED!=tpenqueue("MYSPACE", "FUT_FIFO", &qc1, (char *)buf, 0, 0))
1978 {
1979 NDRX_LOG(log_error, "TESTERROR: tpenqueue() failed %s diag: %d:%s",
1980 tpstrerror(tperrno), qc1.diagnostic, qc1.diagmsg);
1981 EXFAIL_OUT(ret);
1982 }
1983 tpfree((char *)buf);
1984 }
1985
1986 NDRX_LOG(log_debug, "dequeue normal msg!");
1987
1988 for (i=0; i<max_msgs; i++)
1989 {
1990
1991 if (0==i%2)
1992 {
1993 continue;
1994 }
1995
1996 UBFH *buf2 = (UBFH *)tpalloc("UBF", "", 1024);
1997 memset(&qc1, 0, sizeof(qc1));
1998
1999 if (EXSUCCEED!=tpdequeue("MYSPACE", "FUT_FIFO", &qc1, (char **)&buf2, &len, 0))
2000 {
2001 NDRX_LOG(log_error, "TESTERROR: tpdequeue() failed %s diag: %d:%s",
2002 tpstrerror(tperrno), qc1.diagnostic, qc1.diagmsg);
2003 EXFAIL_OUT(ret);
2004 }
2005
2006 ndrx_debug_dump_UBF(log_debug, "normal msg buf", buf2);
2007
2008
2009 if (EXSUCCEED!=Bget(buf2, T_LONG_FLD, 0, (char *)&l, 0L))
2010 {
2011 NDRX_LOG(log_error, "TESTERROR: failed to get T_LONG_FLD %s",
2012 Bstrerror(Berror));
2013 EXFAIL_OUT(ret);
2014 }
2015 if (l != i )
2016 {
2017 NDRX_LOG(log_error, "TESTERROR: Invalid value [%d] exp [%d]", l, i);
2018 EXFAIL_OUT(ret);
2019 }
2020
2021 tpfree((char *)buf2);
2022 }
2023
2024 UBFH *buf = (UBFH *)tpalloc("UBF", "", 1024);
2025 if (NULL==buf)
2026 {
2027 NDRX_LOG(log_error, "TESTERROR: tpalloc() failed %s",
2028 tpstrerror(tperrno));
2029 EXFAIL_OUT(ret);
2030 }
2031
2032 memset(&qc1, 0, sizeof(qc1));
2033 if (EXSUCCEED==tpdequeue("MYSPACE", "FUT_LIFO", &qc1, (char **)&buf, &len, 0))
2034 {
2035 NDRX_LOG(log_error, "TESTERROR: tpdequeue() must fail but succeed!");
2036 EXFAIL_OUT(ret);
2037 }
2038
2039 NDRX_ASSERT_VAL_OUT(TPEDIAGNOSTIC==tperrno && QMENOMSG==qc1.diagnostic,
2040 "Expected QMENOMSG got %d %ld", tperrno, qc1.diagnostic);
2041
2042
2043 sleep(40);
2044 NDRX_LOG(log_debug, "dequeue future msg!");
2045
2046
2047 for (i=0; i<max_msgs; i++)
2048 {
2049
2050 if (0!=i%2)
2051 {
2052 continue;
2053 }
2054
2055 UBFH *buf3 = (UBFH *)tpalloc("UBF", "", 1024);
2056 memset(&qc1, 0, sizeof(qc1));
2057
2058 if (EXSUCCEED!=tpdequeue("MYSPACE", "FUT_FIFO", &qc1, (char **)&buf3, &len, 0))
2059 {
2060 NDRX_LOG(log_error, "TESTERROR: tpdequeue() failed %s diag: %d:%s",
2061 tpstrerror(tperrno), qc1.diagnostic, qc1.diagmsg);
2062 EXFAIL_OUT(ret);
2063 }
2064
2065 ndrx_debug_dump_UBF(log_debug, "fut Q msg buf", buf3);
2066
2067
2068 if (EXSUCCEED!=Bget(buf3, T_LONG_FLD, 0, (char *)&l, 0L))
2069 {
2070 NDRX_LOG(log_error, "TESTERROR: failed to get T_LONG_FLD %s",
2071 Bstrerror(Berror));
2072 EXFAIL_OUT(ret);
2073 }
2074 if (l != i )
2075 {
2076 NDRX_LOG(log_error, "TESTERROR: Invalid value [%d] exp [%d]", l, i);
2077 EXFAIL_OUT(ret);
2078 }
2079
2080 tpfree((char *)buf3);
2081 }
2082 }
2083
2084
2085 out:
2086 return ret;
2087 }
2088
2089
2090
2091
2092
2093
2094
2095
2096 exprivate int basic_q_fut_lifo_test(void)
2097 {
2098 int ret = EXSUCCEED;
2099 TPQCTL qc1;
2100 long len=0;
2101 int test;
2102 long i, l;
2103 long max_msgs = 200;
2104
2105 for (test = 0; test < 2; test++)
2106 {
2107 for (i=0; i<max_msgs; i++)
2108 {
2109 UBFH *buf = (UBFH *)tpalloc("UBF", "", 1024);
2110 if (NULL==buf)
2111 {
2112 NDRX_LOG(log_error, "TESTERROR: tpalloc() failed %s",
2113 tpstrerror(tperrno));
2114 EXFAIL_OUT(ret);
2115 }
2116
2117 if (EXSUCCEED != Bchg(buf, T_LONG_FLD, 0, (char *)&i, 0L))
2118 {
2119 NDRX_LOG(log_error, "TESTERROR: failed to set T_LONG_FLD %s",
2120 Bstrerror(Berror));
2121 EXFAIL_OUT(ret);
2122 }
2123
2124
2125 memset(&qc1, 0, sizeof(qc1));
2126
2127
2128 if (0==i%2)
2129 {
2130 if (0==test)
2131 {
2132 qc1.flags|=TPQTIME_REL;
2133 qc1.deq_time = 10+(i%9);
2134 }
2135 else
2136 {
2137 qc1.flags|=TPQTIME_ABS;
2138 qc1.deq_time = time(NULL)+10;
2139 }
2140 }
2141
2142 if (EXSUCCEED!=tpenqueue("MYSPACE", "FUT_LIFO", &qc1, (char *)buf, 0, 0))
2143 {
2144 NDRX_LOG(log_error, "TESTERROR: tpenqueue() failed %s diag: %d:%s",
2145 tpstrerror(tperrno), qc1.diagnostic, qc1.diagmsg);
2146 EXFAIL_OUT(ret);
2147 }
2148 tpfree((char *)buf);
2149 }
2150
2151 NDRX_LOG(log_debug, "dequeue normal msg from LIFO!");
2152
2153 for (i=max_msgs-1; i>=0; i--)
2154 {
2155
2156 if (0==i%2)
2157 {
2158 continue;
2159 }
2160
2161 UBFH *buf2 = (UBFH *)tpalloc("UBF", "", 1024);
2162 memset(&qc1, 0, sizeof(qc1));
2163
2164 if (EXSUCCEED!=tpdequeue("MYSPACE", "FUT_LIFO", &qc1, (char **)&buf2, &len, 0))
2165 {
2166 NDRX_LOG(log_error, "TESTERROR: tpdequeue() failed %s diag: %d:%s",
2167 tpstrerror(tperrno), qc1.diagnostic, qc1.diagmsg);
2168 EXFAIL_OUT(ret);
2169 }
2170
2171 ndrx_debug_dump_UBF(log_debug, "normal msg buf", buf2);
2172
2173
2174 if (EXSUCCEED!=Bget(buf2, T_LONG_FLD, 0, (char *)&l, 0L))
2175 {
2176 NDRX_LOG(log_error, "TESTERROR: failed to get T_LONG_FLD %s",
2177 Bstrerror(Berror));
2178 EXFAIL_OUT(ret);
2179 }
2180 if (l != i )
2181 {
2182 NDRX_LOG(log_error, "TESTERROR: Invalid value [%d] exp [%d]", l, i);
2183 EXFAIL_OUT(ret);
2184 }
2185
2186 tpfree((char *)buf2);
2187 }
2188
2189 UBFH *buf = (UBFH *)tpalloc("UBF", "", 1024);
2190 if (NULL==buf)
2191 {
2192 NDRX_LOG(log_error, "TESTERROR: tpalloc() failed %s",
2193 tpstrerror(tperrno));
2194 EXFAIL_OUT(ret);
2195 }
2196
2197 memset(&qc1, 0, sizeof(qc1));
2198 if (EXSUCCEED==tpdequeue("MYSPACE", "FUT_LIFO", &qc1, (char **)&buf, &len, 0))
2199 {
2200 NDRX_LOG(log_error, "TESTERROR: tpdequeue() must fail but succeed!");
2201 EXFAIL_OUT(ret);
2202 }
2203
2204 NDRX_ASSERT_VAL_OUT(TPEDIAGNOSTIC==tperrno && QMENOMSG==qc1.diagnostic,
2205 "Expected QMENOMSG got %d %ld", tperrno, qc1.diagnostic);
2206
2207 sleep(40);
2208 NDRX_LOG(log_debug, "dequeue future msg from LIFO !");
2209
2210
2211 for (i=max_msgs-1; i>=0; i--)
2212 {
2213
2214 if (0!=i%2)
2215 {
2216 continue;
2217 }
2218
2219 UBFH *buf3 = (UBFH *)tpalloc("UBF", "", 1024);
2220 memset(&qc1, 0, sizeof(qc1));
2221
2222 if (EXSUCCEED!=tpdequeue("MYSPACE", "FUT_LIFO", &qc1, (char **)&buf3, &len, 0))
2223 {
2224 NDRX_LOG(log_error, "TESTERROR: tpdequeue() failed %s diag: %d:%s",
2225 tpstrerror(tperrno), qc1.diagnostic, qc1.diagmsg);
2226 EXFAIL_OUT(ret);
2227 }
2228
2229 ndrx_debug_dump_UBF(log_debug, "fut Q msg buf", buf3);
2230
2231
2232 if (EXSUCCEED!=Bget(buf3, T_LONG_FLD, 0, (char *)&l, 0L))
2233 {
2234 NDRX_LOG(log_error, "TESTERROR: failed to get T_LONG_FLD %s",
2235 Bstrerror(Berror));
2236 EXFAIL_OUT(ret);
2237 }
2238 if (l != i )
2239 {
2240 NDRX_LOG(log_error, "TESTERROR: Invalid value [%d] exp [%d]", l, i);
2241 EXFAIL_OUT(ret);
2242 }
2243
2244 tpfree((char *)buf3);
2245 }
2246 }
2247
2248
2249 out:
2250 return ret;
2251 }
2252
2253
2254
2255
2256 #define TEST_FUT_FIFO 0
2257 #define TEST_FUT_LIFO 1
2258
2259
2260 volatile int M_fut_test_mode=0;
2261
2262
2263 volatile int M_fut_test_counter=0;
2264
2265
2266 volatile int M_fut_nr_proc=0;
2267
2268 #define TEST_FUT_STAGE_CUR 0
2269 #define TEST_FUT_STAGE_FUT 1
2270 #define TEST_FUT_MAX 200
2271
2272 volatile int M_fut_test_stage;
2273
2274
2275
2276
2277 void notification_callback (char *data, long len, long flags)
2278 {
2279 UBFH *buf = (UBFH *)data;
2280 long l;
2281 char qname[64];
2282
2283
2284
2285 if (EXSUCCEED!=Bget(buf, T_LONG_FLD, 0, (char *)&l, 0L))
2286 {
2287 NDRX_LOG(log_error, "TESTERROR: failed to get T_LONG_FLD %s",
2288 Bstrerror(Berror));
2289 }
2290
2291 if (EXSUCCEED!=Bget(buf, T_STRING_FLD, 0, qname, 0L))
2292 {
2293 NDRX_LOG(log_error, "TESTERROR: failed to get T_STRING_FLD %s",
2294 Bstrerror(Berror));
2295 }
2296
2297
2298 if (TEST_FUT_FIFO==M_fut_test_mode)
2299 {
2300
2301 M_fut_test_counter+=2;
2302 if (TEST_FUT_STAGE_CUR==M_fut_test_stage)
2303 {
2304
2305 if (l%2!=1)
2306 {
2307 NDRX_LOG(log_error, "TESTERROR: FIFO/CUR Expected odd counter "
2308 "rcved [%d] (M_fut_nr_proc=%d qname=%s)", l, M_fut_nr_proc, qname);
2309 }
2310
2311
2312 if (l!=M_fut_test_counter)
2313 {
2314 NDRX_LOG(log_error, "TESTERROR: FIFO/CUR Expected counter [%d] got [%d] "
2315 "(M_fut_nr_proc=%d qname=%s)",
2316 M_fut_test_counter, l, M_fut_nr_proc, qname);
2317 }
2318
2319
2320 M_fut_nr_proc++;
2321
2322 NDRX_LOG(log_error, "FIFO/CUR M_fut_nr_proc=%d l=%ld qname=%s",
2323 M_fut_nr_proc, l, qname);
2324 }
2325 else
2326 {
2327
2328 if (l%2!=0)
2329 {
2330 NDRX_LOG(log_error, "TESTERROR: FIFO/FUT Expected rcvd "
2331 "cntr [%d] to be even, but got odd "
2332 "(M_fut_nr_proc=%d qname=%s)", l, M_fut_nr_proc, qname);
2333 }
2334
2335
2336 if (l!=M_fut_test_counter)
2337 {
2338 NDRX_LOG(log_error, "TESTERROR: FIFO/FUT Expected counter [%d] got [%d] "
2339 "(M_fut_nr_proc=%d qname=%s)",
2340 M_fut_test_counter+2, l, M_fut_nr_proc, qname);
2341 }
2342
2343
2344 M_fut_nr_proc++;
2345
2346 NDRX_LOG(log_error, "FIFO/FUT M_fut_nr_proc=%d l=%ld qname=%s",
2347 M_fut_nr_proc, l, qname);
2348 }
2349 }
2350 else if (TEST_FUT_LIFO==M_fut_test_mode)
2351 {
2352
2353 M_fut_test_counter-=2;
2354 if (TEST_FUT_STAGE_CUR==M_fut_test_stage)
2355 {
2356
2357 if (l%2!=1)
2358 {
2359 NDRX_LOG(log_error, "TESTERROR: LIFO/CUR Expected odd counter "
2360 "rcved [%d] (M_fut_nr_proc=%d qname=%s)", l, M_fut_nr_proc, qname);
2361 }
2362
2363
2364 if (l!=M_fut_test_counter)
2365 {
2366 NDRX_LOG(log_error, "TESTERROR: LIFO/CUR Expected counter [%d] got [%d] "
2367 "(M_fut_nr_proc=%d qname=%s)",
2368 M_fut_test_counter, l, M_fut_nr_proc, qname);
2369 }
2370
2371
2372 M_fut_nr_proc++;
2373
2374 NDRX_LOG(log_error, "LIFO/CUR M_fut_nr_proc=%d l=%ld qname=%s",
2375 M_fut_nr_proc, l, qname);
2376 }
2377 else
2378 {
2379
2380 if (l%2!=0)
2381 {
2382 NDRX_LOG(log_error, "TESTERROR: LIFO/FUT Expected rcvd "
2383 "cntr [%d] to be even, but got odd "
2384 "(M_fut_nr_proc=%d qname=5s)", l, M_fut_nr_proc, qname);
2385 }
2386
2387
2388 if (l!=M_fut_test_counter)
2389 {
2390 NDRX_LOG(log_error, "TESTERROR: LIFO/FUT Expected counter [%d] got [%d] "
2391 "(M_fut_nr_proc=%d qname=%s)",
2392 M_fut_test_counter+2, l, M_fut_nr_proc, qname);
2393 }
2394
2395
2396 M_fut_nr_proc++;
2397 NDRX_LOG(log_error, "LIFO/CUR M_fut_nr_proc=%d l=%ld qname=%s",
2398 M_fut_nr_proc, l, qname);
2399 }
2400 }
2401 }
2402
2403
2404
2405
2406 exprivate int basic_q_fut_fifo_lifo_auto_test(void)
2407 {
2408 int ret = EXSUCCEED;
2409 TPQCTL qc1;
2410 long len=0;
2411 long i, l, q;
2412 long max_msgs = TEST_FUT_MAX;
2413 char *qnames[] = {"FUT_FIFO_AUTO", "FUT_LIFO_AUTO"};
2414 UBFH *buf = (UBFH *)tpalloc("UBF", "", 1024);
2415 ndrx_stopwatch_t w;
2416 time_t tt;
2417
2418 tpsetunsol(notification_callback);
2419
2420 for (q=0;q<2; q++)
2421 {
2422
2423
2424
2425 tt=time(NULL);
2426
2427 M_fut_test_mode=q;
2428 M_fut_nr_proc=0;
2429 M_fut_test_stage=TEST_FUT_STAGE_CUR;
2430
2431
2432
2433
2434 if (TEST_FUT_FIFO==q)
2435 {
2436 M_fut_test_counter=-1;
2437 }
2438 else
2439 {
2440 M_fut_test_counter=(TEST_FUT_MAX+1);
2441 }
2442
2443 for (i=0; i<max_msgs; i++)
2444 {
2445
2446
2447
2448
2449 if (TEST_FUT_LIFO==q && 1==i%2)
2450 {
2451 continue;
2452 }
2453
2454 if (EXSUCCEED != Bchg(buf, T_LONG_FLD, 0, (char *)&i, 0L))
2455 {
2456 NDRX_LOG(log_error, "TESTERROR: failed to set T_LONG_FLD %s",
2457 Bstrerror(Berror));
2458 EXFAIL_OUT(ret);
2459 }
2460
2461 if (EXSUCCEED != Bchg(buf, T_STRING_FLD, 0, qnames[q], 0L))
2462 {
2463 NDRX_LOG(log_error, "TESTERROR: failed to set T_STRING_FLD %s",
2464 Bstrerror(Berror));
2465 EXFAIL_OUT(ret);
2466 }
2467
2468
2469 memset(&qc1, 0, sizeof(qc1));
2470
2471
2472 if (0==i%2)
2473 {
2474 qc1.flags|=TPQTIME_ABS;
2475
2476 if (TEST_FUT_FIFO==q)
2477 {
2478 if (i>=TEST_FUT_MAX/2)
2479 {
2480
2481 qc1.deq_time = tt+20;
2482 }
2483 else
2484 {
2485
2486 qc1.deq_time = tt+35;
2487 }
2488 }
2489 else if (TEST_FUT_LIFO==q)
2490 {
2491
2492
2493 if (i>=TEST_FUT_MAX/2)
2494 {
2495
2496 qc1.deq_time = tt+35;
2497 }
2498 else
2499 {
2500
2501 qc1.deq_time = tt+20;
2502 }
2503 }
2504 }
2505
2506
2507 if (EXSUCCEED!=tpenqueue("MYSPACE", qnames[q], &qc1, (char *)buf, 0, 0))
2508 {
2509 NDRX_LOG(log_error, "TESTERROR: tpenqueue() failed %s diag: %d:%s",
2510 tpstrerror(tperrno), qc1.diagnostic, qc1.diagmsg);
2511 EXFAIL_OUT(ret);
2512 }
2513 }
2514
2515
2516 if (TEST_FUT_FIFO==q)
2517 {
2518 ndrx_stopwatch_reset(&w);
2519 do
2520 {
2521
2522 while (tpchkunsol()>0){}
2523 sleep(1);
2524 } while (ndrx_stopwatch_get_delta_sec(&w) <=10);
2525
2526 if (M_fut_nr_proc!=TEST_FUT_MAX/2)
2527 {
2528 NDRX_LOG(log_error, "TESTERROR: Expected %d messages, got %d, qname=[%s] (NORMAL)",
2529 TEST_FUT_MAX/2, M_fut_nr_proc, qnames[q]);
2530 EXFAIL_OUT(ret);
2531 }
2532
2533 NDRX_LOG(log_error, "Expected %d messages, got %d, qname=[%s] (NORMAL) - OK",
2534 TEST_FUT_MAX/2, M_fut_nr_proc, qnames[q]);
2535 }
2536 else
2537 {
2538 sleep(10);
2539 }
2540
2541
2542
2543
2544
2545
2546 M_fut_nr_proc=0;
2547 M_fut_test_stage=TEST_FUT_STAGE_FUT;
2548
2549 if (TEST_FUT_FIFO==q)
2550 {
2551
2552
2553 M_fut_test_counter=98;
2554 }
2555 else
2556 {
2557
2558 M_fut_test_counter=(TEST_FUT_MAX)/2;
2559 }
2560
2561
2562
2563
2564 ndrx_stopwatch_reset(&w);
2565 do
2566 {
2567
2568 while (tpchkunsol()>0){}
2569 sleep(1);
2570 } while (ndrx_stopwatch_get_delta_sec(&w) <=15);
2571
2572 if (M_fut_nr_proc!=TEST_FUT_MAX/2/2)
2573 {
2574 NDRX_LOG(log_error, "TESTERROR: Expected %d messages, got %d qname=[%s] (FUT, 1st part)",
2575 TEST_FUT_MAX/2, M_fut_nr_proc, qnames[q]);
2576 EXFAIL_OUT(ret);
2577 }
2578 NDRX_LOG(log_error, "Expected %d messages, got %d, qname=[%s] (FUT, 1st part) - OK",
2579 TEST_FUT_MAX/2/2, M_fut_nr_proc, qnames[q]);
2580
2581
2582
2583
2584 M_fut_nr_proc=0;
2585 M_fut_test_stage=TEST_FUT_STAGE_FUT;
2586
2587 if (TEST_FUT_FIFO==q)
2588 {
2589
2590
2591 M_fut_test_counter=-2;
2592 }
2593 else
2594 {
2595 M_fut_test_counter=(TEST_FUT_MAX);
2596 }
2597
2598
2599
2600
2601 ndrx_stopwatch_reset(&w);
2602 do
2603 {
2604
2605 while (tpchkunsol()>0){}
2606 sleep(1);
2607 } while (ndrx_stopwatch_get_delta_sec(&w) <=25);
2608
2609 if (M_fut_nr_proc!=TEST_FUT_MAX/2/2)
2610 {
2611 NDRX_LOG(log_error, "TESTERROR: Expected %d messages, got %d qname=[%s] (FUT, 2nd part)",
2612 TEST_FUT_MAX/2, M_fut_nr_proc, qnames[q]);
2613 EXFAIL_OUT(ret);
2614 }
2615 NDRX_LOG(log_error, "Expected %d messages, got %d, qname=[%s] (FUT, 2nd part) - OK",
2616 TEST_FUT_MAX/2/2, M_fut_nr_proc, qnames[q]);
2617
2618 }
2619 out:
2620 return ret;
2621 }
2622
2623
2624
2625
2626 exprivate int basic_q_fut_corfifo_test(void)
2627 {
2628 int ret = EXSUCCEED;
2629 TPQCTL qc1;
2630 long len=0;
2631 long i, l;
2632 char cor_buf[64];
2633
2634 for (i=0; i<400; i++)
2635 {
2636 UBFH *buf = (UBFH *)tpalloc("UBF", "", 1024);
2637 if (NULL==buf)
2638 {
2639 NDRX_LOG(log_error, "TESTERROR: tpalloc() failed %s",
2640 tpstrerror(tperrno));
2641 EXFAIL_OUT(ret);
2642 }
2643
2644 if (EXSUCCEED != Bchg(buf, T_LONG_FLD, 0, (char *)&i, 0L))
2645 {
2646 NDRX_LOG(log_error, "TESTERROR: failed to set T_LONG_FLD %s",
2647 Bstrerror(Berror));
2648 EXFAIL_OUT(ret);
2649 }
2650
2651
2652 memset(&qc1, 0, sizeof(qc1));
2653
2654 if (i>=100 && i<200)
2655 {
2656 qc1.flags|=TPQCORRID;
2657 qc1.corrid[0]=1;
2658 if (EXSUCCEED != Bchg(buf, T_STRING_FLD, 0, "CORRID=1", 0L))
2659 {
2660 NDRX_LOG(log_error, "TESTERROR: failed to set T_STRING_FLD %s",
2661 Bstrerror(Berror));
2662 EXFAIL_OUT(ret);
2663 }
2664 }
2665 else if (i>=200 && i<300)
2666 {
2667 qc1.flags|=TPQCORRID;
2668 qc1.corrid[0]=2;
2669 if (EXSUCCEED != Bchg(buf, T_STRING_FLD, 0, "CORRID=2", 0L))
2670 {
2671 NDRX_LOG(log_error, "TESTERROR: failed to set T_STRING_FLD %s",
2672 Bstrerror(Berror));
2673 EXFAIL_OUT(ret);
2674 }
2675 }
2676
2677
2678 if (0==i%2)
2679 {
2680 qc1.flags|=TPQTIME_REL;
2681 qc1.deq_time = 15+(i%9);
2682 }
2683
2684 if (EXSUCCEED!=tpenqueue("MYSPACE", "FUT_CORFIFO", &qc1, (char *)buf, 0, 0))
2685 {
2686 NDRX_LOG(log_error, "TESTERROR: tpenqueue() failed %s diag: %d:%s",
2687 tpstrerror(tperrno), qc1.diagnostic, qc1.diagmsg);
2688 EXFAIL_OUT(ret);
2689 }
2690 tpfree((char *)buf);
2691 }
2692
2693
2694 UBFH *buf = (UBFH *)tpalloc("UBF", "", 1024);
2695 if (NULL==buf)
2696 {
2697 NDRX_LOG(log_error, "TESTERROR: tpalloc() failed %s",
2698 tpstrerror(tperrno));
2699 EXFAIL_OUT(ret);
2700 }
2701 memset(&qc1, 0, sizeof(qc1));
2702 qc1.flags|=TPQGETBYCORRID;
2703 qc1.corrid[0]=5;
2704 if (EXSUCCEED==tpdequeue("MYSPACE", "FUT_CORFIFO", &qc1, (char **)&buf, &len, 0))
2705 {
2706 NDRX_LOG(log_error, "TESTERROR: tpdequeue() must fail but succeed!");
2707 EXFAIL_OUT(ret);
2708 }
2709
2710 NDRX_ASSERT_VAL_OUT(TPEDIAGNOSTIC==tperrno && QMENOMSG==qc1.diagnostic,
2711 "Expected QMENOMSG got %d %ld (%s)", tperrno, qc1.diagnostic, tpstrerror(tperrno));
2712
2713 tpfree((char *)buf);
2714
2715 NDRX_LOG(log_debug, "dequeue first 100 w/o corid from normal Q");
2716
2717 for (i=0; i<100; i++)
2718 {
2719
2720 if (0==i%2)
2721 {
2722 continue;
2723 }
2724
2725 UBFH *buf2 = (UBFH *)tpalloc("UBF", "", 1024);
2726 memset(&qc1, 0, sizeof(qc1));
2727
2728 if (EXSUCCEED!=tpdequeue("MYSPACE", "FUT_CORFIFO", &qc1, (char **)&buf2, &len, 0))
2729 {
2730 NDRX_LOG(log_error, "TESTERROR: tpdequeue() failed %s diag: %d:%s",
2731 tpstrerror(tperrno), qc1.diagnostic, qc1.diagmsg);
2732 EXFAIL_OUT(ret);
2733 }
2734
2735 ndrx_debug_dump_UBF(log_debug, "msg buf", buf2);
2736
2737
2738 if (EXSUCCEED!=Bget(buf2, T_LONG_FLD, 0, (char *)&l, 0L))
2739 {
2740 NDRX_LOG(log_error, "TESTERROR: failed to get T_LONG_FLD %s",
2741 Bstrerror(Berror));
2742 EXFAIL_OUT(ret);
2743 }
2744 if (l != i )
2745 {
2746 NDRX_LOG(log_error, "TESTERROR: Invalid value [%d] exp [%d]", l, i);
2747 EXFAIL_OUT(ret);
2748 }
2749
2750 tpfree((char *)buf2);
2751 }
2752
2753 NDRX_LOG(log_debug, "dequeue next 100 with corid=2 from normal Q");
2754 for (i=200; i<300; i++)
2755 {
2756
2757 if (0==i%2)
2758 {
2759 continue;
2760 }
2761
2762 UBFH *buf3 = (UBFH *)tpalloc("UBF", "", 1024);
2763 memset(&qc1, 0, sizeof(qc1));
2764
2765 qc1.flags|=TPQGETBYCORRID;
2766 qc1.corrid[0]=2;
2767
2768 if (EXSUCCEED!=tpdequeue("MYSPACE", "FUT_CORFIFO", &qc1, (char **)&buf3, &len, 0))
2769 {
2770 NDRX_LOG(log_error, "TESTERROR: tpdequeue() failed %s diag: %d:%s",
2771 tpstrerror(tperrno), qc1.diagnostic, qc1.diagmsg);
2772 EXFAIL_OUT(ret);
2773 }
2774
2775 ndrx_debug_dump_UBF(log_debug, "msg buf", buf3);
2776
2777
2778 if (EXSUCCEED!=Bget(buf3, T_STRING_FLD, 0, cor_buf, 0L))
2779 {
2780 NDRX_LOG(log_error, "TESTERROR: failed to get T_STRING_FLD %s",
2781 Bstrerror(Berror));
2782 EXFAIL_OUT(ret);
2783 }
2784
2785 if (0!=strcmp("CORRID=2", cor_buf) )
2786 {
2787 NDRX_LOG(log_error, "TESTERROR: Invalid value [%s] exp [%s]", cor_buf, "CORRID=2");
2788 EXFAIL_OUT(ret);
2789 }
2790
2791
2792 if (EXSUCCEED!=Bget(buf3, T_LONG_FLD, 0, (char *)&l, 0L))
2793 {
2794 NDRX_LOG(log_error, "TESTERROR: failed to get T_LONG_FLD %s",
2795 Bstrerror(Berror));
2796 EXFAIL_OUT(ret);
2797 }
2798 if (l != i )
2799 {
2800 NDRX_LOG(log_error, "TESTERROR: Invalid value [%d] exp [%d]", l, i);
2801 EXFAIL_OUT(ret);
2802 }
2803
2804 tpfree((char *)buf3);
2805 }
2806
2807 NDRX_LOG(log_debug, "dequeue next 100 with corid=1 from normal Q");
2808 for (i=100; i<200; i++)
2809 {
2810
2811 if (0==i%2)
2812 {
2813 continue;
2814 }
2815
2816 UBFH *buf4 = (UBFH *)tpalloc("UBF", "", 1024);
2817 memset(&qc1, 0, sizeof(qc1));
2818
2819 qc1.flags|=TPQGETBYCORRID;
2820 qc1.corrid[0]=1;
2821
2822 if (EXSUCCEED!=tpdequeue("MYSPACE", "FUT_CORFIFO", &qc1, (char **)&buf4, &len, 0))
2823 {
2824 NDRX_LOG(log_error, "TESTERROR: tpdequeue() failed %s diag: %d:%s",
2825 tpstrerror(tperrno), qc1.diagnostic, qc1.diagmsg);
2826 EXFAIL_OUT(ret);
2827 }
2828
2829 ndrx_debug_dump_UBF(log_debug, "msg buf", buf4);
2830
2831
2832 if (EXSUCCEED!=Bget(buf4, T_STRING_FLD, 0, cor_buf, 0L))
2833 {
2834 NDRX_LOG(log_error, "TESTERROR: failed to get T_STRING_FLD %s",
2835 Bstrerror(Berror));
2836 EXFAIL_OUT(ret);
2837 }
2838
2839 if (0!=strcmp("CORRID=1", cor_buf) )
2840 {
2841 NDRX_LOG(log_error, "TESTERROR: Invalid value [%s] exp [%s]", cor_buf, "CORRID=1");
2842 EXFAIL_OUT(ret);
2843 }
2844
2845
2846 if (EXSUCCEED!=Bget(buf4, T_LONG_FLD, 0, (char *)&l, 0L))
2847 {
2848 NDRX_LOG(log_error, "TESTERROR: failed to get T_LONG_FLD %s",
2849 Bstrerror(Berror));
2850 EXFAIL_OUT(ret);
2851 }
2852 if (l != i )
2853 {
2854 NDRX_LOG(log_error, "TESTERROR: Invalid value [%d] exp [%d]", l, i);
2855 EXFAIL_OUT(ret);
2856 }
2857
2858 tpfree((char *)buf4);
2859 }
2860
2861 NDRX_LOG(log_debug, "dequeue last 100 w/o corid from normal Q");
2862
2863 for (i=300; i<400; i++)
2864 {
2865
2866 if (0==i%2)
2867 {
2868 continue;
2869 }
2870
2871 UBFH *buf5 = (UBFH *)tpalloc("UBF", "", 1024);
2872 memset(&qc1, 0, sizeof(qc1));
2873
2874 if (EXSUCCEED!=tpdequeue("MYSPACE", "FUT_CORFIFO", &qc1, (char **)&buf5, &len, 0))
2875 {
2876 NDRX_LOG(log_error, "TESTERROR: tpdequeue() failed %s diag: %d:%s",
2877 tpstrerror(tperrno), qc1.diagnostic, qc1.diagmsg);
2878 EXFAIL_OUT(ret);
2879 }
2880
2881 ndrx_debug_dump_UBF(log_debug, "msg buf", buf5);
2882
2883
2884 if (EXSUCCEED!=Bget(buf5, T_LONG_FLD, 0, (char *)&l, 0L))
2885 {
2886 NDRX_LOG(log_error, "TESTERROR: failed to get T_LONG_FLD %s",
2887 Bstrerror(Berror));
2888 EXFAIL_OUT(ret);
2889 }
2890 if (l != i )
2891 {
2892 NDRX_LOG(log_error, "TESTERROR: Invalid value [%d] exp [%d]", l, i);
2893 EXFAIL_OUT(ret);
2894 }
2895
2896 tpfree((char *)buf5);
2897 }
2898
2899
2900 UBFH *buf6 = (UBFH *)tpalloc("UBF", "", 1024);
2901 if (NULL==buf6)
2902 {
2903 NDRX_LOG(log_error, "TESTERROR: tpalloc() failed %s",
2904 tpstrerror(tperrno));
2905 EXFAIL_OUT(ret);
2906 }
2907
2908 memset(&qc1, 0, sizeof(qc1));
2909 if (EXSUCCEED==tpdequeue("MYSPACE", "FUT_CORFIFO", &qc1, (char **)&buf6, &len, 0))
2910 {
2911 NDRX_LOG(log_error, "TESTERROR: tpdequeue() must fail but succeed!");
2912 EXFAIL_OUT(ret);
2913 }
2914
2915 NDRX_ASSERT_VAL_OUT(TPEDIAGNOSTIC==tperrno && QMENOMSG==qc1.diagnostic,
2916 "Expected QMENOMSG got %d %ld", tperrno, qc1.diagnostic);
2917
2918 tpfree((char *)buf6);
2919
2920 sleep(30);
2921
2922 NDRX_LOG(log_debug, "dequeue first 100 w/o corid from future Q");
2923
2924 for (i=0; i<100; i++)
2925 {
2926
2927 if (0!=i%2)
2928 {
2929 continue;
2930 }
2931
2932 UBFH *buf7 = (UBFH *)tpalloc("UBF", "", 1024);
2933 memset(&qc1, 0, sizeof(qc1));
2934
2935 if (EXSUCCEED!=tpdequeue("MYSPACE", "FUT_CORFIFO", &qc1, (char **)&buf7, &len, 0))
2936 {
2937 NDRX_LOG(log_error, "TESTERROR: tpdequeue() failed %s diag: %d:%s",
2938 tpstrerror(tperrno), qc1.diagnostic, qc1.diagmsg);
2939 EXFAIL_OUT(ret);
2940 }
2941
2942 ndrx_debug_dump_UBF(log_debug, "msg buf", buf7);
2943
2944
2945 if (EXSUCCEED!=Bget(buf7, T_LONG_FLD, 0, (char *)&l, 0L))
2946 {
2947 NDRX_LOG(log_error, "TESTERROR: failed to get T_LONG_FLD %s",
2948 Bstrerror(Berror));
2949 EXFAIL_OUT(ret);
2950 }
2951 if (l != i )
2952 {
2953 NDRX_LOG(log_error, "TESTERROR: Invalid value [%d] exp [%d]", l, i);
2954 EXFAIL_OUT(ret);
2955 }
2956
2957 tpfree((char *)buf7);
2958 }
2959
2960 NDRX_LOG(log_debug, "dequeue next 100 with corid=2 from future Q");
2961 for (i=200; i<300; i++)
2962 {
2963
2964 if (0!=i%2)
2965 {
2966 continue;
2967 }
2968
2969 UBFH *buf8 = (UBFH *)tpalloc("UBF", "", 1024);
2970 memset(&qc1, 0, sizeof(qc1));
2971
2972 qc1.flags|=TPQGETBYCORRID;
2973 qc1.corrid[0]=2;
2974
2975 if (EXSUCCEED!=tpdequeue("MYSPACE", "FUT_CORFIFO", &qc1, (char **)&buf8, &len, 0))
2976 {
2977 NDRX_LOG(log_error, "TESTERROR: tpdequeue() failed %s diag: %d:%s",
2978 tpstrerror(tperrno), qc1.diagnostic, qc1.diagmsg);
2979 EXFAIL_OUT(ret);
2980 }
2981
2982 ndrx_debug_dump_UBF(log_debug, "msg buf", buf8);
2983
2984
2985 if (EXSUCCEED!=Bget(buf8, T_STRING_FLD, 0, cor_buf, 0L))
2986 {
2987 NDRX_LOG(log_error, "TESTERROR: failed to get T_STRING_FLD %s",
2988 Bstrerror(Berror));
2989 EXFAIL_OUT(ret);
2990 }
2991
2992 if (0!=strcmp("CORRID=2", cor_buf) )
2993 {
2994 NDRX_LOG(log_error, "TESTERROR: Invalid value [%s] exp [%s]", cor_buf, "CORRID=2");
2995 EXFAIL_OUT(ret);
2996 }
2997
2998
2999 if (EXSUCCEED!=Bget(buf8, T_LONG_FLD, 0, (char *)&l, 0L))
3000 {
3001 NDRX_LOG(log_error, "TESTERROR: failed to get T_LONG_FLD %s",
3002 Bstrerror(Berror));
3003 EXFAIL_OUT(ret);
3004 }
3005 if (l != i )
3006 {
3007 NDRX_LOG(log_error, "TESTERROR: Invalid value [%d] exp [%d]", l, i);
3008 EXFAIL_OUT(ret);
3009 }
3010
3011 tpfree((char *)buf8);
3012 }
3013
3014 NDRX_LOG(log_debug, "dequeue next 100 with corid=1 from future Q");
3015 for (i=100; i<200; i++)
3016 {
3017
3018 if (0!=i%2)
3019 {
3020 continue;
3021 }
3022
3023 UBFH *buf9 = (UBFH *)tpalloc("UBF", "", 1024);
3024 memset(&qc1, 0, sizeof(qc1));
3025
3026 qc1.flags|=TPQGETBYCORRID;
3027 qc1.corrid[0]=1;
3028
3029 if (EXSUCCEED!=tpdequeue("MYSPACE", "FUT_CORFIFO", &qc1, (char **)&buf9, &len, 0))
3030 {
3031 NDRX_LOG(log_error, "TESTERROR: tpdequeue() failed %s diag: %d:%s",
3032 tpstrerror(tperrno), qc1.diagnostic, qc1.diagmsg);
3033 EXFAIL_OUT(ret);
3034 }
3035
3036 ndrx_debug_dump_UBF(log_debug, "msg buf", buf9);
3037
3038
3039 if (EXSUCCEED!=Bget(buf9, T_STRING_FLD, 0, cor_buf, 0L))
3040 {
3041 NDRX_LOG(log_error, "TESTERROR: failed to get T_STRING_FLD %s",
3042 Bstrerror(Berror));
3043 EXFAIL_OUT(ret);
3044 }
3045
3046 if (0!=strcmp("CORRID=1", cor_buf) )
3047 {
3048 NDRX_LOG(log_error, "TESTERROR: Invalid value [%s] exp [%s]", cor_buf, "CORRID=1");
3049 EXFAIL_OUT(ret);
3050 }
3051
3052
3053 if (EXSUCCEED!=Bget(buf9, T_LONG_FLD, 0, (char *)&l, 0L))
3054 {
3055 NDRX_LOG(log_error, "TESTERROR: failed to get T_LONG_FLD %s",
3056 Bstrerror(Berror));
3057 EXFAIL_OUT(ret);
3058 }
3059 if (l != i )
3060 {
3061 NDRX_LOG(log_error, "TESTERROR: Invalid value [%d] exp [%d]", l, i);
3062 EXFAIL_OUT(ret);
3063 }
3064
3065 tpfree((char *)buf9);
3066 }
3067
3068 NDRX_LOG(log_debug, "dequeue last 100 w/o corid from future Q");
3069
3070 for (i=300; i<400; i++)
3071 {
3072
3073 if (0!=i%2)
3074 {
3075 continue;
3076 }
3077
3078 UBFH *buf10 = (UBFH *)tpalloc("UBF", "", 1024);
3079 memset(&qc1, 0, sizeof(qc1));
3080
3081 if (EXSUCCEED!=tpdequeue("MYSPACE", "FUT_CORFIFO", &qc1, (char **)&buf10, &len, 0))
3082 {
3083 NDRX_LOG(log_error, "TESTERROR: tpdequeue() failed %s diag: %d:%s",
3084 tpstrerror(tperrno), qc1.diagnostic, qc1.diagmsg);
3085 EXFAIL_OUT(ret);
3086 }
3087
3088 ndrx_debug_dump_UBF(log_debug, "msg buf", buf10);
3089
3090
3091 if (EXSUCCEED!=Bget(buf10, T_LONG_FLD, 0, (char *)&l, 0L))
3092 {
3093 NDRX_LOG(log_error, "TESTERROR: failed to get T_LONG_FLD %s",
3094 Bstrerror(Berror));
3095 EXFAIL_OUT(ret);
3096 }
3097 if (l != i )
3098 {
3099 NDRX_LOG(log_error, "TESTERROR: Invalid value [%d] exp [%d]", l, i);
3100 EXFAIL_OUT(ret);
3101 }
3102
3103 tpfree((char *)buf10);
3104 }
3105 out:
3106 return ret;
3107 }
3108
3109
3110
3111
3112 exprivate int basic_q_fut_corlifo_test(void)
3113 {
3114 int ret = EXSUCCEED;
3115 TPQCTL qc1;
3116 long len=0;
3117 long i, l;
3118 char cor_buf[64];
3119
3120 for (i=0; i<400; i++)
3121 {
3122 UBFH *buf = (UBFH *)tpalloc("UBF", "", 1024);
3123 if (NULL==buf)
3124 {
3125 NDRX_LOG(log_error, "TESTERROR: tpalloc() failed %s",
3126 tpstrerror(tperrno));
3127 EXFAIL_OUT(ret);
3128 }
3129
3130 if (EXSUCCEED != Bchg(buf, T_LONG_FLD, 0, (char *)&i, 0L))
3131 {
3132 NDRX_LOG(log_error, "TESTERROR: failed to set T_LONG_FLD %s",
3133 Bstrerror(Berror));
3134 EXFAIL_OUT(ret);
3135 }
3136
3137
3138 memset(&qc1, 0, sizeof(qc1));
3139
3140 if (i>=100 && i<200)
3141 {
3142 qc1.flags|=TPQCORRID;
3143 qc1.corrid[0]=1;
3144 if (EXSUCCEED != Bchg(buf, T_STRING_FLD, 0, "CORRID=1", 0L))
3145 {
3146 NDRX_LOG(log_error, "TESTERROR: failed to set T_STRING_FLD %s",
3147 Bstrerror(Berror));
3148 EXFAIL_OUT(ret);
3149 }
3150 }
3151 else if (i>=200 && i<300)
3152 {
3153 qc1.flags|=TPQCORRID;
3154 qc1.corrid[0]=2;
3155 if (EXSUCCEED != Bchg(buf, T_STRING_FLD, 0, "CORRID=2", 0L))
3156 {
3157 NDRX_LOG(log_error, "TESTERROR: failed to set T_STRING_FLD %s",
3158 Bstrerror(Berror));
3159 EXFAIL_OUT(ret);
3160 }
3161 }
3162
3163
3164 if (0==i%2)
3165 {
3166 qc1.flags|=TPQTIME_REL;
3167 qc1.deq_time = 15+(i%9);
3168 }
3169
3170 if (EXSUCCEED!=tpenqueue("MYSPACE", "FUT_CORLIFO", &qc1, (char *)buf, 0, 0))
3171 {
3172 NDRX_LOG(log_error, "TESTERROR: tpenqueue() failed %s diag: %d:%s",
3173 tpstrerror(tperrno), qc1.diagnostic, qc1.diagmsg);
3174 EXFAIL_OUT(ret);
3175 }
3176 tpfree((char *)buf);
3177 }
3178
3179
3180 UBFH *buf = (UBFH *)tpalloc("UBF", "", 1024);
3181 if (NULL==buf)
3182 {
3183 NDRX_LOG(log_error, "TESTERROR: tpalloc() failed %s",
3184 tpstrerror(tperrno));
3185 EXFAIL_OUT(ret);
3186 }
3187 memset(&qc1, 0, sizeof(qc1));
3188 qc1.flags|=TPQGETBYCORRID;
3189 qc1.corrid[0]=5;
3190 if (EXSUCCEED==tpdequeue("MYSPACE", "FUT_CORLIFO", &qc1, (char **)&buf, &len, 0))
3191 {
3192 NDRX_LOG(log_error, "TESTERROR: tpdequeue() must fail but succeed!");
3193 EXFAIL_OUT(ret);
3194 }
3195
3196 NDRX_ASSERT_VAL_OUT(TPEDIAGNOSTIC==tperrno && QMENOMSG==qc1.diagnostic,
3197 "Expected QMENOMSG got %d %ld (%s)", tperrno, qc1.diagnostic, tpstrerror(tperrno));
3198
3199 tpfree((char *)buf);
3200
3201 NDRX_LOG(log_debug, "dequeue first 100 w/o corid from normal Q");
3202
3203 for (i=399; i>=300; i--)
3204 {
3205
3206 if (0==i%2)
3207 {
3208 continue;
3209 }
3210
3211 UBFH *buf2 = (UBFH *)tpalloc("UBF", "", 1024);
3212 memset(&qc1, 0, sizeof(qc1));
3213
3214 if (EXSUCCEED!=tpdequeue("MYSPACE", "FUT_CORLIFO", &qc1, (char **)&buf2, &len, 0))
3215 {
3216 NDRX_LOG(log_error, "TESTERROR: tpdequeue() failed %s diag: %d:%s",
3217 tpstrerror(tperrno), qc1.diagnostic, qc1.diagmsg);
3218 EXFAIL_OUT(ret);
3219 }
3220
3221 ndrx_debug_dump_UBF(log_debug, "msg buf", buf2);
3222
3223
3224 if (EXSUCCEED!=Bget(buf2, T_LONG_FLD, 0, (char *)&l, 0L))
3225 {
3226 NDRX_LOG(log_error, "TESTERROR: failed to get T_LONG_FLD %s",
3227 Bstrerror(Berror));
3228 EXFAIL_OUT(ret);
3229 }
3230 if (l != i )
3231 {
3232 NDRX_LOG(log_error, "TESTERROR: Invalid value [%d] exp [%d]", l, i);
3233 EXFAIL_OUT(ret);
3234 }
3235
3236 tpfree((char *)buf2);
3237 }
3238
3239 NDRX_LOG(log_debug, "dequeue next 100 with corid=2 from normal Q");
3240 for (i=299; i>=200; i--)
3241 {
3242
3243 if (0==i%2)
3244 {
3245 continue;
3246 }
3247
3248 UBFH *buf3 = (UBFH *)tpalloc("UBF", "", 1024);
3249 memset(&qc1, 0, sizeof(qc1));
3250
3251 qc1.flags|=TPQGETBYCORRID;
3252 qc1.corrid[0]=2;
3253
3254 if (EXSUCCEED!=tpdequeue("MYSPACE", "FUT_CORLIFO", &qc1, (char **)&buf3, &len, 0))
3255 {
3256 NDRX_LOG(log_error, "TESTERROR: tpdequeue() failed %s diag: %d:%s",
3257 tpstrerror(tperrno), qc1.diagnostic, qc1.diagmsg);
3258 EXFAIL_OUT(ret);
3259 }
3260
3261 ndrx_debug_dump_UBF(log_debug, "msg buf", buf3);
3262
3263
3264 if (EXSUCCEED!=Bget(buf3, T_STRING_FLD, 0, cor_buf, 0L))
3265 {
3266 NDRX_LOG(log_error, "TESTERROR: failed to get T_STRING_FLD %s",
3267 Bstrerror(Berror));
3268 EXFAIL_OUT(ret);
3269 }
3270
3271 if (0!=strcmp("CORRID=2", cor_buf) )
3272 {
3273 NDRX_LOG(log_error, "TESTERROR: Invalid value [%s] exp [%s]", cor_buf, "CORRID=2");
3274 EXFAIL_OUT(ret);
3275 }
3276
3277
3278 if (EXSUCCEED!=Bget(buf3, T_LONG_FLD, 0, (char *)&l, 0L))
3279 {
3280 NDRX_LOG(log_error, "TESTERROR: failed to get T_LONG_FLD %s",
3281 Bstrerror(Berror));
3282 EXFAIL_OUT(ret);
3283 }
3284 if (l != i )
3285 {
3286 NDRX_LOG(log_error, "TESTERROR: Invalid value [%d] exp [%d]", l, i);
3287 EXFAIL_OUT(ret);
3288 }
3289
3290 tpfree((char *)buf3);
3291 }
3292
3293 NDRX_LOG(log_debug, "dequeue next 100 with corid=1 from normal Q");
3294 for (i=199; i>=100; i--)
3295 {
3296
3297 if (0==i%2)
3298 {
3299 continue;
3300 }
3301
3302 UBFH *buf4 = (UBFH *)tpalloc("UBF", "", 1024);
3303 memset(&qc1, 0, sizeof(qc1));
3304
3305 qc1.flags|=TPQGETBYCORRID;
3306 qc1.corrid[0]=1;
3307
3308 if (EXSUCCEED!=tpdequeue("MYSPACE", "FUT_CORLIFO", &qc1, (char **)&buf4, &len, 0))
3309 {
3310 NDRX_LOG(log_error, "TESTERROR: tpdequeue() failed %s diag: %d:%s",
3311 tpstrerror(tperrno), qc1.diagnostic, qc1.diagmsg);
3312 EXFAIL_OUT(ret);
3313 }
3314
3315 ndrx_debug_dump_UBF(log_debug, "msg buf", buf4);
3316
3317
3318 if (EXSUCCEED!=Bget(buf4, T_STRING_FLD, 0, cor_buf, 0L))
3319 {
3320 NDRX_LOG(log_error, "TESTERROR: failed to get T_STRING_FLD %s",
3321 Bstrerror(Berror));
3322 EXFAIL_OUT(ret);
3323 }
3324
3325 if (0!=strcmp("CORRID=1", cor_buf) )
3326 {
3327 NDRX_LOG(log_error, "TESTERROR: Invalid value [%s] exp [%s]", cor_buf, "CORRID=1");
3328 EXFAIL_OUT(ret);
3329 }
3330
3331
3332 if (EXSUCCEED!=Bget(buf4, T_LONG_FLD, 0, (char *)&l, 0L))
3333 {
3334 NDRX_LOG(log_error, "TESTERROR: failed to get T_LONG_FLD %s",
3335 Bstrerror(Berror));
3336 EXFAIL_OUT(ret);
3337 }
3338 if (l != i )
3339 {
3340 NDRX_LOG(log_error, "TESTERROR: Invalid value [%d] exp [%d]", l, i);
3341 EXFAIL_OUT(ret);
3342 }
3343
3344 tpfree((char *)buf4);
3345 }
3346
3347 NDRX_LOG(log_debug, "dequeue last 100 w/o corid from normal Q");
3348
3349 for (i=99; i>=0; i--)
3350 {
3351
3352 if (0==i%2)
3353 {
3354 continue;
3355 }
3356
3357 UBFH *buf5 = (UBFH *)tpalloc("UBF", "", 1024);
3358 memset(&qc1, 0, sizeof(qc1));
3359
3360 if (EXSUCCEED!=tpdequeue("MYSPACE", "FUT_CORLIFO", &qc1, (char **)&buf5, &len, 0))
3361 {
3362 NDRX_LOG(log_error, "TESTERROR: tpdequeue() failed %s diag: %d:%s",
3363 tpstrerror(tperrno), qc1.diagnostic, qc1.diagmsg);
3364 EXFAIL_OUT(ret);
3365 }
3366
3367 ndrx_debug_dump_UBF(log_debug, "msg buf", buf5);
3368
3369
3370 if (EXSUCCEED!=Bget(buf5, T_LONG_FLD, 0, (char *)&l, 0L))
3371 {
3372 NDRX_LOG(log_error, "TESTERROR: failed to get T_LONG_FLD %s",
3373 Bstrerror(Berror));
3374 EXFAIL_OUT(ret);
3375 }
3376 if (l != i )
3377 {
3378 NDRX_LOG(log_error, "TESTERROR: Invalid value [%d] exp [%d]", l, i);
3379 EXFAIL_OUT(ret);
3380 }
3381
3382 tpfree((char *)buf5);
3383 }
3384
3385
3386 UBFH *buf6 = (UBFH *)tpalloc("UBF", "", 1024);
3387 if (NULL==buf6)
3388 {
3389 NDRX_LOG(log_error, "TESTERROR: tpalloc() failed %s",
3390 tpstrerror(tperrno));
3391 EXFAIL_OUT(ret);
3392 }
3393
3394 memset(&qc1, 0, sizeof(qc1));
3395 if (EXSUCCEED==tpdequeue("MYSPACE", "FUT_CORLIFO", &qc1, (char **)&buf6, &len, 0))
3396 {
3397 NDRX_LOG(log_error, "TESTERROR: tpdequeue() must fail but succeed!");
3398 EXFAIL_OUT(ret);
3399 }
3400
3401 NDRX_ASSERT_VAL_OUT(TPEDIAGNOSTIC==tperrno && QMENOMSG==qc1.diagnostic,
3402 "Expected QMENOMSG got %d %ld", tperrno, qc1.diagnostic);
3403
3404 tpfree((char *)buf6);
3405
3406 sleep(30);
3407
3408 NDRX_LOG(log_debug, "dequeue last 100 w/o corid from future Q");
3409
3410 for (i=399; i>=300; i--)
3411 {
3412
3413 if (0!=i%2)
3414 {
3415 continue;
3416 }
3417
3418 UBFH *buf7 = (UBFH *)tpalloc("UBF", "", 1024);
3419 memset(&qc1, 0, sizeof(qc1));
3420
3421 if (EXSUCCEED!=tpdequeue("MYSPACE", "FUT_CORLIFO", &qc1, (char **)&buf7, &len, 0))
3422 {
3423 NDRX_LOG(log_error, "TESTERROR: tpdequeue() failed %s diag: %d:%s",
3424 tpstrerror(tperrno), qc1.diagnostic, qc1.diagmsg);
3425 EXFAIL_OUT(ret);
3426 }
3427
3428 ndrx_debug_dump_UBF(log_debug, "msg buf", buf7);
3429
3430
3431 if (EXSUCCEED!=Bget(buf7, T_LONG_FLD, 0, (char *)&l, 0L))
3432 {
3433 NDRX_LOG(log_error, "TESTERROR: failed to get T_LONG_FLD %s",
3434 Bstrerror(Berror));
3435 EXFAIL_OUT(ret);
3436 }
3437 if (l != i )
3438 {
3439 NDRX_LOG(log_error, "TESTERROR: Invalid value [%d] exp [%d]", l, i);
3440 EXFAIL_OUT(ret);
3441 }
3442
3443 tpfree((char *)buf7);
3444 }
3445
3446 NDRX_LOG(log_debug, "dequeue next 100 with corid=2 from future Q");
3447 for (i=299; i>=200; i--)
3448 {
3449
3450 if (0!=i%2)
3451 {
3452 continue;
3453 }
3454
3455 UBFH *buf8 = (UBFH *)tpalloc("UBF", "", 1024);
3456 memset(&qc1, 0, sizeof(qc1));
3457
3458 qc1.flags|=TPQGETBYCORRID;
3459 qc1.corrid[0]=2;
3460
3461 if (EXSUCCEED!=tpdequeue("MYSPACE", "FUT_CORLIFO", &qc1, (char **)&buf8, &len, 0))
3462 {
3463 NDRX_LOG(log_error, "TESTERROR: tpdequeue() failed %s diag: %d:%s",
3464 tpstrerror(tperrno), qc1.diagnostic, qc1.diagmsg);
3465 EXFAIL_OUT(ret);
3466 }
3467
3468 ndrx_debug_dump_UBF(log_debug, "msg buf", buf8);
3469
3470
3471 if (EXSUCCEED!=Bget(buf8, T_STRING_FLD, 0, cor_buf, 0L))
3472 {
3473 NDRX_LOG(log_error, "TESTERROR: failed to get T_STRING_FLD %s",
3474 Bstrerror(Berror));
3475 EXFAIL_OUT(ret);
3476 }
3477
3478 if (0!=strcmp("CORRID=2", cor_buf) )
3479 {
3480 NDRX_LOG(log_error, "TESTERROR: Invalid value [%s] exp [%s]", cor_buf, "CORRID=2");
3481 EXFAIL_OUT(ret);
3482 }
3483
3484
3485 if (EXSUCCEED!=Bget(buf8, T_LONG_FLD, 0, (char *)&l, 0L))
3486 {
3487 NDRX_LOG(log_error, "TESTERROR: failed to get T_LONG_FLD %s",
3488 Bstrerror(Berror));
3489 EXFAIL_OUT(ret);
3490 }
3491 if (l != i )
3492 {
3493 NDRX_LOG(log_error, "TESTERROR: Invalid value [%d] exp [%d]", l, i);
3494 EXFAIL_OUT(ret);
3495 }
3496
3497 tpfree((char *)buf8);
3498 }
3499
3500 NDRX_LOG(log_debug, "dequeue next 100 with corid=1 from future Q");
3501 for (i=199; i>=100; i--)
3502 {
3503
3504 if (0!=i%2)
3505 {
3506 continue;
3507 }
3508
3509 UBFH *buf9 = (UBFH *)tpalloc("UBF", "", 1024);
3510 memset(&qc1, 0, sizeof(qc1));
3511
3512 qc1.flags|=TPQGETBYCORRID;
3513 qc1.corrid[0]=1;
3514
3515 if (EXSUCCEED!=tpdequeue("MYSPACE", "FUT_CORLIFO", &qc1, (char **)&buf9, &len, 0))
3516 {
3517 NDRX_LOG(log_error, "TESTERROR: tpdequeue() failed %s diag: %d:%s",
3518 tpstrerror(tperrno), qc1.diagnostic, qc1.diagmsg);
3519 EXFAIL_OUT(ret);
3520 }
3521
3522 ndrx_debug_dump_UBF(log_debug, "msg buf", buf9);
3523
3524
3525 if (EXSUCCEED!=Bget(buf9, T_STRING_FLD, 0, cor_buf, 0L))
3526 {
3527 NDRX_LOG(log_error, "TESTERROR: failed to get T_STRING_FLD %s",
3528 Bstrerror(Berror));
3529 EXFAIL_OUT(ret);
3530 }
3531
3532 if (0!=strcmp("CORRID=1", cor_buf) )
3533 {
3534 NDRX_LOG(log_error, "TESTERROR: Invalid value [%s] exp [%s]", cor_buf, "CORRID=1");
3535 EXFAIL_OUT(ret);
3536 }
3537
3538
3539 if (EXSUCCEED!=Bget(buf9, T_LONG_FLD, 0, (char *)&l, 0L))
3540 {
3541 NDRX_LOG(log_error, "TESTERROR: failed to get T_LONG_FLD %s",
3542 Bstrerror(Berror));
3543 EXFAIL_OUT(ret);
3544 }
3545 if (l != i )
3546 {
3547 NDRX_LOG(log_error, "TESTERROR: Invalid value [%d] exp [%d]", l, i);
3548 EXFAIL_OUT(ret);
3549 }
3550
3551 tpfree((char *)buf9);
3552 }
3553
3554 NDRX_LOG(log_debug, "dequeue last 100 w/o corid from future Q");
3555
3556 for (i=99; i>=0; i--)
3557 {
3558
3559 if (0!=i%2)
3560 {
3561 continue;
3562 }
3563
3564 UBFH *buf10 = (UBFH *)tpalloc("UBF", "", 1024);
3565 memset(&qc1, 0, sizeof(qc1));
3566
3567 if (EXSUCCEED!=tpdequeue("MYSPACE", "FUT_CORLIFO", &qc1, (char **)&buf10, &len, 0))
3568 {
3569 NDRX_LOG(log_error, "TESTERROR: tpdequeue() failed %s diag: %d:%s",
3570 tpstrerror(tperrno), qc1.diagnostic, qc1.diagmsg);
3571 EXFAIL_OUT(ret);
3572 }
3573
3574 ndrx_debug_dump_UBF(log_debug, "msg buf", buf10);
3575
3576
3577 if (EXSUCCEED!=Bget(buf10, T_LONG_FLD, 0, (char *)&l, 0L))
3578 {
3579 NDRX_LOG(log_error, "TESTERROR: failed to get T_LONG_FLD %s",
3580 Bstrerror(Berror));
3581 EXFAIL_OUT(ret);
3582 }
3583 if (l != i )
3584 {
3585 NDRX_LOG(log_error, "TESTERROR: Invalid value [%d] exp [%d]", l, i);
3586 EXFAIL_OUT(ret);
3587 }
3588
3589 tpfree((char *)buf10);
3590 }
3591 out:
3592 return ret;
3593 }
3594
3595
3596