Commit 72c55b03 authored by Rusty Russell's avatar Rusty Russell

const addition changes from brian, awfulhak.org

parent 1c1a74f4
......@@ -16,9 +16,9 @@ their success or failure.
.Ss PRINTF STRINGS
In the descriptions that follow, for any function that takes as the
last two parameters
.Dq Fa char * , Fa ...
.Dq Fa const char * , Fa ...
it can be assumed that the
.Fa char *
.Fa const char *
is a
.Fn printf
-like format string, and the optional arguments are values to be placed
......@@ -35,7 +35,7 @@ in that string.
.Xc
.It Xo
.Ft void
.Fn plan_skip_all "char *" "..."
.Fn plan_skip_all "const char *" "..."
.Xc
.El
.Pp
......@@ -74,7 +74,7 @@ the tests.
.Bl -tag -width indent
.It Xo
.Ft unsigned int
.Fn ok "expression" "char *" "..."
.Fn ok "expression" "const char *" "..."
.Xc
.It Xo
.Ft unsigned int
......@@ -82,11 +82,11 @@ the tests.
.Xc
.It Xo
.Ft unsigned int
.Fn pass "char *" "..."
.Fn pass "const char *" "..."
.Xc
.It Xo
.Ft unsigned int
.Fn fail "char *" "..."
.Fn fail "const char *" "..."
.Xc
.El
.Pp
......@@ -161,10 +161,10 @@ These are synonyms for ok(1, ...) and ok(0, ...).
.Bl -tag -width indent
.It Xo
.Ft void
.Fn skip "unsigned int" "char *" "..."
.Fn skip "unsigned int" "const char *" "..."
.Xc
.It Xo
.Fn skip_if "expression" "unsigned int" "char *" "..."
.Fn skip_if "expression" "unsigned int" "const char *" "..."
.Xc
.El
.Pp
......@@ -204,7 +204,7 @@ skip_if(getuid() != 0, 1, "because test only works as root") {
.Bl -tag -width indent
.It Xo
.Ft void
.Fn todo_start "char *" "..."
.Fn todo_start "const char *" "..."
.Xc
.It Xo
.Ft void
......@@ -261,8 +261,8 @@ yet to fix, but want to put tests in your testing script
.Ss DIAGNOSTIC OUTPUT
.Bl -tag -width indent
.It Xo
.Fr void
.Fn diag "char *" "..."
.Fr int
.Fn diag "const char *" "..."
.Xc
.El
.Pp
......@@ -273,6 +273,7 @@ It ensures that the output will not be considered by the TAP test harness.
adds the necessary trailing
.Dq \en
for you.
It returns the number of characters written.
.Bd -literal -offset indent
diag("Expected return code 0, got return code %d", rcode);
.Ed
......
......@@ -42,7 +42,7 @@ static unsigned int test_count = 0; /* Number of tests that have been run */
static unsigned int e_tests = 0; /* Expected number of tests to run */
static unsigned int failures = 0; /* Number of tests that failed */
static char *todo_msg = NULL;
static char *todo_msg_fixed = "libtap malloc issue";
static const char *todo_msg_fixed = "libtap malloc issue";
static int todo = 0;
static int test_died = 0;
static int test_pid;
......@@ -68,7 +68,7 @@ _expected_tests(unsigned int tests)
}
static void
diagv(char *fmt, va_list ap)
diagv(const char *fmt, va_list ap)
{
fputs("# ", stdout);
vfprintf(stdout, fmt, ap);
......@@ -76,7 +76,7 @@ diagv(char *fmt, va_list ap)
}
static void
_diag(char *fmt, ...)
_diag(const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
......@@ -92,8 +92,8 @@ _diag(char *fmt, ...)
* test_comment -- a comment to print afterwards, may be NULL
*/
unsigned int
_gen_result(int ok, const char *func, char *file, unsigned int line,
char *test_name, ...)
_gen_result(int ok, const char *func, const char *file, unsigned int line,
const char *test_name, ...)
{
va_list ap;
char *local_test_name = NULL;
......@@ -293,7 +293,7 @@ plan_no_plan(void)
* Note that the plan is to skip all tests
*/
void
plan_skip_all(char *reason)
plan_skip_all(const char *reason)
{
LOCK;
......@@ -345,7 +345,7 @@ plan_tests(unsigned int tests)
}
void
diag(char *fmt, ...)
diag(const char *fmt, ...)
{
va_list ap;
......@@ -359,7 +359,7 @@ diag(char *fmt, ...)
}
void
skip(unsigned int n, char *fmt, ...)
skip(unsigned int n, const char *fmt, ...)
{
va_list ap;
char *skip_msg;
......@@ -384,7 +384,7 @@ skip(unsigned int n, char *fmt, ...)
}
void
todo_start(char *fmt, ...)
todo_start(const char *fmt, ...)
{
va_list ap;
......
......@@ -124,8 +124,8 @@ void plan_tests(unsigned int tests);
#endif
#endif
unsigned int _gen_result(int, const char *, char *, unsigned int, char *, ...)
PRINTF_ATTRIBUTE(5, 6);
unsigned int _gen_result(int, const char *, const char *, unsigned int,
const char *, ...) PRINTF_ATTRIBUTE(5, 6);
/**
* diag - print a diagnostic message (use instead of printf/fprintf)
......@@ -137,7 +137,7 @@ unsigned int _gen_result(int, const char *, char *, unsigned int, char *, ...)
* Example:
* diag("Now running complex tests");
*/
void diag(char *fmt, ...) PRINTF_ATTRIBUTE(1, 2);
void diag(const char *fmt, ...) PRINTF_ATTRIBUTE(1, 2);
/**
* skip - print a diagnostic message (use instead of printf/fprintf)
......@@ -160,7 +160,7 @@ void diag(char *fmt, ...) PRINTF_ATTRIBUTE(1, 2);
* skip(1, "Don't have SOME_FEATURE");
* #endif
*/
void skip(unsigned int n, char *fmt, ...) PRINTF_ATTRIBUTE(2, 3);
void skip(unsigned int n, const char *fmt, ...) PRINTF_ATTRIBUTE(2, 3);
/**
* todo_start - mark tests that you expect to fail.
......@@ -185,7 +185,7 @@ void skip(unsigned int n, char *fmt, ...) PRINTF_ATTRIBUTE(2, 3);
* ok(dwim(), "Did what the user wanted");
* todo_end();
*/
void todo_start(char *fmt, ...) PRINTF_ATTRIBUTE(1, 2);
void todo_start(const char *fmt, ...) PRINTF_ATTRIBUTE(1, 2);
/**
* todo_end - end of tests you expect to fail.
......@@ -241,6 +241,6 @@ void plan_no_plan(void);
* }
* plan_tests(13);
*/
void plan_skip_all(char *reason);
void plan_skip_all(const char *reason);
#endif /* C99 or gcc */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment