Back to home page

Enduro/X

 
 

    


0001 /**
0002  *
0003  * @file test_mkfldhdr.c
0004  */
0005 /* -----------------------------------------------------------------------------
0006  * Enduro/X Middleware Platform for Distributed Transaction Processing
0007  * Copyright (C) 2009-2016, ATR Baltic, Ltd. All Rights Reserved.
0008  * Copyright (C) 2017-2023, Mavimax, Ltd. All Rights Reserved.
0009  * This software is released under one of the following licenses:
0010  * AGPL (with Java and Go exceptions) or Mavimax's license for commercial use.
0011  * See LICENSE file for full text.
0012  * -----------------------------------------------------------------------------
0013  * AGPL license:
0014  *
0015  * This program is free software; you can redistribute it and/or modify it under
0016  * the terms of the GNU Affero General Public License, version 3 as published
0017  * by the Free Software Foundation;
0018  *
0019  * This program is distributed in the hope that it will be useful, but WITHOUT ANY
0020  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
0021  * PARTICULAR PURPOSE. See the GNU Affero General Public License, version 3
0022  * for more details.
0023  *
0024  * You should have received a copy of the GNU Affero General Public License along 
0025  * with this program; if not, write to the Free Software Foundation, Inc.,
0026  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
0027  *
0028  * -----------------------------------------------------------------------------
0029  * A commercial use license is available from Mavimax, Ltd
0030  * contact@mavimax.com
0031  * -----------------------------------------------------------------------------
0032  */
0033 
0034 #include <stdio.h>
0035 #include <stdlib.h>
0036 #include <cgreen/cgreen.h>
0037 #include <ubf.h>
0038 #include <ndrstandard.h>
0039 #include <string.h>
0040 #include "test.fd.h"
0041 #include "ubfunit1.h"
0042 
0043 /**
0044  * Check duplicate field table resolve
0045  */
0046 Ensure(test_dup_tab_resolve)
0047 {
0048     setenv("FLDTBLDIR", "./ubftab", 1);
0049     setenv("FIELDTBLS", "dup.test", 1);
0050     
0051     /* resolves to last loaded */
0052     assert_equal(Bfldid("T_DUP_FLD"), 67112876);
0053     
0054     /* resolves to last loaded. */
0055     assert_string_equal(Bfname(67112875), "T_HELLO_FLD");
0056 }
0057 
0058 /**
0059  * Calls scripts for checing mkfldhdr. Return code says
0060  * was OK or not OK.
0061  */
0062 Ensure(test_mkfldhdr)
0063 {
0064     load_field_table();
0065     assert_equal(system("./test_mkfldhdr_cmd.sh"), EXSUCCEED);
0066     assert_equal(system("./test_mkfldhdr_env.sh"), EXSUCCEED);
0067     assert_equal(system("./test_mkfldhdr_env_multidir.sh"), EXSUCCEED);
0068     assert_equal(system("./test_mkfldhdr_dup.sh"), EXSUCCEED);
0069     assert_not_equal(system("./test_mkfldhdr_err_output.sh"), EXSUCCEED);
0070     assert_not_equal(system("./test_mkfldhdr_no_FLDTBLDIR.sh"), EXSUCCEED);
0071     assert_not_equal(system("./test_mkfldhdr_no_FIELDTBLS.sh"), EXSUCCEED);
0072     assert_not_equal(system("./test_mkfldhdr_syntax_err.sh"), EXSUCCEED);
0073 
0074 }
0075 
0076 TestSuite *ubf_mkfldhdr_tests(void)
0077 {
0078     TestSuite *suite = create_test_suite();
0079 
0080     add_test(suite, test_mkfldhdr);
0081     add_test(suite, test_dup_tab_resolve);
0082 
0083     return suite;
0084 }
0085 
0086 
0087 /* vim: set ts=4 sw=4 et smartindent: */