2 * This library is free software; you can redistribute it and/or
3 * modify it under the terms of the GNU Lesser General Public
4 * License as published by the Free Software Foundation; either
5 * version 2.1 of the License, or (at your option) any later version.
7 * This library is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10 * Lesser General Public License for more details.
12 * You should have received a copy of the GNU Lesser General Public
13 * License along with this library; If not, see
14 * <http://www.gnu.org/licenses/>.
19 #include "testutils.h"
21 #define LIBVIRT_VIRERRORPRIV_H_ALLOW
22 #include "virerrorpriv.h"
23 #undef LIBVIRT_VIRERRORPRIV_H_ALLOW
26 virErrorTestMsgFormatInfoOne(const char *msg
)
32 for (next
= (char *)msg
; (next
= strchr(next
, '%')); next
++) {
34 VIR_TEST_VERBOSE("\nerror message '%s' contains disallowed printf modifiers\n", msg
);
38 VIR_TEST_VERBOSE("\nerror message '%s' contains multiple %%s modifiers\n", msg
);
47 VIR_TEST_VERBOSE("\nerror message '%s' does not contain any %%s modifiers\n", msg
);
56 virErrorTestMsgs(const void *opaque ATTRIBUTE_UNUSED
)
58 const char *err_noinfo
;
63 for (i
= 1; i
< VIR_ERR_NUMBER_LAST
; i
++) {
64 err_noinfo
= virErrorMsg(i
, NULL
);
65 err_info
= virErrorMsg(i
, "");
68 VIR_TEST_VERBOSE("\nmissing string without info for error id %zu\n", i
);
73 VIR_TEST_VERBOSE("\nmissing string with info for error id %zu\n", i
);
77 if (err_noinfo
&& strchr(err_noinfo
, '%')) {
78 VIR_TEST_VERBOSE("\nerror message id %zu contains formatting characters: '%s'\n",
83 if (err_info
&& virErrorTestMsgFormatInfoOne(err_info
) < 0)
96 if (virTestRun("error message strings ", virErrorTestMsgs
, NULL
) < 0)
99 return ret
== 0 ? EXIT_SUCCESS
: EXIT_FAILURE
;
102 VIR_TEST_MAIN(mymain
)