1139749Simp/* 272017Scg * testcode/unitmain.h - unit test main program for unbound. 372017Scg * 472017Scg * Copyright (c) 2007, NLnet Labs. All rights reserved. 572017Scg * 672017Scg * This software is open source. 772017Scg * 872017Scg * Redistribution and use in source and binary forms, with or without 972017Scg * modification, are permitted provided that the following conditions 1072017Scg * are met: 1172017Scg * 1272017Scg * Redistributions of source code must retain the above copyright notice, 1372017Scg * this list of conditions and the following disclaimer. 1472017Scg * 1572017Scg * Redistributions in binary form must reproduce the above copyright notice, 1672017Scg * this list of conditions and the following disclaimer in the documentation 1772017Scg * and/or other materials provided with the distribution. 1872017Scg * 1972017Scg * Neither the name of the NLNET LABS nor the names of its contributors may 2072017Scg * be used to endorse or promote products derived from this software without 2172017Scg * specific prior written permission. 2272017Scg * 2372017Scg * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 2472017Scg * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25192919Sjoel * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 26192919Sjoel * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 27192919Sjoel * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 2872017Scg * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 2972017Scg * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 3072455Scg * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 3172455Scg * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 3272455Scg * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 3372017Scg * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 3472017Scg * 3572017Scg */ 3672017Scg/** 37119287Simp * \file 38119287Simp * Declarations useful for the unit tests. 3972017Scg */ 4072017Scg 4172017Scg#ifndef TESTCODE_UNITMAIN_H 4282180Scg#define TESTCODE_UNITMAIN_H 4382180Scg#include "util/log.h" 4484771Sorion 4572017Scg/** number of tests done */ 4672017Scgextern int testcount; 4772017Scg/** test bool x, exits on failure, increases testcount. */ 4872017Scg#ifdef DEBUG_UNBOUND 4972017Scg#define unit_assert(x) do {testcount++; log_assert(x);} while(0) 5072017Scg#else 5172017Scg#define unit_assert(x) do {testcount++; if(!(x)) { fprintf(stderr, "assertion failure %s:%d\n", __FILE__, __LINE__); exit(1);}} while(0) 5272017Scg#endif 5372017Scg 5472017Scg/** we are now testing this function */ 5572017Scgvoid unit_show_func(const char* file, const char* func); 5672017Scg/** we are testing this functionality */ 5772017Scgvoid unit_show_feature(const char* feature); 5872017Scg 5972017Scg/** unit test lruhashtable implementation */ 6072017Scgvoid lruhash_test(void); 6172017Scg/** unit test slabhashtable implementation */ 6272017Scgvoid slabhash_test(void); 6372017Scg/** unit test for msgreply and msgparse */ 6472017Scgvoid msgparse_test(void); 6572017Scg/** unit test dname handling functions */ 6672017Scgvoid dname_test(void); 6772017Scg/** unit test trust anchor storage functions */ 6872017Scgvoid anchors_test(void); 6972017Scg/** unit test for verification functions */ 7074763Scgvoid verify_test(void); 7174763Scg/** unit test for negative cache functions */ 7272017Scgvoid neg_test(void); 7372455Scg/** unit test for regional allocator functions */ 7472455Scgvoid regional_test(void); 7572455Scg#ifdef CLIENT_SUBNET 7672017Scg/** Unit test for ECS functions */ 7772017Scgvoid ecs_test(void); 7872017Scg#endif /* CLIENT_SUBNET */ 7972017Scg/** unit test for ldns functions */ 8072017Scgvoid ldns_test(void); 8172017Scg/** unit test for auth zone functions */ 8272017Scgvoid authzone_test(void); 8372017Scg/** unit test for zonemd functions */ 8472017Scgvoid zonemd_test(void); 8572017Scg/** unit test for tcp_reuse functions */ 8672017Scgvoid tcpreuse_test(void); 8772017Scg 8872017Scg#endif /* TESTCODE_UNITMAIN_H */ 8972017Scg