mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 13:45:38 +00:00
commandtest: Fix test28 error detection
As a part of c799d150d5
I've introduced a test case that
tests whether passing error object between processes works. The
test spawns a child which reports a system error, parent process
then reads the error and compares with expected output. Problem
with this approach is that error message contains stringified
errno which is not portable. FreeBSD has generally different
messages than Linux. Therefore, use g_strerror() to do the errno
to string translation for us.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
parent
1b84dd190c
commit
1ac79d29eb
@ -1272,6 +1272,7 @@ test28(const void *unused G_GNUC_UNUSED)
|
|||||||
/* Not strictly a virCommand test, but this is the easiest place
|
/* Not strictly a virCommand test, but this is the easiest place
|
||||||
* to test this lower-level interface. */
|
* to test this lower-level interface. */
|
||||||
virErrorPtr err;
|
virErrorPtr err;
|
||||||
|
g_autofree char *msg = g_strdup_printf("some error message: %s", g_strerror(ENODATA));
|
||||||
|
|
||||||
if (virProcessRunInFork(test28Callback, NULL) != -1) {
|
if (virProcessRunInFork(test28Callback, NULL) != -1) {
|
||||||
fprintf(stderr, "virProcessRunInFork did not fail\n");
|
fprintf(stderr, "virProcessRunInFork did not fail\n");
|
||||||
@ -1285,10 +1286,10 @@ test28(const void *unused G_GNUC_UNUSED)
|
|||||||
|
|
||||||
if (!(err->code == VIR_ERR_SYSTEM_ERROR &&
|
if (!(err->code == VIR_ERR_SYSTEM_ERROR &&
|
||||||
err->domain == 0 &&
|
err->domain == 0 &&
|
||||||
STREQ(err->message, "some error message: No data available") &&
|
STREQ(err->message, msg) &&
|
||||||
err->level == VIR_ERR_ERROR &&
|
err->level == VIR_ERR_ERROR &&
|
||||||
STREQ(err->str1, "%s") &&
|
STREQ(err->str1, "%s") &&
|
||||||
STREQ(err->str2, "some error message: No data available") &&
|
STREQ(err->str2, msg) &&
|
||||||
err->int1 == ENODATA &&
|
err->int1 == ENODATA &&
|
||||||
err->int2 == -1)) {
|
err->int2 == -1)) {
|
||||||
fprintf(stderr, "Unexpected error object\n");
|
fprintf(stderr, "Unexpected error object\n");
|
||||||
|
Loading…
Reference in New Issue
Block a user