TORTURE_SKIP=3
};
+enum torture_progress_whence {
+ TORTURE_PROGRESS_SET,
+ TORTURE_PROGRESS_CUR,
+ TORTURE_PROGRESS_POP,
+ TORTURE_PROGRESS_PUSH,
+};
+
/*
* These callbacks should be implemented by any backend that wishes
* to listen to reports from the torture tests.
struct torture_test *);
void (*test_result) (struct torture_context *,
enum torture_result, const char *reason);
+ void (*progress) (struct torture_context *, int offset, enum torture_progress_whence whence);
+ void (*report_time) (struct torture_context *);
};
void torture_ui_test_start(struct torture_context *context,
enum torture_result result,
const char *comment);
+void torture_ui_report_time(struct torture_context *context);
+
/*
* Holds information about a specific run of the testsuite.
* The data in this structure should be considered private to
{
struct torture_results *results;
- char *active_testname;
struct torture_test *active_test;
struct torture_tcase *active_tcase;
/** Directory used for temporary test data */
const char *outputdir;
-
- /** Indentation level */
- int level;
/** Event context */
- struct event_context *ev;
+ struct tevent_context *ev;
/** Loadparm context (will go away in favor of torture_setting_ at some point) */
struct loadparm_context *lp_ctx;
bool torture_run_suite(struct torture_context *context,
struct torture_suite *suite);
+/* Run the specified testsuite recursively, but only the specified
+ * tests */
+bool torture_run_suite_restricted(struct torture_context *context,
+ struct torture_suite *suite, const char **restricted);
+
/* Run the specified testcase */
bool torture_run_tcase(struct torture_context *context,
struct torture_tcase *tcase);
+bool torture_run_tcase_restricted(struct torture_context *context,
+ struct torture_tcase *tcase, const char **restricted);
+
/* Run the specified test */
bool torture_run_test(struct torture_context *context,
struct torture_tcase *tcase,
struct torture_test *test);
+bool torture_run_test_restricted(struct torture_context *context,
+ struct torture_tcase *tcase,
+ struct torture_test *test,
+ const char **restricted);
+
void torture_comment(struct torture_context *test, const char *comment, ...) 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,
return false; \
}
+#define torture_assert_goto(torture_ctx,expr,ret,label,cmt) \
+ if (!(expr)) { \
+ torture_result(torture_ctx, TORTURE_FAIL, __location__": Expression `%s' failed: %s", __STRING(expr), cmt); \
+ ret = false; \
+ goto label; \
+ }
+
#define torture_assert_werr_equal(torture_ctx, got, expected, cmt) \
do { WERROR __got = got, __expected = expected; \
if (!W_ERROR_EQUAL(__got, __expected)) { \
}\
} while(0)
+#define torture_assert_ntstatus_equal_goto(torture_ctx,got,expected,ret,label,cmt) \
+ do { NTSTATUS __got = got, __expected = expected; \
+ if (!NT_STATUS_EQUAL(__got, __expected)) { \
+ torture_result(torture_ctx, TORTURE_FAIL, __location__": "#got" was %s, expected %s: %s", nt_errstr(__got), nt_errstr(__expected), cmt); \
+ ret = false; \
+ goto label; \
+ }\
+ } while(0)
+
#define torture_assert_ndr_err_equal(torture_ctx,got,expected,cmt) \
do { enum ndr_err_code __got = got, __expected = expected; \
if (__got != __expected) { \
} \
} while(0)
+#define torture_assert_strn_equal(torture_ctx,got,expected,len,cmt)\
+ do { const char *__got = (got), *__expected = (expected); \
+ if (strncmp(__got, __expected, len) != 0) { \
+ torture_result(torture_ctx, TORTURE_FAIL, \
+ __location__": "#got" %s of len %d did not match "#expected" %s: %s", \
+ __got, (int)len, __expected, cmt); \
+ return false; \
+ } \
+ } while(0)
+
+#define torture_assert_str_equal_goto(torture_ctx,got,expected,ret,label,cmt)\
+ do { const char *__got = (got), *__expected = (expected); \
+ if (strcmp_safe(__got, __expected) != 0) { \
+ torture_result(torture_ctx, TORTURE_FAIL, \
+ __location__": "#got" was %s, expected %s: %s", \
+ __got, __expected, cmt); \
+ ret = false; \
+ goto label; \
+ } \
+ } while(0)
+
#define torture_assert_mem_equal(torture_ctx,got,expected,len,cmt)\
do { const void *__got = (got), *__expected = (expected); \
if (memcmp(__got, __expected, len) != 0) { \
torture_result(torture_ctx, TORTURE_FAIL, \
- __location__": "#got" of len %d did not match"#expected": %s", (int)len, cmt); \
+ __location__": "#got" of len %d did not match "#expected": %s", (int)len, cmt); \
return false; \
} \
} while(0)
} \
if (memcmp(__got.data, __expected.data, __got.length) != 0) { \
torture_result(torture_ctx, TORTURE_FAIL, \
- __location__": "#got" of len %d did not match"#expected": %s", (int)__got.length, cmt); \
+ __location__": "#got" of len %d did not match "#expected": %s", (int)__got.length, cmt); \
return false; \
} \
} while(0)
do { int __got = (got), __expected = (expected); \
if (__got != __expected) { \
torture_result(torture_ctx, TORTURE_FAIL, \
- __location__": "#got" was %d, expected %d: %s", \
- __got, __expected, cmt); \
+ __location__": "#got" was %d (0x%X), expected %d (0x%X): %s", \
+ __got, __got, __expected, __expected, cmt); \
return false; \
} \
} while(0)
+#define torture_assert_int_equal_goto(torture_ctx,got,expected,ret,label,cmt)\
+ do { int __got = (got), __expected = (expected); \
+ if (__got != __expected) { \
+ torture_result(torture_ctx, TORTURE_FAIL, \
+ __location__": "#got" was %d (0x%X), expected %d (0x%X): %s", \
+ __got, __got, __expected, __expected, cmt); \
+ ret = false; \
+ goto label; \
+ } \
+ } 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); \
+ __location__": "#got" was %llu (0x%llX), expected %llu (0x%llX): %s", \
+ (unsigned long long)__got, (unsigned long long)__got, \
+ (unsigned long long)__expected, (unsigned long long)__expected, \
+ cmt); \
return false; \
} \
} while(0)
+#define torture_assert_u64_equal_goto(torture_ctx,got,expected,ret,label,cmt)\
+ do { uint64_t __got = (got), __expected = (expected); \
+ if (__got != __expected) { \
+ torture_result(torture_ctx, TORTURE_FAIL, \
+ __location__": "#got" was %llu (0x%llX), expected %llu (0x%llX): %s", \
+ (unsigned long long)__got, (unsigned long long)__got, \
+ (unsigned long long)__expected, (unsigned long long)__expected, \
+ cmt); \
+ ret = false; \
+ goto label; \
+ } \
+ } while(0)
+
#define torture_assert_errno_equal(torture_ctx,expected,cmt)\
do { int __expected = (expected); \
if (errno != __expected) { \
} \
} while(0)
-
+#define torture_assert_nttime_equal(torture_ctx,got,expected,cmt) \
+ do { NTTIME __got = got, __expected = expected; \
+ if (!nt_time_equal(&__got, &__expected)) { \
+ torture_result(torture_ctx, TORTURE_FAIL, __location__": "#got" was %s, expected %s: %s", nt_time_string(tctx, __got), nt_time_string(tctx, __expected), cmt); \
+ return false; \
+ }\
+ } while(0)
#define torture_skip(torture_ctx,cmt) do {\
torture_result(torture_ctx, TORTURE_SKIP, __location__": %s", cmt);\
return true; \
} while(0)
+#define torture_skip_goto(torture_ctx,label,cmt) do {\
+ torture_result(torture_ctx, TORTURE_SKIP, __location__": %s", cmt);\
+ goto label; \
+ } while(0)
#define torture_fail(torture_ctx,cmt) do {\
torture_result(torture_ctx, TORTURE_FAIL, __location__": %s", cmt);\
return false; \
#define torture_assert_ntstatus_ok(torture_ctx,expr,cmt) \
torture_assert_ntstatus_equal(torture_ctx,expr,NT_STATUS_OK,cmt)
+#define torture_assert_ntstatus_ok_goto(torture_ctx,expr,ret,label,cmt) \
+ torture_assert_ntstatus_equal_goto(torture_ctx,expr,NT_STATUS_OK,ret,label,cmt)
+
#define torture_assert_werr_ok(torture_ctx,expr,cmt) \
torture_assert_werr_equal(torture_ctx,expr,WERR_OK,cmt)
struct torture_suite *torture_find_suite(struct torture_suite *parent,
const char *name);
+unsigned long torture_setting_ulong(struct torture_context *test,
+ const char *name,
+ unsigned long default_value);
+
NTSTATUS torture_temp_dir(struct torture_context *tctx,
const char *prefix,
char **tempdir);
+NTSTATUS torture_deltree_outputdir(struct torture_context *tctx);
struct torture_test *torture_tcase_add_simple_test(struct torture_tcase *tcase,
const char *name,
bool torture_suite_init_tcase(struct torture_suite *suite,
struct torture_tcase *tcase,
const char *name);
+int torture_suite_children_count(const struct torture_suite *suite);
-struct torture_context *torture_context_init(struct event_context *event_ctx, struct torture_results *results);
+struct torture_context *torture_context_init(struct tevent_context *event_ctx, struct torture_results *results);
struct torture_results *torture_results_init(TALLOC_CTX *mem_ctx, const struct torture_ui_ops *ui_ops);