This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
+ the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __TORTURE_UI_H__
enum torture_result {
TORTURE_OK=0,
- TORTURE_FAIL=1,
- TORTURE_TODO=2,
+ TORTURE_FAIL=1,
+ TORTURE_ERROR=2,
TORTURE_SKIP=3
};
*/
struct torture_ui_ops
{
+ void (*init) (struct torture_context *);
void (*comment) (struct torture_context *, const char *);
+ void (*warning) (struct torture_context *, const char *);
void (*suite_start) (struct torture_context *, struct torture_suite *);
void (*suite_finish) (struct torture_context *, struct torture_suite *);
void (*tcase_start) (struct torture_context *, struct torture_tcase *);
enum torture_result, const char *reason);
};
+void torture_ui_test_start(struct torture_context *context,
+ struct torture_tcase *tcase,
+ struct torture_test *test);
+
+void torture_ui_test_result(struct torture_context *context,
+ enum torture_result result,
+ const char *comment);
+
/*
* Holds information about a specific run of the testsuite.
* The data in this structure should be considered private to
const struct torture_ui_ops *ui_ops;
void *ui_data;
+ char *active_testname;
struct torture_test *active_test;
struct torture_tcase *active_tcase;
- int skipped;
- int todo;
- int success;
- int failed;
-
bool quiet; /* Whether tests should avoid writing output to stdout */
enum torture_result last_result;
char *last_reason;
+ bool returncode;
+
char *outputdir;
int level;
+ struct event_context *ev;
};
/*
struct torture_tcase *tcase,
struct torture_test *test);
-void _torture_fail_ext(struct torture_context *test, const char *reason, ...) PRINTF_ATTRIBUTE(2,3);
void torture_comment(struct torture_context *test, const char *comment, ...) PRINTF_ATTRIBUTE(2,3);
-void _torture_skip_ext(struct torture_context *test, const char *reason, ...) PRINTF_ATTRIBUTE(2,3);
+void torture_warning(struct torture_context *test, const char *comment, ...) PRINTF_ATTRIBUTE(2,3);
+void torture_result(struct torture_context *test,
+ enum torture_result, const char *reason, ...) PRINTF_ATTRIBUTE(3,4);
#define torture_assert(torture_ctx,expr,cmt) \
if (!(expr)) { \
- torture_comment(torture_ctx, __location__": Expression `%s' failed\n", __STRING(expr)); \
- _torture_fail_ext(torture_ctx, __location__": %s", cmt); \
+ torture_result(torture_ctx, TORTURE_FAIL, __location__": Expression `%s' failed: %s", __STRING(expr), cmt); \
return false; \
}
#define torture_assert_werr_equal(torture_ctx, got, expected, cmt) \
do { WERROR __got = got, __expected = expected; \
if (!W_ERROR_EQUAL(__got, __expected)) { \
- torture_comment(torture_ctx, __location__": "#got" was %s, expected %s\n", \
- win_errstr(__got), win_errstr(__expected)); \
- _torture_fail_ext(torture_ctx, __location__": %s", cmt); \
+ torture_result(torture_ctx, TORTURE_FAIL, __location__": "#got" was %s, expected %s: %s", win_errstr(__got), win_errstr(__expected), cmt); \
return false; \
} \
} while (0)
#define torture_assert_ntstatus_equal(torture_ctx,got,expected,cmt) \
do { NTSTATUS __got = got, __expected = expected; \
if (!NT_STATUS_EQUAL(__got, __expected)) { \
- torture_comment(torture_ctx, __location__": "#got" was %s, expected %s\n", \
- nt_errstr(__got), nt_errstr(__expected)); \
- _torture_fail_ext(torture_ctx, __location__": %s", cmt); \
+ torture_result(torture_ctx, TORTURE_FAIL, __location__": "#got" was %s, expected %s: %s", nt_errstr(__got), nt_errstr(__expected), cmt); \
return false; \
}\
} while(0)
#define torture_assert_casestr_equal(torture_ctx,got,expected,cmt) \
do { const char *__got = (got), *__expected = (expected); \
if (!strequal(__got, __expected)) { \
- torture_comment(torture_ctx, __location__": "#got" was %s, expected %s\n", __got, __expected); \
- _torture_fail_ext(torture_ctx, __location__": %s", cmt); \
+ torture_result(torture_ctx, TORTURE_FAIL, __location__": "#got" was %s, expected %s: %s", __got, __expected, cmt); \
return false; \
} \
} while(0)
#define torture_assert_str_equal(torture_ctx,got,expected,cmt)\
do { const char *__got = (got), *__expected = (expected); \
if (strcmp_safe(__got, __expected) != 0) { \
- torture_comment(torture_ctx, __location__": "#got" was %s, expected %s\n", __got, __expected); \
- _torture_fail_ext(torture_ctx, __location__": %s", cmt); \
+ torture_result(torture_ctx, TORTURE_FAIL, \
+ __location__": "#got" was %s, expected %s: %s", \
+ __got, __expected, cmt); \
return false; \
} \
} while(0)
#define torture_assert_int_equal(torture_ctx,got,expected,cmt)\
do { int __got = (got), __expected = (expected); \
if (__got != __expected) { \
- torture_comment(torture_ctx, __location__": "#got" was %d, expected %d\n", __got, __expected); \
- _torture_fail_ext(torture_ctx, __location__": %s", cmt); \
+ torture_result(torture_ctx, TORTURE_FAIL, \
+ __location__": "#got" was %d, expected %d: %s", \
+ __got, __expected, cmt); \
+ return false; \
+ } \
+ } while(0)
+
+#define torture_assert_u64_equal(torture_ctx,got,expected,cmt)\
+ do { uint64_t __got = (got), __expected = (expected); \
+ if (__got != __expected) { \
+ torture_result(torture_ctx, TORTURE_FAIL, \
+ __location__": "#got" was %llu, expected %llu: %s", \
+ (unsigned long long)__got, (unsigned long long)__expected, cmt); \
return false; \
} \
} while(0)
#define torture_assert_errno_equal(torture_ctx,expected,cmt)\
do { int __expected = (expected); \
if (errno != __expected) { \
- torture_comment(torture_ctx, __location__": errno was %d, expected %s\n", errno, strerror(__expected)); \
- _torture_fail_ext(torture_ctx, __location__": %s", cmt); \
+ torture_result(torture_ctx, TORTURE_FAIL, \
+ __location__": errno was %d (%s), expected %d: %s: %s", \
+ errno, strerror(errno), __expected, \
+ strerror(__expected), cmt); \
return false; \
} \
} while(0)
#define torture_skip(torture_ctx,cmt) do {\
- _torture_skip_ext(torture_ctx, __location__": %s", cmt);\
+ torture_result(torture_ctx, TORTURE_SKIP, __location__": %s", cmt);\
return true; \
} while(0)
#define torture_fail(torture_ctx,cmt) do {\
- _torture_fail_ext(torture_ctx, __location__": %s", cmt);\
+ torture_result(torture_ctx, TORTURE_FAIL, __location__": %s", cmt);\
return false; \
} while (0)
+#define torture_fail_goto(torture_ctx,label,cmt) do {\
+ torture_result(torture_ctx, TORTURE_FAIL, __location__": %s", cmt);\
+ goto label; \
+ } while (0)
#define torture_out stderr
const char *name,
bool default_value);
-/* Helper function commonly used */
-bool torture_teardown_free(struct torture_context *torture, void *data);
+struct torture_suite *torture_find_suite(struct torture_suite *parent,
+ const char *name);
+
#endif /* __TORTURE_UI_H__ */