• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2004, Bull S.A..  All rights reserved.
3  * Created by: Sebastien Decugis
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms of version 2 of the GNU General Public License as
7  * published by the Free Software Foundation.
8  *
9  * This program is distributed in the hope that it would be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12  *
13  * You should have received a copy of the GNU General Public License along
14  * with this program; if not, write the Free Software Foundation, Inc.,
15  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
16  *
17  * This file is a wrapper to use the tests from the NPTL Test & Trace Project
18  * with either the Linux Test Project or the Open POSIX Test Suite.
19  *
20  * The following macros are defined here:
21  * UNRESOLVED(ret, descr);
22  *    where descr is a description of the error and ret is
23  *    an int (error code for example)
24  * FAILED(descr);
25  *    where descr is a short text saying why the test has failed.
26  * PASSED();
27  *    No parameter.
28  *
29  * Both three macros shall terminate the calling process.
30  * The testcase shall not terminate without calling one of those macros.
31  */
32 
33 #include "posixtest.h"
34 #include <string.h>
35 
36 #ifdef __GNUC__
37 
38 #define UNRESOLVED(x, s)						\
39 {									\
40 	output("Test %s unresolved: got %i (%s) on line %i (%s)\n",	\
41 		__FILE__, x, strerror(x), __LINE__, s);			\
42 	output_fini();							\
43 	exit(PTS_UNRESOLVED);						\
44 }
45 
46 #define FAILED(s)							\
47 {									\
48 	output("Test %s FAILED: %s\n", __FILE__, s);			\
49 	output_fini();							\
50 	exit(PTS_FAIL);							\
51 }
52 
53 #define PASSED								\
54 {									\
55 	output_fini();							\
56 	exit(PTS_PASS);							\
57 }
58 
59 #define UNTESTED(s)							\
60 {									\
61 	output("File %s cannot test: %s\n", __FILE__, s);		\
62 	output_fini();							\
63 	exit(PTS_UNTESTED);						\
64 }
65 
66 #else
67 
68 #define UNRESOLVED(x, s)						\
69 {									\
70 	output("Test unresolved: got %i (%s) on line %i (%s)\n",	\
71 		x, strerror(x), __LINE__, s);				\
72 	output_fini();							\
73 	exit(PTS_UNRESOLVED);						\
74 }
75 
76 #define FAILED(s)							\
77 {									\
78 	output("Test FAILED: %s\n", s);					\
79 	output_fini();							\
80 	exit(PTS_FAIL);							\
81 }
82 
83 #define PASSED								\
84 {									\
85 	output_fini();							\
86 	exit(PTS_PASS);							\
87 }
88 
89 #define UNTESTED(s)							\
90 {									\
91 	output("Unable to test: %s\n", s);				\
92 	output_fini();							\
93 	exit(PTS_UNTESTED);						\
94 }
95 
96 #endif
97