Back to home page

Enduro/X

 
 

    


0001 /**
0002  * @brief Common-config server tests
0003  *
0004  * @file atmiclt30.c
0005  */
0006 /* -----------------------------------------------------------------------------
0007  * Enduro/X Middleware Platform for Distributed Transaction Processing
0008  * Copyright (C) 2009-2016, ATR Baltic, Ltd. All Rights Reserved.
0009  * Copyright (C) 2017-2023, Mavimax, Ltd. All Rights Reserved.
0010  * This software is released under one of the following licenses:
0011  * AGPL (with Java and Go exceptions) or Mavimax's license for commercial use.
0012  * See LICENSE file for full text.
0013  * -----------------------------------------------------------------------------
0014  * AGPL license:
0015  *
0016  * This program is free software; you can redistribute it and/or modify it under
0017  * the terms of the GNU Affero General Public License, version 3 as published
0018  * by the Free Software Foundation;
0019  *
0020  * This program is distributed in the hope that it will be useful, but WITHOUT ANY
0021  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
0022  * PARTICULAR PURPOSE. See the GNU Affero General Public License, version 3
0023  * for more details.
0024  *
0025  * You should have received a copy of the GNU Affero General Public License along 
0026  * with this program; if not, write to the Free Software Foundation, Inc.,
0027  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
0028  *
0029  * -----------------------------------------------------------------------------
0030  * A commercial use license is available from Mavimax, Ltd
0031  * contact@mavimax.com
0032  * -----------------------------------------------------------------------------
0033  */
0034 #include <string.h>
0035 #include <stdio.h>
0036 #include <stdlib.h>
0037 #include <memory.h>
0038 
0039 #include <atmi.h>
0040 #include <ubf.h>
0041 #include <ndebug.h>
0042 #include <test.fd.h>
0043 #include <ndrstandard.h>
0044 #include <Exfields.h>
0045 #include <ubfutil.h>
0046 /*---------------------------Externs------------------------------------*/
0047 /*---------------------------Macros-------------------------------------*/
0048 /*---------------------------Enums--------------------------------------*/
0049 /*---------------------------Typedefs-----------------------------------*/
0050 /*---------------------------Globals------------------------------------*/
0051 /*---------------------------Statics------------------------------------*/
0052 /*---------------------------Prototypes---------------------------------*/
0053 
0054 /*
0055  * Do the test call to the server
0056  */
0057 int main(int argc, char** argv) {
0058 
0059     UBFH *p_ub;
0060     long rsplen;
0061     int i;
0062     int ret=EXSUCCEED;
0063     long revent;
0064     int sections_got = 0;
0065     int sections_total = 0;
0066     int occ1, occ2;
0067     int cd;
0068     int recv_continue=1;
0069     BFLDID empty[] = {
0070         BBADFLDID
0071     };
0072     
0073     /**************************************************************************
0074      * Get one section, with type checks (OK)
0075      **************************************************************************/
0076     if (NULL==(p_ub= (UBFH *)tpalloc("UBF", NULL, 1024)))
0077     {
0078         NDRX_LOG(log_error, "TESTERROR: buffer alloc failed: %s", tpstrerror(tperrno));
0079         EXFAIL_OUT(ret);
0080     }
0081     
0082     if (EXSUCCEED!=Bchg(p_ub, EX_CC_LOOKUPSECTION, 0, "my_app", 0L) ||
0083             
0084             EXSUCCEED!=Badd(p_ub, EX_CC_FORMAT_KEY,"string_setting", 0L) ||
0085             EXSUCCEED!=Badd(p_ub, EX_CC_FORMAT_FORMAT, "s..6", 0L) ||
0086             
0087             EXSUCCEED!=Badd(p_ub, EX_CC_FORMAT_KEY, "float_setting", 0L) ||
0088             EXSUCCEED!=Badd(p_ub, EX_CC_FORMAT_FORMAT, "n1..5", 0L) ||
0089             
0090             EXSUCCEED!=Badd(p_ub, EX_CC_FORMAT_KEY, "integer_setting", 0L) ||
0091             EXSUCCEED!=Badd(p_ub, EX_CC_FORMAT_FORMAT, "i..6", 0L) ||
0092             
0093             EXSUCCEED!=Badd(p_ub, EX_CC_FORMAT_KEY, "true_setting", 0L) ||
0094             EXSUCCEED!=Badd(p_ub, EX_CC_FORMAT_FORMAT, "t", 0L) ||
0095             
0096             EXSUCCEED!=Badd(p_ub, EX_CC_FORMAT_KEY, "false_setting", 0L) ||
0097             EXSUCCEED!=Badd(p_ub, EX_CC_FORMAT_FORMAT, "t", 0L)
0098             )
0099     {
0100         NDRX_LOG(log_error, "TESTERROR: Failed to setup buffer: %s", Bstrerror(Berror));
0101         EXFAIL_OUT(ret);
0102     }   
0103     
0104     /* call the server */
0105     if (EXFAIL == tpcall("@CCONF", (char *)p_ub, 0L, (char **)&p_ub, &rsplen,0))
0106     {
0107         NDRX_LOG(log_error, "TESTERROR: @CCONF failed: %s", tpstrerror(tperrno));
0108         EXFAIL_OUT(ret);
0109     }
0110     
0111     /* verify results... */
0112     
0113     /* key: string_setting */
0114     
0115     if (EXFAIL==(occ1=CBfindocc (p_ub, EX_CC_KEY, "string_setting", 0, BFLD_STRING)))
0116     {
0117         NDRX_LOG(log_error, "TESTERROR: EX_CC_KEY with value [string_setting] "
0118                 "not found: %s", Bstrerror(Berror));
0119         EXFAIL_OUT(ret);
0120     }
0121     
0122     if (EXFAIL==(occ2=CBfindocc (p_ub, EX_CC_VALUE, "value1", 0, BFLD_STRING)))
0123     {
0124         NDRX_LOG(log_error, "TESTERROR: EX_CC_VALUE with value [value1] "
0125                 "not found: %s", Bstrerror(Berror));
0126         EXFAIL_OUT(ret);
0127     }
0128     
0129     if (occ1!=occ2)
0130     {
0131         NDRX_LOG(log_error, "Invalid occurrences: %d vs %d", occ1, occ2);
0132         EXFAIL_OUT(ret);
0133     }
0134     
0135     /* key: float_setting */
0136     
0137     if (EXFAIL==(occ1=CBfindocc (p_ub, EX_CC_KEY, "float_setting", 0, BFLD_STRING)))
0138     {
0139         NDRX_LOG(log_error, "TESTERROR: EX_CC_KEY with value [float_setting] "
0140                 "not found: %s", Bstrerror(Berror));
0141         EXFAIL_OUT(ret);
0142     }
0143     
0144     if (EXFAIL==(occ2=CBfindocc (p_ub, EX_CC_VALUE, "-1.99", 0, BFLD_STRING)))
0145     {
0146         NDRX_LOG(log_error, "TESTERROR: EX_CC_VALUE with value [-1.99] "
0147                 "not found: %s", Bstrerror(Berror));
0148         EXFAIL_OUT(ret);
0149     }
0150     
0151     if (occ1!=occ2)
0152     {
0153         NDRX_LOG(log_error, "Invalid occurrences: %d vs %d", occ1, occ2);
0154         EXFAIL_OUT(ret);
0155     }
0156     
0157     
0158     /* integer_setting=100001 */
0159     
0160     if (EXFAIL==(occ1=CBfindocc (p_ub, EX_CC_KEY, "integer_setting", 0, BFLD_STRING)))
0161     {
0162         NDRX_LOG(log_error, "TESTERROR: EX_CC_KEY with value [integer_setting] "
0163                 "not found: %s", Bstrerror(Berror));
0164         EXFAIL_OUT(ret);
0165     }
0166     
0167     if (EXFAIL==(occ2=CBfindocc (p_ub, EX_CC_VALUE, "100001", 0, BFLD_STRING)))
0168     {
0169         NDRX_LOG(log_error, "TESTERROR: EX_CC_VALUE with value [100001] "
0170                 "not found: %s", Bstrerror(Berror));
0171         EXFAIL_OUT(ret);
0172     }
0173     
0174     if (occ1!=occ2)
0175     {
0176         NDRX_LOG(log_error, "Invalid occurrences: %d vs %d", occ1, occ2);
0177         EXFAIL_OUT(ret);
0178     }
0179     
0180     
0181     /* true_setting=True */
0182     
0183     if (EXFAIL==(occ1=CBfindocc (p_ub, EX_CC_KEY, "true_setting", 0, BFLD_STRING)))
0184     {
0185         NDRX_LOG(log_error, "TESTERROR: EX_CC_KEY with value [true_setting] "
0186                 "not found: %s", Bstrerror(Berror));
0187         EXFAIL_OUT(ret);
0188     }
0189     
0190     if (EXFAIL==(occ2=CBfindocc (p_ub, EX_CC_VALUE, "True", 0, BFLD_STRING)))
0191     {
0192         NDRX_LOG(log_error, "TESTERROR: EX_CC_VALUE with value [True] "
0193                 "not found: %s", Bstrerror(Berror));
0194         EXFAIL_OUT(ret);
0195     }
0196     
0197     if (occ1!=occ2)
0198     {
0199         NDRX_LOG(log_error, "Invalid occurrences: %d vs %d", occ1, occ2);
0200         EXFAIL_OUT(ret);
0201     }
0202     
0203     /* false_setting=no */
0204      
0205     if (EXFAIL==(occ1=CBfindocc (p_ub, EX_CC_KEY, "false_setting", 0, BFLD_STRING)))
0206     {
0207         NDRX_LOG(log_error, "TESTERROR: EX_CC_KEY with value [false_setting] "
0208                 "not found: %s", Bstrerror(Berror));
0209         EXFAIL_OUT(ret);
0210     }
0211     
0212     if (EXFAIL==(occ2=CBfindocc (p_ub, EX_CC_VALUE, "no", 0, BFLD_STRING)))
0213     {
0214         NDRX_LOG(log_error, "TESTERROR: EX_CC_VALUE with value [no] "
0215                 "not found: %s", Bstrerror(Berror));
0216         EXFAIL_OUT(ret);
0217     }
0218     
0219     if (occ1!=occ2)
0220     {
0221         NDRX_LOG(log_error, "Invalid occurrences: %d vs %d", occ1, occ2);
0222         EXFAIL_OUT(ret);
0223     }
0224     
0225     tpfree((char *)p_ub);
0226     
0227     
0228     /**************************************************************************
0229      * Get one section, with type checks (FAIL)
0230      **************************************************************************/
0231     if (NULL==(p_ub= (UBFH *)tpalloc("UBF", NULL, 1024)))
0232     {
0233         NDRX_LOG(log_error, "TESTERROR: buffer alloc failed: %s", tpstrerror(tperrno));
0234         EXFAIL_OUT(ret);
0235     }
0236     
0237     if (EXSUCCEED!=Bchg(p_ub, EX_CC_LOOKUPSECTION, 0, "xapp", 0L) ||
0238             
0239             EXSUCCEED!=Bchg(p_ub, EX_CC_FORMAT_KEY,0, "xstring_setting", 0L) ||
0240             EXSUCCEED!=Bchg(p_ub, EX_CC_FORMAT_FORMAT, 0, "s..6", 0L))
0241     {
0242         NDRX_LOG(log_error, "TESTERROR: buffer failed to setup: %s", 
0243                 Bstrerror(Berror));
0244         EXFAIL_OUT(ret);
0245     }
0246     
0247     if (EXSUCCEED == tpcall("@CCONF", (char *)p_ub, 0L, (char **)&p_ub, &rsplen,0))
0248     {
0249         NDRX_LOG(log_error, "TESTERROR: @CCONF must FAIL!");
0250         EXFAIL_OUT(ret);
0251     }
0252     else
0253     {
0254         /* check the error codes 
0255          * Should be something like this:
0256         EX_NERROR_CODE  7 - invalid format
0257         EX_NERROR_MSG   xstring_setting
0258          * */
0259              
0260         if (EXFAIL==(occ1=CBfindocc (p_ub, EX_NERROR_CODE, "7", 0, BFLD_STRING)))
0261         {
0262             NDRX_LOG(log_error, "TESTERROR: EX_NERROR_CODE with value [7] "
0263                     "not found: %s", Bstrerror(Berror));
0264             EXFAIL_OUT(ret);
0265         }
0266 
0267         if (EXFAIL==(occ2=CBfindocc (p_ub, EX_NERROR_MSG, "xstring_setting", 0, BFLD_STRING)))
0268         {
0269             NDRX_LOG(log_error, "TESTERROR: EX_CC_VALUE with value [xstring_setting] "
0270                     "not found: %s", Bstrerror(Berror));
0271             EXFAIL_OUT(ret);
0272         }
0273 
0274         if (occ1!=occ2)
0275         {
0276             NDRX_LOG(log_error, "Invalid occurrences: %d vs %d", occ1, occ2);
0277             EXFAIL_OUT(ret);
0278         }
0279     }
0280     
0281     Bdelall(p_ub, EX_NERROR_CODE);
0282     Bdelall(p_ub, EX_NERROR_MSG);
0283     
0284     if (EXSUCCEED!=Bchg(p_ub, EX_CC_LOOKUPSECTION, 0, "xapp", 0L) ||
0285             
0286             EXSUCCEED!=Bchg(p_ub, EX_CC_FORMAT_KEY,0, "xfloat_setting", 0L) ||
0287             EXSUCCEED!=Bchg(p_ub, EX_CC_FORMAT_FORMAT, 0, "n1..1", 0L))
0288     {
0289         NDRX_LOG(log_error, "TESTERROR: buffer failed to setup: %s", 
0290                 Bstrerror(Berror));
0291         EXFAIL_OUT(ret);
0292     }
0293     
0294     if (EXSUCCEED == tpcall("@CCONF", (char *)p_ub, 0L, (char **)&p_ub, &rsplen,0))
0295     {
0296         NDRX_LOG(log_error, "TESTERROR: @CCONF must FAIL!");
0297         EXFAIL_OUT(ret);
0298     }
0299     else
0300     {
0301         /* check the error codes 
0302          * Should be something like this:
0303         EX_NERROR_CODE  7 - invalid format
0304         EX_NERROR_MSG   xstring_setting
0305          * */
0306              
0307         if (EXFAIL==(occ1=CBfindocc (p_ub, EX_NERROR_CODE, "7", 0, BFLD_STRING)))
0308         {
0309             NDRX_LOG(log_error, "TESTERROR: EX_NERROR_CODE with value [7] "
0310                     "not found: %s", Bstrerror(Berror));
0311             EXFAIL_OUT(ret);
0312         }
0313 
0314         if (EXFAIL==(occ2=CBfindocc (p_ub, EX_NERROR_MSG, "xfloat_setting", 0, BFLD_STRING)))
0315         {
0316             NDRX_LOG(log_error, "TESTERROR: EX_CC_VALUE with value [xfloat_setting] "
0317                     "not found: %s", Bstrerror(Berror));
0318             EXFAIL_OUT(ret);
0319         }
0320 
0321         if (occ1!=occ2)
0322         {
0323             NDRX_LOG(log_error, "Invalid occurrences: %d vs %d", occ1, occ2);
0324             EXFAIL_OUT(ret);
0325         }
0326     }
0327     
0328     
0329     Bdelall(p_ub, EX_NERROR_CODE);
0330     Bdelall(p_ub, EX_NERROR_MSG);
0331     
0332     if (EXSUCCEED!=Bchg(p_ub, EX_CC_LOOKUPSECTION, 0, "xapp", 0L) ||
0333             
0334             EXSUCCEED!=Bchg(p_ub, EX_CC_FORMAT_KEY,0, "xinteger_setting", 0L) ||
0335             EXSUCCEED!=Bchg(p_ub, EX_CC_FORMAT_FORMAT, 0, "i..10", 0L))
0336     {
0337         NDRX_LOG(log_error, "TESTERROR: buffer failed to setup: %s", 
0338                 Bstrerror(Berror));
0339         EXFAIL_OUT(ret);
0340     }
0341     
0342     if (EXSUCCEED == tpcall("@CCONF", (char *)p_ub, 0L, (char **)&p_ub, &rsplen,0))
0343     {
0344         NDRX_LOG(log_error, "TESTERROR: @CCONF must FAIL!");
0345         EXFAIL_OUT(ret);
0346     }
0347     else
0348     {
0349         /* check the error codes 
0350          * Should be something like this:
0351         EX_NERROR_CODE  7 - invalid format
0352         EX_NERROR_MSG   xstring_setting
0353          * */
0354              
0355         if (EXFAIL==(occ1=CBfindocc (p_ub, EX_NERROR_CODE, "7", 0, BFLD_STRING)))
0356         {
0357             NDRX_LOG(log_error, "TESTERROR: EX_NERROR_CODE with value [7] "
0358                     "not found: %s", Bstrerror(Berror));
0359             EXFAIL_OUT(ret);
0360         }
0361 
0362         if (EXFAIL==(occ2=CBfindocc (p_ub, EX_NERROR_MSG, "xinteger_setting", 0, BFLD_STRING)))
0363         {
0364             NDRX_LOG(log_error, "TESTERROR: EX_CC_VALUE with value [xinteger_setting] "
0365                     "not found: %s", Bstrerror(Berror));
0366             EXFAIL_OUT(ret);
0367         }
0368 
0369         if (occ1!=occ2)
0370         {
0371             NDRX_LOG(log_error, "Invalid occurrences: %d vs %d", occ1, occ2);
0372             EXFAIL_OUT(ret);
0373         }
0374     }
0375     
0376     
0377     Bdelall(p_ub, EX_NERROR_CODE);
0378     Bdelall(p_ub, EX_NERROR_MSG);
0379     
0380     if (EXSUCCEED!=Bchg(p_ub, EX_CC_LOOKUPSECTION, 0, "xapp", 0L) ||
0381             
0382             EXSUCCEED!=Bchg(p_ub, EX_CC_FORMAT_KEY,0, "xtrue_setting", 0L) ||
0383             EXSUCCEED!=Bchg(p_ub, EX_CC_FORMAT_FORMAT, 0, "t", 0L))
0384     {
0385         NDRX_LOG(log_error, "TESTERROR: buffer failed to setup: %s", 
0386                 Bstrerror(Berror));
0387         EXFAIL_OUT(ret);
0388     }
0389     
0390     if (EXSUCCEED == tpcall("@CCONF", (char *)p_ub, 0L, (char **)&p_ub, &rsplen,0))
0391     {
0392         NDRX_LOG(log_error, "TESTERROR: @CCONF must FAIL!");
0393         EXFAIL_OUT(ret);
0394     }
0395     else
0396     {
0397         /* check the error codes 
0398          * Should be something like this:
0399         EX_NERROR_CODE  7 - invalid format
0400         EX_NERROR_MSG   xstring_setting
0401          * */
0402              
0403         if (EXFAIL==(occ1=CBfindocc (p_ub, EX_NERROR_CODE, "7", 0, BFLD_STRING)))
0404         {
0405             NDRX_LOG(log_error, "TESTERROR: EX_NERROR_CODE with value [7] "
0406                     "not found: %s", Bstrerror(Berror));
0407             EXFAIL_OUT(ret);
0408         }
0409 
0410         if (EXFAIL==(occ2=CBfindocc (p_ub, EX_NERROR_MSG, "xtrue_setting", 0, BFLD_STRING)))
0411         {
0412             NDRX_LOG(log_error, "TESTERROR: EX_CC_VALUE with value [xtrue_setting] "
0413                     "not found: %s", Bstrerror(Berror));
0414             EXFAIL_OUT(ret);
0415         }
0416 
0417         if (occ1!=occ2)
0418         {
0419             NDRX_LOG(log_error, "Invalid occurrences: %d vs %d", occ1, occ2);
0420             EXFAIL_OUT(ret);
0421         }
0422     }
0423     
0424     
0425     Bdelall(p_ub, EX_NERROR_CODE);
0426     Bdelall(p_ub, EX_NERROR_MSG);
0427     
0428     if (EXSUCCEED!=Bchg(p_ub, EX_CC_LOOKUPSECTION, 0, "xapp", 0L) ||
0429             
0430             EXSUCCEED!=Bchg(p_ub, EX_CC_FORMAT_KEY,0, "xfalse_setting", 0L) ||
0431             EXSUCCEED!=Bchg(p_ub, EX_CC_FORMAT_FORMAT, 0, "t", 0L))
0432     {
0433         NDRX_LOG(log_error, "TESTERROR: buffer failed to setup: %s", 
0434                 Bstrerror(Berror));
0435         EXFAIL_OUT(ret);
0436     }
0437     
0438     if (EXSUCCEED == tpcall("@CCONF", (char *)p_ub, 0L, (char **)&p_ub, &rsplen,0))
0439     {
0440         NDRX_LOG(log_error, "TESTERROR: @CCONF must FAIL!");
0441         EXFAIL_OUT(ret);
0442     }
0443     else
0444     {
0445         /* check the error codes 
0446          * Should be something like this:
0447         EX_NERROR_CODE  7 - invalid format
0448         EX_NERROR_MSG   xstring_setting
0449          * */
0450              
0451         if (EXFAIL==(occ1=CBfindocc (p_ub, EX_NERROR_CODE, "7", 0, BFLD_STRING)))
0452         {
0453             NDRX_LOG(log_error, "TESTERROR: EX_NERROR_CODE with value [7] "
0454                     "not found: %s", Bstrerror(Berror));
0455             EXFAIL_OUT(ret);
0456         }
0457 
0458         if (EXFAIL==(occ2=CBfindocc (p_ub, EX_NERROR_MSG, "xfalse_setting", 0, BFLD_STRING)))
0459         {
0460             NDRX_LOG(log_error, "TESTERROR: EX_CC_VALUE with value [xfalse_setting] "
0461                     "not found: %s", Bstrerror(Berror));
0462             EXFAIL_OUT(ret);
0463         }
0464 
0465         if (occ1!=occ2)
0466         {
0467             NDRX_LOG(log_error, "Invalid occurrences: %d vs %d", occ1, occ2);
0468             EXFAIL_OUT(ret);
0469         }
0470     }
0471     
0472     
0473     /**************************************************************************
0474      * Check for mandatory field
0475      **************************************************************************/
0476     Bdelall(p_ub, EX_NERROR_CODE);
0477     Bdelall(p_ub, EX_NERROR_MSG);
0478     
0479     if (EXSUCCEED!=Bchg(p_ub, EX_CC_LOOKUPSECTION, 0, "x2app", 0L) ||
0480             
0481             EXSUCCEED!=Bchg(p_ub, EX_CC_MANDATORY,0, "xtrue_setting", 0L))
0482     {
0483         NDRX_LOG(log_error, "TESTERROR: buffer failed to setup: %s", 
0484                 Bstrerror(Berror));
0485         EXFAIL_OUT(ret);
0486     }
0487     
0488     if (EXSUCCEED == tpcall("@CCONF", (char *)p_ub, 0L, (char **)&p_ub, &rsplen,0))
0489     {
0490         NDRX_LOG(log_error, "TESTERROR: @CCONF must FAIL!");
0491         EXFAIL_OUT(ret);
0492     }
0493     else
0494     {
0495         /* check the error codes 
0496          * Should be something like this:
0497         EX_NERROR_CODE  6 - mandatory field missing
0498         EX_NERROR_MSG   xtrue_setting
0499          * */
0500              
0501         if (EXFAIL==(occ1=CBfindocc (p_ub, EX_NERROR_CODE, "6", 0, BFLD_STRING)))
0502         {
0503             NDRX_LOG(log_error, "TESTERROR: EX_NERROR_CODE with value [6] "
0504                     "not found: %s", Bstrerror(Berror));
0505             EXFAIL_OUT(ret);
0506         }
0507 
0508         if (EXFAIL==(occ2=CBfindocc (p_ub, EX_NERROR_MSG, "xtrue_setting", 0, BFLD_STRING)))
0509         {
0510             NDRX_LOG(log_error, "TESTERROR: EX_CC_VALUE with value [xtrue_setting] "
0511                     "not found: %s", Bstrerror(Berror));
0512             EXFAIL_OUT(ret);
0513         }
0514 
0515         if (occ1!=occ2)
0516         {
0517             NDRX_LOG(log_error, "Invalid occurrences: %d vs %d", occ1, occ2);
0518             EXFAIL_OUT(ret);
0519         }
0520     }
0521     
0522     /**************************************************************************
0523      * Lookup stuff in new file...
0524      **************************************************************************/
0525     /* Remove all fields from buffer.. */
0526     Bproj(p_ub, empty);
0527     if (EXSUCCEED!=Bchg(p_ub, EX_CC_LOOKUPSECTION, 0, "test_section", 0L))
0528     {
0529         NDRX_LOG(log_error, "TESTERROR: buffer failed to setup: %s", 
0530                 Bstrerror(Berror));
0531         EXFAIL_OUT(ret);
0532     }
0533     
0534     if (EXSUCCEED!=Bchg(p_ub, EX_CC_RESOURCE, 0, "test.ini", 0L))
0535     {
0536         NDRX_LOG(log_error, "TESTERROR: buffer failed to setup: %s", 
0537                 Bstrerror(Berror));
0538         EXFAIL_OUT(ret);
0539     }
0540     
0541     if (EXFAIL == tpcall("@CCONF", (char *)p_ub, 0L, (char **)&p_ub, &rsplen,0))
0542     {
0543         NDRX_LOG(log_error, "TESTERROR: @CCONF failed: %s", tpstrerror(tperrno));
0544         ndrx_debug_dump_UBF(log_debug, "CCONF error rsp", p_ub);
0545         
0546         EXFAIL_OUT(ret);
0547     }
0548     else
0549     {     
0550         if (EXFAIL==CBfindocc (p_ub, EX_CC_VALUE, "motorcycle", 0, BFLD_STRING))
0551         {
0552             NDRX_LOG(log_error, "TESTERROR: cannot find EX_CC_VALUE with value "
0553                     "[motorcycle]: %s", Bstrerror(Berror));
0554             EXFAIL_OUT(ret);
0555         }
0556     }
0557     /* now lookup some other section, must not be found */
0558     Bproj(p_ub, empty);
0559     if (EXSUCCEED!=Bchg(p_ub, EX_CC_LOOKUPSECTION, 0, "xapp", 0L))
0560     {
0561         NDRX_LOG(log_error, "TESTERROR: buffer failed to setup: %s", 
0562                 Bstrerror(Berror));
0563         EXFAIL_OUT(ret);
0564     }
0565     
0566     if (EXSUCCEED!=Bchg(p_ub, EX_CC_RESOURCE, 0, "test.ini", 0L))
0567     {
0568         NDRX_LOG(log_error, "TESTERROR: buffer failed to setup: %s", 
0569                 Bstrerror(Berror));
0570         EXFAIL_OUT(ret);
0571     }
0572     if (EXSUCCEED!=Bchg(p_ub, EX_CC_MANDATORY, 0, "xstring_setting", 0L))
0573     {
0574         NDRX_LOG(log_error, "TESTERROR: buffer failed to setup: %s", 
0575                 Bstrerror(Berror));
0576         EXFAIL_OUT(ret);
0577     }
0578     
0579     
0580     /* cos we are not looking into endurox.ini */
0581     if (EXSUCCEED == tpcall("@CCONF", (char *)p_ub, 0L, (char **)&p_ub, &rsplen,0))
0582     {
0583         NDRX_LOG(log_error, "TESTERROR: @CCONF must not return [xapp]!", tpstrerror(tperrno));
0584         ndrx_debug_dump_UBF(log_debug, "CCONF error rsp", p_ub);
0585         
0586         EXFAIL_OUT(ret);
0587     }
0588     
0589     /**************************************************************************
0590      * Call the section listing
0591      **************************************************************************/
0592     
0593     tpfree((char *)p_ub);
0594     
0595     if (NULL==(p_ub= (UBFH *)tpalloc("UBF", NULL, 1024)))
0596     {
0597         NDRX_LOG(log_error, "TESTERROR: buffer alloc failed: %s", tpstrerror(tperrno));
0598         EXFAIL_OUT(ret);
0599     }
0600     
0601     if (EXSUCCEED!=CBchg(p_ub, EX_CC_CMD, 0, "l", 0L, BFLD_STRING))
0602     {
0603         NDRX_LOG(log_error, "TESTERROR: Failed to set EX_CPMCOMMAND to l!");        
0604         EXFAIL_OUT(ret);
0605     }
0606      
0607     /* get the sections which starts with x */
0608     if (EXSUCCEED!=CBchg(p_ub, EX_CC_SECTIONMASK, 0, "x", 0L, BFLD_STRING))
0609     {
0610         NDRX_LOG(log_error, "TESTERROR: Failed to set EX_CC_SECTIONMASK to l!");        
0611         EXFAIL_OUT(ret);
0612     }
0613     
0614     if (EXFAIL == (cd = tpconnect("@CCONF",
0615                                     (char *)p_ub,
0616                                     0,
0617                                     TPNOTRAN |
0618                                     TPRECVONLY)))
0619     {
0620         NDRX_LOG(log_error, "Connect error [%s]", tpstrerror(tperrno) );
0621         
0622         ret = EXFAIL;
0623         goto out;
0624     }
0625     NDRX_LOG(log_debug, "Connected OK, cd = %d", cd );
0626 
0627     while (recv_continue)
0628     {
0629         int tp_errno;
0630         recv_continue=0;
0631         if (EXFAIL == tprecv(cd,
0632                             (char **)&p_ub,
0633                             0L,
0634                             0L,
0635                             &revent))
0636         {
0637             ret = EXFAIL;
0638             tp_errno = tperrno;
0639             if (TPEEVENT == tp_errno)
0640             {
0641                 if (TPEV_SVCSUCC == revent)
0642                         ret = EXSUCCEED;
0643                 else
0644                 {
0645                     NDRX_LOG(log_error,
0646                              "Unexpected conv event %lx", revent );
0647                     EXFAIL_OUT(ret);
0648                 }
0649             }
0650         }
0651         else
0652         {
0653             recv_continue=1;
0654             /* Check for specified values (per section) and
0655              * count them, must much the section count in ini
0656              */
0657             
0658             if (CBfindocc (p_ub, EX_CC_KEY, "xstring_setting", 0, BFLD_STRING)>=0)
0659             {
0660                 sections_got++;
0661             }
0662             
0663             if (CBfindocc (p_ub, EX_CC_KEY, "hello", 0, BFLD_STRING)>=0)
0664             {
0665                 sections_got++;
0666             }
0667             
0668             sections_total++;
0669         }
0670     }
0671     
0672     if (sections_got!=sections_total)
0673     {
0674         NDRX_LOG(log_error, "TESTERROR: Got sections does not match total: %d vs %d",
0675                 sections_got, sections_total);
0676         EXFAIL_OUT(ret);
0677     }
0678     
0679     if (EXSUCCEED!=tpterm())
0680     {
0681         NDRX_LOG(log_error, "tpterm failed with: %s", tpstrerror(tperrno));
0682         ret=EXFAIL;
0683         goto out;
0684     }
0685     
0686 out:
0687     return ret;
0688 }
0689 
0690 /* vim: set ts=4 sw=4 et smartindent: */