Back to home page

Enduro/X

 
 

    


0001 /**
0002  * @brief Base64 tests (Bug #261)
0003  *
0004  * @file test_nstd_debug.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 
0035 #include <stdio.h>
0036 #include <stdlib.h>
0037 #include <cgreen/cgreen.h>
0038 #include <ubf.h>
0039 #include <ndrstandard.h>
0040 #include <ndebug.h>
0041 #include <string.h>
0042 #include <ndebug.h>
0043 #include <exbase64.h>
0044 #include "test.fd.h"
0045 #include "ubfunit1.h"
0046 #include "xatmi.h"
0047 
0048 /**
0049  * Test base64 functions of Enduro/X standard library
0050  */
0051 Ensure(test_nstd_tplogqinfo)
0052 {
0053     int ret;
0054     
0055     /* lets configure our logger */
0056     
0057     assert_equal(tplogconfig(LOG_FACILITY_NDRX | LOG_FACILITY_UBF | LOG_FACILITY_TP, 
0058             EXFAIL, "ndrx=5 ubf=4 tp=3 iflags=detailed", NULL, NULL), EXSUCCEED);
0059     
0060     
0061     ret = tplogqinfo(log_error, TPLOGQI_GET_NDRX);
0062     
0063     NDRX_LOG(log_debug, "got ret=%d", ret);
0064     
0065     /* The debug shall be returned for given level
0066      * debugger
0067      */
0068     /* as we have something to log */
0069     assert_not_equal(ret, 0);
0070     assert_not_equal(ret, EXFAIL);
0071     /* the logger shall be LOG_FACILITY_NDRX */
0072     assert_equal(ret & LOG_FACILITY_MASK, LOG_FACILITY_NDRX);
0073     assert_equal(TPLOGQI_RET_DBGLEVGET(ret), log_debug);
0074     assert_equal(ret & TPLOGQI_RET_HAVDETAILED, 0);
0075     
0076     /* eval detailed flags */
0077     
0078     ret = tplogqinfo(log_error, TPLOGQI_GET_TP | TPLOGQI_EVAL_DETAILED);
0079     
0080     assert_not_equal(ret, 0);
0081     assert_not_equal(ret, EXFAIL);
0082     /* the logger shall be LOG_FACILITY_NDRX */
0083     assert_equal(ret & LOG_FACILITY_MASK, LOG_FACILITY_TP);
0084     assert_equal(TPLOGQI_RET_DBGLEVGET(ret), log_warn);
0085     assert_not_equal(ret & TPLOGQI_RET_HAVDETAILED, 0);
0086     
0087     
0088     /* test UBF, nothing to return */
0089     
0090     ret = tplogqinfo(log_debug, TPLOGQI_GET_UBF | TPLOGQI_EVAL_DETAILED);
0091     assert_equal(ret, 0);
0092     
0093     
0094     /* return anyway */
0095     ret = tplogqinfo(log_debug, TPLOGQI_GET_UBF | TPLOGQI_EVAL_DETAILED | TPLOGQI_EVAL_RETURN);
0096     assert_not_equal(ret, 0);
0097     assert_not_equal(ret, EXFAIL);
0098     
0099     assert_equal(ret & LOG_FACILITY_MASK, LOG_FACILITY_UBF);
0100     assert_equal(TPLOGQI_RET_DBGLEVGET(ret), log_info);
0101     assert_not_equal(ret & TPLOGQI_RET_HAVDETAILED, 0);
0102     
0103     /* test error */
0104     ret = tplogqinfo(log_debug, 0);
0105     assert_equal(ret, EXFAIL);
0106     assert_equal(Nerror, NEINVAL);
0107     
0108 }
0109 
0110 /**
0111  * Debug routine tests
0112  * @return
0113  */
0114 TestSuite *ubf_nstd_debug(void)
0115 {
0116     TestSuite *suite = create_test_suite();
0117 
0118     add_test(suite, test_nstd_tplogqinfo);
0119             
0120     return suite;
0121 }
0122 /* vim: set ts=4 sw=4 et smartindent: */