s3: use monotonic clock for time deltas in namequery functions
[Samba/ita.git] / lib / torture / subunit.c
blob86b3dd0e60c460741d094996f223d073912a8da8
1 /*
2 Unix SMB/CIFS implementation.
3 Samba utility functions
4 Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2008
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #include "includes.h"
21 #include "lib/torture/torture.h"
23 static void subunit_suite_start(struct torture_context *ctx,
24 struct torture_suite *suite)
28 static void subunit_print_testname(struct torture_context *ctx,
29 struct torture_tcase *tcase,
30 struct torture_test *test)
32 if (!strcmp(tcase->name, test->name)) {
33 printf("%s", test->name);
34 } else {
35 printf("%s.%s", tcase->name, test->name);
39 static void subunit_test_start(struct torture_context *ctx,
40 struct torture_tcase *tcase,
41 struct torture_test *test)
43 printf("test: ");
44 subunit_print_testname(ctx, tcase, test);
45 printf("\n");
48 static void subunit_test_result(struct torture_context *context,
49 enum torture_result res, const char *reason)
51 switch (res) {
52 case TORTURE_OK:
53 printf("success: ");
54 break;
55 case TORTURE_FAIL:
56 printf("failure: ");
57 break;
58 case TORTURE_ERROR:
59 printf("error: ");
60 break;
61 case TORTURE_SKIP:
62 printf("skip: ");
63 break;
65 subunit_print_testname(context, context->active_tcase, context->active_test);
67 if (reason)
68 printf(" [\n%s\n]", reason);
69 printf("\n");
72 static void subunit_comment(struct torture_context *test,
73 const char *comment)
75 fprintf(stderr, "%s", comment);
78 static void subunit_warning(struct torture_context *test,
79 const char *comment)
81 fprintf(stderr, "WARNING!: %s\n", comment);
84 static void subunit_progress(struct torture_context *tctx, int offset, enum torture_progress_whence whence)
86 switch (whence) {
87 case TORTURE_PROGRESS_SET:
88 printf("progress: %d\n", offset);
89 break;
90 case TORTURE_PROGRESS_CUR:
91 printf("progress: %+-d\n", offset);
92 break;
93 case TORTURE_PROGRESS_POP:
94 printf("progress: pop\n");
95 break;
96 case TORTURE_PROGRESS_PUSH:
97 printf("progress: push\n");
98 break;
99 default:
100 fprintf(stderr, "Invalid call to progress()\n");
101 break;
105 const struct torture_ui_ops torture_subunit_ui_ops = {
106 .comment = subunit_comment,
107 .warning = subunit_warning,
108 .test_start = subunit_test_start,
109 .test_result = subunit_test_result,
110 .suite_start = subunit_suite_start,
111 .progress = subunit_progress,