tzh
2024-08-22 c7d0944258c7d0943aa7b2211498fd612971ce27
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/*
 * Copyright (c) 2016 Linux Test Project
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of version 2 of the GNU General Public License as
 * published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it would be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 *
 * You should have received a copy of the GNU General Public License
 * alone with this program.
 */
 
#ifndef __SAFE_HELPERS_H__
#define __SAFE_HELPERS_H__
 
#include <stdio.h>
#include <string.h>
 
#define SAFE_PFUNC(op) \
do {\
   int ret = (op); \
   if (ret != 0) { \
       printf("Test %s unresolved: got %i (%s) on line %i\n  %s\n", \
           __FILE__, ret, strerror(ret), __LINE__, #op); \
       fflush(stdout); \
       exit(PTS_UNRESOLVED); \
   } \
} while (0)
 
#define SAFE_FUNC(op) \
({ \
   int ret = (op); \
   if (ret == -1) { \
       printf("Test %s unresolved: got %i (%s) on line %i\n  %s\n", \
           __FILE__, ret, strerror(errno), __LINE__, #op); \
       fflush(stdout); \
       exit(PTS_UNRESOLVED); \
   } \
   ret; \
})
 
#endif