From nobody Mon Feb 9 01:31:01 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1587655359; cv=none; d=zohomail.com; s=zohoarc; b=JD87FlBDsUrH6SFjxdooHkfBPthwucIzmbycj1QinmzB5F3irvCRZ02ehN96IhMl75AGPqO3JOMyRB1tDIvSoRy6sLVjebwucccRd0KSDyNyoqUrfa/cl6iwmP7noOXia+WSU+60ZnW289DkhszJyEFFYvbzCC9ry+t/WfRUv18= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1587655359; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=dSfi4KdxOYkdPXR70iklXWrGWtNx/aLYlzvSVny9LcU=; b=NibkvxKWNSMcbtCc1V+2yVk7ZG3BmfP8NfZOxsjDQkvBZhtzNPkGX4GwvUFps2S8afL2cuESoroP6NtP8tDEj/R/TS7ry+Q0NN2/s0OoX6b8HiIGLznk8YNUGzwENxAzJpQ8d+B1r59WGD5bYjqu1stOCyaRLH/VHE7+W/K/QVg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1587655359808303.6703331045877; Thu, 23 Apr 2020 08:22:39 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-112-PIKzp90BNxmqsSBMkPCdgw-1; Thu, 23 Apr 2020 11:22:32 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A33311054F94; Thu, 23 Apr 2020 15:22:25 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 791625D70A; Thu, 23 Apr 2020 15:22:25 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 2921B4CAAE; Thu, 23 Apr 2020 15:22:25 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 03NFMDob010433 for ; Thu, 23 Apr 2020 11:22:13 -0400 Received: by smtp.corp.redhat.com (Postfix) id ACC8560E1C; Thu, 23 Apr 2020 15:22:13 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.40.208.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 19C9C60C81 for ; Thu, 23 Apr 2020 15:22:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587655358; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=dSfi4KdxOYkdPXR70iklXWrGWtNx/aLYlzvSVny9LcU=; b=IBiUWhtPu0+4wEcvh/DgobjRNKtswOeOAjiYizODwLdAJLEcyuoSKE0CFIJIWfrg6SGqVo FCg8EpXSmG3sQ2GnPC3mzQqGI5QOk+XrI2yNlOTYXrmS7OvX7SPnI6QMvcnASgtRi8BBem xMf2BC7hli+GrzrPfRk8ZzFY/ROKn0I= X-MC-Unique: PIKzp90BNxmqsSBMkPCdgw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 4/8] qemumonitortestutils: Make test monitor failures more prominent Date: Thu, 23 Apr 2020 17:22:01 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Until now we've tried to report errors from the test monitor code by passing them back as failures from the qemu we simulate. This doesn't work well in cases when the monitor logic does not detect failures or has fallback code. Additionally there isn't much use for continuing the test execution after first failure as in most cases the test data will be misaligned and all other calls will fail as well. To make the errors more obvious this patch moves away from reporting them via the simulated monitor to reporting them to stderr and exit()ing afterwards. While this might be less convenient when developing tests it actually makes failures in the test suite really obvious and doesn't require any opt-in from the tests themselves. Signed-off-by: Peter Krempa --- build-aux/syntax-check.mk | 1 + tests/qemumonitortestutils.c | 121 +++++++++++++++++------------------ 2 files changed, 61 insertions(+), 61 deletions(-) diff --git a/build-aux/syntax-check.mk b/build-aux/syntax-check.mk index cbcdf445aa..bf8832a2a5 100644 --- a/build-aux/syntax-check.mk +++ b/build-aux/syntax-check.mk @@ -900,6 +900,7 @@ sc_flake8: sc_prohibit_exit_in_tests: @prohibit=3D'\nitems =3D=3D 0) { - return qemuMonitorTestAddUnexpectedErrorResponse(test, cmdstr); + qemuMonitorTestError("unexpected command: '%s'", cmdstr); } else { qemuMonitorTestItemPtr item =3D test->items[0]; ret =3D (item->cb)(test, item, cmdstr); @@ -527,10 +542,7 @@ qemuMonitorTestProcessCommandDefaultValidate(qemuMonit= orTestPtr test, if (virQEMUQAPISchemaPathGet(schemapath, test->qapischema, &schemaroot= ) < 0 || !schemaroot) { - if (qemuMonitorTestAddErrorResponse(test, - "command '%s' not found in QAP= I schema", - cmdname) =3D=3D 0) - return 1; + qemuMonitorTestError("command '%s' not found in QAPI schema", cmdn= ame); return -1; } @@ -546,12 +558,10 @@ qemuMonitorTestProcessCommandDefaultValidate(qemuMoni= torTestPtr test, cmdname, NULLSTR(argstr), virBufferCurrentContent(&deb= ug)); } - if (qemuMonitorTestAddErrorResponse(test, - "failed to validate arguments = of '%s' " - "against QAPI schema " - "(to see debug output use VIR_= TEST_DEBUG=3D2)", - cmdname) =3D=3D 0) - return 1; + qemuMonitorTestError("failed to validate arguments of '%s' " + "against QAPI schema " + "(to see debug output use VIR_TEST_DEBUG=3D2)= ", + cmdname); return -1; } @@ -573,8 +583,10 @@ qemuMonitorTestProcessCommandDefault(qemuMonitorTestPt= r test, if (!(val =3D virJSONValueFromString(cmdstr))) return -1; - if (!(cmdname =3D virJSONValueObjectGetString(val, "execute"))) - return qemuMonitorTestAddErrorResponse(test, "Missing command name= in %s", cmdstr); + if (!(cmdname =3D virJSONValueObjectGetString(val, "execute"))) { + qemuMonitorTestError("Missing command name in %s", cmdstr); + return -1; + } cmdargs =3D virJSONValueObjectGet(val, "arguments"); if ((rc =3D qemuMonitorTestProcessCommandDefaultValidate(test, cmdname= , cmdargs)) < 0) @@ -583,8 +595,8 @@ qemuMonitorTestProcessCommandDefault(qemuMonitorTestPtr= test, return 0; if (data->command_name && STRNEQ(data->command_name, cmdname)) { - return qemuMonitorTestAddInvalidCommandResponse(test, data->comman= d_name, - cmdname); + qemuMonitorTestErrorInvalidCommand(data->command_name, cmdname); + return -1; } else { return qemuMonitorTestAddResponse(test, data->response); } @@ -617,7 +629,6 @@ qemuMonitorTestProcessCommandVerbatim(qemuMonitorTestPt= r test, { struct qemuMonitorTestHandlerData *data =3D item->opaque; g_autofree char *reformatted =3D NULL; - g_autofree char *errmsg =3D NULL; g_autoptr(virJSONValue) json =3D NULL; virJSONValuePtr cmdargs; const char *cmdname; @@ -646,13 +657,9 @@ qemuMonitorTestProcessCommandVerbatim(qemuMonitorTestP= tr test, ret =3D qemuMonitorTestAddResponse(test, data->response); } else { if (data->cmderr) { - errmsg =3D g_strdup_printf("%s: %s", data->cmderr, cmdstr); - - ret =3D qemuMonitorTestAddErrorResponseInternal(test, errmsg); + qemuMonitorTestError("%s: %s", data->cmderr, cmdstr); } else { - ret =3D qemuMonitorTestAddInvalidCommandResponse(test, - data->command_n= ame, - cmdstr); + qemuMonitorTestErrorInvalidCommand(data->command_name, cmdstr); } } @@ -782,21 +789,19 @@ qemuMonitorTestProcessCommandWithArgs(qemuMonitorTest= Ptr test, return -1; if (!(cmdname =3D virJSONValueObjectGetString(val, "execute"))) { - ret =3D qemuMonitorTestAddErrorResponse(test, "Missing command nam= e in %s", cmdstr); + qemuMonitorTestError("Missing command name in %s", cmdstr); goto cleanup; } if (data->command_name && STRNEQ(data->command_name, cmdname)) { - ret =3D qemuMonitorTestAddInvalidCommandResponse(test, data->comma= nd_name, - cmdname); + qemuMonitorTestErrorInvalidCommand(data->command_name, cmdname); goto cleanup; } if (!(args =3D virJSONValueObjectGet(val, "arguments"))) { - ret =3D qemuMonitorTestAddErrorResponse(test, - "Missing arguments section f= or command '%s'", - NULLSTR(data->command_name)); + qemuMonitorTestError("Missing arguments section for command '%s'", + NULLSTR(data->command_name)); goto cleanup; } @@ -804,10 +809,9 @@ qemuMonitorTestProcessCommandWithArgs(qemuMonitorTestP= tr test, for (i =3D 0; i < data->nargs; i++) { qemuMonitorTestCommandArgsPtr arg =3D &data->args[i]; if (!(argobj =3D virJSONValueObjectGet(args, arg->argname))) { - ret =3D qemuMonitorTestAddErrorResponse(test, - "Missing argument '%s' f= or command '%s'", - arg->argname, - NULLSTR(data->command_na= me)); + qemuMonitorTestError("Missing argument '%s' for command '%s'", + arg->argname, + NULLSTR(data->command_name)); goto cleanup; } @@ -817,13 +821,11 @@ qemuMonitorTestProcessCommandWithArgs(qemuMonitorTest= Ptr test, /* verify that the argument value is expected */ if (STRNEQ(argstr, arg->argval)) { - ret =3D qemuMonitorTestAddErrorResponse(test, - "Invalid value of argume= nt '%s' " - "of command '%s': " - "expected '%s' got '%s'", - arg->argname, - NULLSTR(data->command_na= me), - arg->argval, argstr); + qemuMonitorTestError("Invalid value of argument '%s' of comman= d '%s': " + "expected '%s' got '%s'", + arg->argname, + NULLSTR(data->command_name), + arg->argval, argstr); goto cleanup; } @@ -908,20 +910,18 @@ qemuMonitorTestProcessCommandWithArgStr(qemuMonitorTe= stPtr test, return -1; if (!(cmdname =3D virJSONValueObjectGetString(val, "execute"))) { - ret =3D qemuMonitorTestAddErrorResponse(test, "Missing command nam= e in %s", cmdstr); + qemuMonitorTestError("Missing command name in %s", cmdstr); goto cleanup; } if (STRNEQ(data->command_name, cmdname)) { - ret =3D qemuMonitorTestAddInvalidCommandResponse(test, data->comma= nd_name, - cmdname); + qemuMonitorTestErrorInvalidCommand(data->command_name, cmdname); goto cleanup; } if (!(args =3D virJSONValueObjectGet(val, "arguments"))) { - ret =3D qemuMonitorTestAddErrorResponse(test, - "Missing arguments section f= or command '%s'", - data->command_name); + qemuMonitorTestError("Missing arguments section for command '%s'", + data->command_name); goto cleanup; } @@ -931,10 +931,9 @@ qemuMonitorTestProcessCommandWithArgStr(qemuMonitorTes= tPtr test, /* verify that the argument value is expected */ if (STRNEQ(argstr, data->expectArgs)) { - ret =3D qemuMonitorTestAddErrorResponse(test, - "%s: expected arguments: '%s= ', got: '%s'", - data->command_name, - data->expectArgs, argstr); + qemuMonitorTestError("%s: expected arguments: '%s', got: '%s'", + data->command_name, + data->expectArgs, argstr); goto cleanup; } --=20 2.26.0