spnego: add client option to omit sending an optimistic token
[Samba.git] / lib / tdb / test / tap-to-subunit.h
bloba5cf74fb046700ad7f7fa3bb63ec36bb221fff3f
1 #ifndef TAP_TO_SUBUNIT_H
2 #define TAP_TO_SUBUNIT_H
3 /*
4 * tap-style wrapper for subunit.
6 * Copyright (c) 2011 Rusty Russell
7 * All rights reserved.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE.
30 #include "replace.h"
32 /**
33 * plan_tests - announce the number of tests you plan to run
34 * @tests: the number of tests
36 * This should be the first call in your test program: it allows tracing
37 * of failures which mean that not all tests are run.
39 * If you don't know how many tests will actually be run, assume all of them
40 * and use skip() if you don't actually run some tests.
42 * Example:
43 * plan_tests(13);
45 void plan_tests(unsigned int tests);
47 /**
48 * ok1 - Simple conditional test
49 * @e: the expression which we expect to be true.
51 * This is the simplest kind of test: if the expression is true, the
52 * test passes. The name of the test which is printed will simply be
53 * file name, line number, and the expression itself.
55 * Example:
56 * ok1(somefunc() == 1);
58 # define ok1(e) ((e) ? \
59 _gen_result(1, __func__, __FILE__, __LINE__, "%s", #e) : \
60 _gen_result(0, __func__, __FILE__, __LINE__, "%s", #e))
62 /**
63 * ok - Conditional test with a name
64 * @e: the expression which we expect to be true.
65 * @...: the printf-style name of the test.
67 * If the expression is true, the test passes. The name of the test will be
68 * the filename, line number, and the printf-style string. This can be clearer
69 * than simply the expression itself.
71 * Example:
72 * ok1(somefunc() == 1);
73 * ok(somefunc() == 0, "Second somefunc() should fail");
75 # define ok(e, ...) ((e) ? \
76 _gen_result(1, __func__, __FILE__, __LINE__, \
77 __VA_ARGS__) : \
78 _gen_result(0, __func__, __FILE__, __LINE__, \
79 __VA_ARGS__))
81 /**
82 * pass - Note that a test passed
83 * @...: the printf-style name of the test.
85 * For complicated code paths, it can be easiest to simply call pass() in one
86 * branch and fail() in another.
88 * Example:
89 * int x = somefunc();
90 * if (x > 0)
91 * pass("somefunc() returned a valid value");
92 * else
93 * fail("somefunc() returned an invalid value");
95 # define pass(...) ok(1, __VA_ARGS__)
97 /**
98 * fail - Note that a test failed
99 * @...: the printf-style name of the test.
101 * For complicated code paths, it can be easiest to simply call pass() in one
102 * branch and fail() in another.
104 # define fail(...) ok(0, __VA_ARGS__)
106 unsigned int _gen_result(int, const char *, const char *, unsigned int,
107 const char *, ...) PRINTF_ATTRIBUTE(5, 6);
110 * diag - print a diagnostic message (use instead of printf/fprintf)
111 * @fmt: the format of the printf-style message
113 * diag ensures that the output will not be considered to be a test
114 * result by the TAP test harness. It will append '\n' for you.
116 * Example:
117 * diag("Now running complex tests");
119 void diag(const char *fmt, ...) PRINTF_ATTRIBUTE(1, 2);
122 * skip - print a diagnostic message (use instead of printf/fprintf)
123 * @n: number of tests you're skipping.
124 * @fmt: the format of the reason you're skipping the tests.
126 * Sometimes tests cannot be run because the test system lacks some feature:
127 * you should explicitly document that you're skipping tests using skip().
129 * From the Test::More documentation:
130 * If it's something the user might not be able to do, use SKIP. This
131 * includes optional modules that aren't installed, running under an OS that
132 * doesn't have some feature (like fork() or symlinks), or maybe you need an
133 * Internet connection and one isn't available.
135 * Example:
136 * #ifdef HAVE_SOME_FEATURE
137 * ok1(somefunc());
138 * #else
139 * skip(1, "Don't have SOME_FEATURE");
140 * #endif
142 void skip(unsigned int n, const char *fmt, ...) PRINTF_ATTRIBUTE(2, 3);
145 * exit_status - the value that main should return.
147 * For maximum compatibility your test program should return a particular exit
148 * code (ie. 0 if all tests were run, and every test which was expected to
149 * succeed succeeded).
151 * Example:
152 * exit(exit_status());
154 int exit_status(void);
155 #endif /* CCAN_TAP_H */