1/* 2 Copyright (c) 2010 Frank Lahm <franklahm@gmail.com> 3 4 This program is free software; you can redistribute it and/or modify 5 it under the terms of the GNU General Public License as published by 6 the Free Software Foundation; either version 2 of the License, or 7 (at your option) any later version. 8 9 This program is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 GNU General Public License for more details. 13*/ 14 15#ifndef TEST_H 16#define TEST_H 17 18#ifdef HAVE_CONFIG_H 19#include "config.h" 20#endif /* HAVE_CONFIG_H */ 21 22#include <string.h> 23#include <stdio.h> 24#include <stdlib.h> 25#include <errno.h> 26 27#include <atalk/util.h> 28#include <atalk/cnid.h> 29#include <atalk/logger.h> 30#include <atalk/volume.h> 31#include <atalk/directory.h> 32#include <atalk/queue.h> 33#include <atalk/bstrlib.h> 34#include <atalk/globals.h> 35 36#include "directory.h" 37#include "dircache.h" 38#include "hash.h" 39#include "afp_config.h" 40#include "volume.h" 41#include "subtests.h" 42 43static inline void alignok(int len) 44{ 45 int i = 1; 46 if (len < 80) 47 i = 80 - len; 48 while (i--) 49 printf(" "); 50} 51 52#define TEST(a) \ 53 printf("Testing: %s ... ", (#a) ); \ 54 alignok(strlen(#a)); \ 55 a; \ 56 printf("[ok]\n"); 57 58#define TEST_int(a, b) \ 59 printf("Testing: %s ... ", (#a) ); \ 60 alignok(strlen(#a)); \ 61 if ((reti = (a)) != b) { \ 62 printf("[error]\n"); \ 63 exit(1); \ 64 } else { printf("[ok]\n"); } 65 66#define TEST_expr(a, b) \ 67 printf("Testing: %s ... ", (#a) ); \ 68 alignok(strlen(#a)); \ 69 a; \ 70 if (b) { \ 71 printf("[ok]\n"); \ 72 } else { \ 73 printf("[error]\n"); \ 74 exit(1); \ 75 } 76#endif /* TEST_H */ 77