summaryrefslogtreecommitdiff
path: root/testprogs/win32/spoolss/torture.c
blob: ff2824a73746d16012d312d2053e8b975fed6f2e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/*
   Unix SMB/CIFS implementation.
   SMB torture UI functions

   Copyright (C) Jelmer Vernooij 2006

   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 3 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   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, see <http://www.gnu.org/licenses/>.
*/

#include "testspoolss.h"
#include "torture.h"

/****************************************************************************
****************************************************************************/

void torture_warning(struct torture_context *context, const char *comment, ...)
{
	va_list ap;
	char tmp[1024];

#if 0
	if (!context->results->ui_ops->warning)
		return;
#endif

	va_start(ap, comment);
	if (vsprintf(tmp, comment, ap) == -1) {
		return;
	}
	va_end(ap);

	fprintf(stderr, "WARNING: %s\n", tmp);
#if 0
	context->results->ui_ops->warning(context, tmp);

	free(tmp);
#endif
}

/****************************************************************************
****************************************************************************/

void torture_result(struct torture_context *context,
		    enum torture_result result, const char *fmt, ...)
{
	va_list ap;
	char tmp[1024];

	va_start(ap, fmt);

	if (context->last_reason) {
		torture_warning(context, "%s", context->last_reason);
		free(context->last_reason);
		context->last_reason = NULL;
	}

	context->last_result = result;
	if (vsprintf(tmp, fmt, ap) == -1) {
		return;
	}
	context->last_reason = malloc(sizeof(tmp));
	if (!context->last_reason) {
		return;
	}
	memcpy(context->last_reason, tmp, sizeof(tmp));

	va_end(ap);
}

/****************************************************************************
****************************************************************************/

void torture_comment(struct torture_context *context, const char *comment, ...)
{
	va_list ap;
	char tmp[1024];
#if 0
	if (!context->results->ui_ops->comment)
		return;
#endif
	va_start(ap, comment);
	if (vsprintf(tmp, comment, ap) == -1) {
		return;
	}
	va_end(ap);

#if 0
	context->results->ui_ops->comment(context, tmp);
#endif
	fprintf(stdout, "%s\n", tmp);

#if 0
	free(tmp);
#endif
}