tests: Check error message in virnetdaemontest

This way we actually check for the proper error, not any error like invalid JSON
format.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Martin Kletzander 2023-01-02 16:26:31 +01:00
parent fd61d2df66
commit 1d625c5d25
3 changed files with 13 additions and 8 deletions

View File

@ -0,0 +1 @@
internal error: Server testServer1 was not created

View File

@ -0,0 +1 @@
internal error: Invalid auth_pending and auth combination in JSON state document

View File

@ -303,8 +303,8 @@ static int testExecRestart(const void *opaque)
infile = g_strdup_printf("%s/virnetdaemondata/input-data-%s.json", abs_srcdir,
data->jsonfile);
outfile = g_strdup_printf("%s/virnetdaemondata/output-data-%s.json",
abs_srcdir, data->jsonfile);
outfile = g_strdup_printf("%s/virnetdaemondata/output-data-%s.%s",
abs_srcdir, data->jsonfile, data->pass ? "json" : "err");
if (virFileReadAll(infile, 8192, &injsonstr) < 0)
goto cleanup;
@ -331,6 +331,9 @@ static int testExecRestart(const void *opaque)
if (!(outjson = virNetDaemonPreExecRestart(dmn)))
goto cleanup;
if (!data->pass)
goto cleanup;
if (!(outjsonstr = virJSONValueToString(outjson, true)))
goto cleanup;
@ -340,11 +343,11 @@ static int testExecRestart(const void *opaque)
ret = 0;
cleanup:
if (ret < 0) {
if (!data->pass) {
VIR_TEST_DEBUG("Got expected error: %s",
virGetLastErrorMessage());
if (injson && !data->pass) {
ret = virTestCompareToFile(virGetLastErrorMessage(), outfile);
if (ret < 0)
VIR_TEST_DEBUG("Test failed with different error message");
virResetLastError();
ret = 0;
}
} else if (!data->pass) {
VIR_TEST_DEBUG("Test should have failed");