source: XIOS/dev/dev_olga/src/extern/src_netcdf4/err_macros.h @ 1022

Last change on this file since 1022 was 1022, checked in by mhnguyen, 7 years ago
File size: 2.4 KB
Line 
1/* This is part of the netCDF package.
2   Copyright 2005 University Corporation for Atmospheric Research/Unidata
3   See COPYRIGHT file for conditions of use.
4
5   Common includes, defines, etc., for test code in the libsrc4 and
6   nc_test4 directories.
7*/
8
9#ifndef _ERR_MACROS_H
10#define _ERR_MACROS_H
11
12#include <config.h>
13#include <assert.h>
14#include <stdio.h>
15#include <string.h>
16#include <stdlib.h>
17
18/* Err is used to keep track of errors within each set of tests,
19 * total_err is the number of errors in the entire test program, which
20 * generally cosists of several sets of tests. */
21static int total_err = 0, err = 0;
22
23#if 0
24/* This is handy for print statements. */
25static char *format_name[] = {"", "classic", "64-bit offset", "netCDF-4",
26                              "netCDF-4 classic model"};
27#endif
28
29/* This macro prints an error message with line number and name of
30 * test program. */
31#define ERR do { \
32fflush(stdout); /* Make sure our stdout is synced with stderr. */ \
33err++; \
34fprintf(stderr, "Sorry! Unexpected result, %s, line: %d\n", \
35        __FILE__, __LINE__);                                \
36return 2;                                                   \
37} while (0)
38
39/* This macro prints an error message with line number and name of
40 * test program, and then exits the program. */
41
42#define ERR_RET do { \
43fflush(stdout); /* Make sure our stdout is synced with stderr. */ \
44fprintf(stderr, "Sorry! Unexpected result, %s, line: %d\n", \
45        __FILE__, __LINE__);                                \
46return 2;                                                   \
47} while (0)
48
49/* After a set of tests, report the number of errors, and increment
50 * total_err. */
51#define SUMMARIZE_ERR do { \
52   if (err) \
53   { \
54      printf("%d failures\n", err); \
55      total_err += err; \
56      err = 0; \
57   } \
58   else \
59      printf("ok.\n"); \
60} while (0)
61
62/* If extra memory debugging is not in use (as it usually isn't),
63 * define away the nc_exit function, which may be in some tests. */
64#ifndef EXTRA_MEM_DEBUG
65#define nc_exit()
66#endif
67
68/* This macro prints out our total number of errors, if any, and exits
69 * with a 0 if there are not, or a 2 if there were errors. Make will
70 * stop if a non-zero value is returned from a test program. */
71#define FINAL_RESULTS do { \
72   if (total_err) \
73   { \
74      printf("%d errors detected! Sorry!\n", total_err); \
75      return 2; \
76   } \
77   printf("*** Tests successful!\n"); \
78   return 0; \
79} while (0)
80
81#endif /* _ERR_MACROS_H */
Note: See TracBrowser for help on using the repository browser.