1 /* t-support.h - Helper routines for regression tests. 2 * Copyright (C) 2011 g10 Code GmbH 3 * 4 * This file is free software; as a special exception the author gives 5 * unlimited permission to copy and/or distribute it, with or without 6 * modifications, as long as this notice is preserved. 7 * 8 * This file is distributed in the hope that it will be useful, but 9 * WITHOUT ANY WARRANTY, to the extent permitted by law; without even the 10 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11 */ 12 13 #include <stdio.h> 14 #include <stdlib.h> 15 #include <string.h> 16 #include <errno.h> 17 18 #include "npth.h" 19 20 #ifndef DIM 21 #define DIM(v) (sizeof(v)/sizeof((v)[0])) 22 #endif 23 24 static int opt_verbose; 25 26 27 #define fail_if_err(err) \ 28 do \ 29 { \ 30 if (err) \ 31 { \ 32 fprintf (stderr, "%s:%d: %s\n", \ 33 __FILE__, __LINE__, strerror(err)); \ 34 exit (1); \ 35 } \ 36 } \ 37 while (0) 38 39 #define fail_msg(text) \ 40 do \ 41 { \ 42 fprintf (stderr, "%s:%d: %s\n", \ 43 __FILE__, __LINE__, text); \ 44 exit (1); \ 45 } \ 46 while (0) 47 48 #define info_msg(text) \ 49 do \ 50 { \ 51 if (opt_verbose) \ 52 fprintf (stderr, "%s\n", text); \ 53 } \ 54 while (0) 55