1712b2f30Ssthen /* 2712b2f30Ssthen * testcode/unitmain.h - unit test main program for unbound. 3712b2f30Ssthen * 4712b2f30Ssthen * Copyright (c) 2007, NLnet Labs. All rights reserved. 5712b2f30Ssthen * 6712b2f30Ssthen * This software is open source. 7712b2f30Ssthen * 8712b2f30Ssthen * Redistribution and use in source and binary forms, with or without 9712b2f30Ssthen * modification, are permitted provided that the following conditions 10712b2f30Ssthen * are met: 11712b2f30Ssthen * 12712b2f30Ssthen * Redistributions of source code must retain the above copyright notice, 13712b2f30Ssthen * this list of conditions and the following disclaimer. 14712b2f30Ssthen * 15712b2f30Ssthen * Redistributions in binary form must reproduce the above copyright notice, 16712b2f30Ssthen * this list of conditions and the following disclaimer in the documentation 17712b2f30Ssthen * and/or other materials provided with the distribution. 18712b2f30Ssthen * 19712b2f30Ssthen * Neither the name of the NLNET LABS nor the names of its contributors may 20712b2f30Ssthen * be used to endorse or promote products derived from this software without 21712b2f30Ssthen * specific prior written permission. 22712b2f30Ssthen * 23712b2f30Ssthen * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24712b2f30Ssthen * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25712b2f30Ssthen * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 26712b2f30Ssthen * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 27712b2f30Ssthen * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 28712b2f30Ssthen * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 29712b2f30Ssthen * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 30712b2f30Ssthen * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 31712b2f30Ssthen * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 32712b2f30Ssthen * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 33712b2f30Ssthen * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34712b2f30Ssthen * 35712b2f30Ssthen */ 36712b2f30Ssthen /** 37712b2f30Ssthen * \file 38712b2f30Ssthen * Declarations useful for the unit tests. 39712b2f30Ssthen */ 40712b2f30Ssthen 41712b2f30Ssthen #ifndef TESTCODE_UNITMAIN_H 42712b2f30Ssthen #define TESTCODE_UNITMAIN_H 43712b2f30Ssthen #include "util/log.h" 44712b2f30Ssthen 45712b2f30Ssthen /** number of tests done */ 46712b2f30Ssthen extern int testcount; 47712b2f30Ssthen /** test bool x, exits on failure, increases testcount. */ 48712b2f30Ssthen #ifdef DEBUG_UNBOUND 49712b2f30Ssthen #define unit_assert(x) do {testcount++; log_assert(x);} while(0) 50712b2f30Ssthen #else 51712b2f30Ssthen #define unit_assert(x) do {testcount++; if(!(x)) { fprintf(stderr, "assertion failure %s:%d\n", __FILE__, __LINE__); exit(1);}} while(0) 52712b2f30Ssthen #endif 53712b2f30Ssthen 54712b2f30Ssthen /** we are now testing this function */ 55712b2f30Ssthen void unit_show_func(const char* file, const char* func); 56712b2f30Ssthen /** we are testing this functionality */ 57712b2f30Ssthen void unit_show_feature(const char* feature); 58712b2f30Ssthen 59712b2f30Ssthen /** unit test lruhashtable implementation */ 60712b2f30Ssthen void lruhash_test(void); 61712b2f30Ssthen /** unit test slabhashtable implementation */ 62712b2f30Ssthen void slabhash_test(void); 63712b2f30Ssthen /** unit test for msgreply and msgparse */ 64712b2f30Ssthen void msgparse_test(void); 65712b2f30Ssthen /** unit test dname handling functions */ 66712b2f30Ssthen void dname_test(void); 67712b2f30Ssthen /** unit test trust anchor storage functions */ 68712b2f30Ssthen void anchors_test(void); 69712b2f30Ssthen /** unit test for verification functions */ 70712b2f30Ssthen void verify_test(void); 71712b2f30Ssthen /** unit test for negative cache functions */ 72712b2f30Ssthen void neg_test(void); 73712b2f30Ssthen /** unit test for regional allocator functions */ 74712b2f30Ssthen void regional_test(void); 75712b2f30Ssthen #ifdef CLIENT_SUBNET 76712b2f30Ssthen /** Unit test for ECS functions */ 77712b2f30Ssthen void ecs_test(void); 78712b2f30Ssthen #endif /* CLIENT_SUBNET */ 79712b2f30Ssthen /** unit test for ldns functions */ 80712b2f30Ssthen void ldns_test(void); 81712b2f30Ssthen /** unit test for auth zone functions */ 82712b2f30Ssthen void authzone_test(void); 83*a6cc1574Ssthen /** unit test for zonemd functions */ 84*a6cc1574Ssthen void zonemd_test(void); 85*a6cc1574Ssthen /** unit test for tcp_reuse functions */ 86*a6cc1574Ssthen void tcpreuse_test(void); 87712b2f30Ssthen 88712b2f30Ssthen #endif /* TESTCODE_UNITMAIN_H */ 89