projects
/
ccan
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
compiler, talloc, tap, tdb2: use #if instead of #ifdef.
[ccan]
/
ccan
/
tap
/
tap.h
diff --git
a/ccan/tap/tap.h
b/ccan/tap/tap.h
index 8c961983555dc4869ba0f6ebd11e79b3c86d0a8a..2c309740f9286e8d6d72c514f656ff799025524a 100644
(file)
--- a/
ccan/tap/tap.h
+++ b/
ccan/tap/tap.h
@@
-53,7
+53,7
@@
void plan_tests(unsigned int tests);
* file name, line number, and the expression itself.
*
* Example:
* file name, line number, and the expression itself.
*
* Example:
- * ok1(
init_subsystem
() == 1);
+ * ok1(
somefunc
() == 1);
*/
# define ok1(e) ((e) ? \
_gen_result(1, __func__, __FILE__, __LINE__, "%s", #e) : \
*/
# define ok1(e) ((e) ? \
_gen_result(1, __func__, __FILE__, __LINE__, "%s", #e) : \
@@
-69,8
+69,8
@@
void plan_tests(unsigned int tests);
* than simply the expression itself.
*
* Example:
* than simply the expression itself.
*
* Example:
- * ok1(
init_subsystem
() == 1);
- * ok(
init_subsystem() == 0, "Second initialization
should fail");
+ * ok1(
somefunc
() == 1);
+ * ok(
somefunc() == 0, "Second somefunc()
should fail");
*/
# define ok(e, ...) ((e) ? \
_gen_result(1, __func__, __FILE__, __LINE__, \
*/
# define ok(e, ...) ((e) ? \
_gen_result(1, __func__, __FILE__, __LINE__, \
@@
-86,11
+86,11
@@
void plan_tests(unsigned int tests);
* branch and fail() in another.
*
* Example:
* branch and fail() in another.
*
* Example:
- *
x = do_something
();
- * if (
!checkable(x) || check_value(x)
)
- * pass("
do_something
() returned a valid value");
+ *
int x = somefunc
();
+ * if (
x > 0
)
+ * pass("
somefunc
() returned a valid value");
* else
* else
- * fail("
do_something
() returned an invalid value");
+ * fail("
somefunc
() returned an invalid value");
*/
# define pass(...) ok(1, __VA_ARGS__)
*/
# define pass(...) ok(1, __VA_ARGS__)
@@
-118,7
+118,7
@@
void plan_tests(unsigned int tests);
# define skip_end } while(0)
unsigned int _gen_result(int, const char *, const char *, unsigned int,
# define skip_end } while(0)
unsigned int _gen_result(int, const char *, const char *, unsigned int,
- const char *, ...) PRINTF_
ATTRIBUTE
(5, 6);
+ const char *, ...) PRINTF_
FMT
(5, 6);
/**
* diag - print a diagnostic message (use instead of printf/fprintf)
/**
* diag - print a diagnostic message (use instead of printf/fprintf)
@@
-130,7
+130,7
@@
unsigned int _gen_result(int, const char *, const char *, unsigned int,
* Example:
* diag("Now running complex tests");
*/
* Example:
* diag("Now running complex tests");
*/
-void diag(const char *fmt, ...) PRINTF_
ATTRIBUTE
(1, 2);
+void diag(const char *fmt, ...) PRINTF_
FMT
(1, 2);
/**
* skip - print a diagnostic message (use instead of printf/fprintf)
/**
* skip - print a diagnostic message (use instead of printf/fprintf)
@@
-148,12
+148,12
@@
void diag(const char *fmt, ...) PRINTF_ATTRIBUTE(1, 2);
*
* Example:
* #ifdef HAVE_SOME_FEATURE
*
* Example:
* #ifdef HAVE_SOME_FEATURE
- * ok1(
test_some_feature
());
+ * ok1(
somefunc
());
* #else
* skip(1, "Don't have SOME_FEATURE");
* #endif
*/
* #else
* skip(1, "Don't have SOME_FEATURE");
* #endif
*/
-void skip(unsigned int n, const char *fmt, ...) PRINTF_
ATTRIBUTE
(2, 3);
+void skip(unsigned int n, const char *fmt, ...) PRINTF_
FMT
(2, 3);
/**
* todo_start - mark tests that you expect to fail.
/**
* todo_start - mark tests that you expect to fail.
@@
-174,11
+174,16
@@
void skip(unsigned int n, const char *fmt, ...) PRINTF_ATTRIBUTE(2, 3);
* put tests in your testing script (always a good idea).
*
* Example:
* put tests in your testing script (always a good idea).
*
* Example:
+ * static bool dwim(void)
+ * {
+ * return false; // NYI
+ * }
+ * ...
* todo_start("dwim() not returning true yet");
* ok(dwim(), "Did what the user wanted");
* todo_end();
*/
* todo_start("dwim() not returning true yet");
* ok(dwim(), "Did what the user wanted");
* todo_end();
*/
-void todo_start(const char *fmt, ...) PRINTF_
ATTRIBUTE
(1, 2);
+void todo_start(const char *fmt, ...) PRINTF_
FMT
(1, 2);
/**
* todo_end - end of tests you expect to fail.
/**
* todo_end - end of tests you expect to fail.
@@
-190,7
+195,7
@@
void todo_end(void);
/**
* exit_status - the value that main should return.
*
/**
* exit_status - the value that main should return.
*
- * For maximum compat
a
bility your test program should return a particular exit
+ * For maximum compat
i
bility your test program should return a particular exit
* code (ie. 0 if all tests were run, and every test which was expected to
* succeed succeeded).
*
* code (ie. 0 if all tests were run, and every test which was expected to
* succeed succeeded).
*
@@
-213,7
+218,7
@@
int exit_status(void);
* Example:
* plan_no_plan();
* while (random() % 2)
* Example:
* plan_no_plan();
* while (random() % 2)
- * ok1(some
_test
());
+ * ok1(some
func
());
* exit(exit_status());
*/
void plan_no_plan(void);
* exit(exit_status());
*/
void plan_no_plan(void);
@@
-228,12
+233,21
@@
void plan_no_plan(void);
* in the running kernel) use plan_skip_all() instead of plan_tests().
*
* Example:
* in the running kernel) use plan_skip_all() instead of plan_tests().
*
* Example:
- *
if (!have_some_feature) {
- *
plan_skip_all("Need some_feature
support");
- *
exit(exit_status());
- *
}
+ *
#ifndef HAVE_SOME_FEATURE
+ *
plan_skip_all("Need SOME_FEATURE
support");
+ * exit(exit_status());
+ *
#else
* plan_tests(13);
* plan_tests(13);
+ * ...
+ * #endif
*/
void plan_skip_all(const char *reason);
*/
void plan_skip_all(const char *reason);
+/**
+ * tap_fail_callback - function to call when we fail
+ *
+ * This can be used to ease debugging, or exit on the first failure.
+ */
+void (*tap_fail_callback)(void);
+
#endif /* C99 or gcc */
#endif /* C99 or gcc */