testprogs: add win32 spoolss testsuite.
[ira/wip.git] / testprogs / win32 / spoolss / torture.h
1 /*
2    Unix SMB/CIFS implementation.
3    SMB torture UI functions
4
5    Copyright (C) Jelmer Vernooij 2006
6
7    This program is free software; you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation; either version 3 of the License, or
10    (at your option) any later version.
11
12    This program is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16
17    You should have received a copy of the GNU General Public License
18    along with this program.  If not, see <http://www.gnu.org/licenses/>.
19 */
20
21 #ifndef __TORTURE_UI_H__
22 #define __TORTURE_UI_H__
23
24 /****************************************************************************
25 ****************************************************************************/
26
27 enum torture_result {
28         TORTURE_OK=0,
29         TORTURE_FAIL=1,
30         TORTURE_ERROR=2,
31         TORTURE_SKIP=3
32 };
33
34 struct torture_context {
35         enum torture_result last_result;
36         char *last_reason;
37         BOOL print;
38 };
39
40 /****************************************************************************
41 ****************************************************************************/
42
43 #define torture_assert(torture_ctx,expr,cmt) do {\
44         if (!(expr)) {\
45                 torture_result(torture_ctx, TORTURE_FAIL, __location__": Expression `%s' failed: %s", __STRING(expr), cmt); \
46                 return false;\
47         }\
48 } while(0)
49
50 #define torture_assert_str_equal(torture_ctx,got,expected,cmt)\
51         do { const char *__got = (got), *__expected = (expected); \
52         if (strcmp_safe(__got, __expected) != 0) { \
53                 torture_result(torture_ctx, TORTURE_FAIL, \
54                         __location__": "#got" was %s, expected %s: %s", \
55                         __got, __expected, cmt); \
56                 return false; \
57         } \
58         } while(0)
59
60 #define torture_assert_int_equal(torture_ctx,got,expected,cmt)\
61         do { int __got = (got), __expected = (expected); \
62         if (__got != __expected) { \
63                 torture_result(torture_ctx, TORTURE_FAIL, \
64                         __location__": "#got" was %d, expected %d: %s", \
65                         __got, __expected, cmt); \
66                 return false; \
67         } \
68         } while(0)
69
70 #define torture_assert_mem_equal(torture_ctx,got,expected,len,cmt)\
71         do { const void *__got = (got), *__expected = (expected); \
72         if (memcmp(__got, __expected, len) != 0) { \
73                 torture_result(torture_ctx, TORTURE_FAIL, \
74                         __location__": "#got" of len %d did not match "#expected": %s", (int)len, cmt); \
75                 return false; \
76         } \
77         } while(0)
78
79 #define torture_skip(torture_ctx,cmt) do {\
80                 torture_result(torture_ctx, TORTURE_SKIP, __location__": %s", cmt);\
81                 return true; \
82         } while(0)
83
84 #define torture_fail(torture_ctx,cmt) do {\
85                 torture_result(torture_ctx, TORTURE_FAIL, __location__": %s", cmt);\
86                 return false; \
87         } while (0)
88
89 #include "torture_proto.h"
90
91 #endif