From nobody Thu Mar 28 19:26:37 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.74 as permitted sender) client-ip=63.128.21.74; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-74.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.74 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=1585054496; cv=none; d=zohomail.com; s=zohoarc; b=PxawZLBqYtqjqqPqe3x15+hhRithw4bdh1Ma9q6Oyh/T4wt8Msc/+zvc+5hakD0bp6tYVDVnzBrwXLWatqRkBp8WytHQk9iyHpCDDl9UGOGB2/DSoS15fxgoRrpAAn+izgK0IVaTIlvoH6Cgob9CHPbZjeCKhyJJSxLjR4R81c0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1585054496; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=+pNKcY6viqRiwY6C/iXj41pOAtqtfZsXsCJ47pq//Tg=; b=gecqvAPbPDhwSX0GJLIVAEli/h4wzf/d1rF3lIZ+myYh/bq8UmGaWkjiKnaBTyC5LT0RQSPE99aZg51Mya95oFUNY0qsmQego965ZsmmkKqSpenhSSe9Ieau1Q0oet9l77gM59tkctJac3r4nay3sFtN8A83CIm7o/4TFSW3UCM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.74 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-delivery-74.mimecast.com (us-smtp-delivery-74.mimecast.com [63.128.21.74]) by mx.zohomail.com with SMTPS id 1585054496398573.5284964687107; Tue, 24 Mar 2020 05:54:56 -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-408-hiXc6BLVP9SH11gGmYHA7w-1; Tue, 24 Mar 2020 08:54:51 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 92A7D13F8; Tue, 24 Mar 2020 12:54:46 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6C5715C1C7; Tue, 24 Mar 2020 12:54:46 +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 2AA481803C33; Tue, 24 Mar 2020 12:54:46 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 02OCsif2020880 for ; Tue, 24 Mar 2020 08:54:44 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1FEE919C70; Tue, 24 Mar 2020 12:54:44 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.192.151]) by smtp.corp.redhat.com (Postfix) with ESMTP id 92FCB19C6A for ; Tue, 24 Mar 2020 12:54:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585054494; 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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=+pNKcY6viqRiwY6C/iXj41pOAtqtfZsXsCJ47pq//Tg=; b=V8YrTOjJ/h6Q/B8w1CzyjA4Wt8ekTo1SH5Eam6hvN8yM+WcpffTF8iBvhm+mEbklTICflr Mz1aJv+HFExLiynjaj3KcQrpoLcufMJYOzGY4muBW1CLpMHx9OJO4NBbu/oXMDfEmdmI5p uZASns953q8N/12JDjTLnkIZHVOiB/0= X-MC-Unique: hiXc6BLVP9SH11gGmYHA7w-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH] commandtest: Fix test28 error detection Date: Tue, 24 Mar 2020 13:54:35 +0100 Message-Id: <0c838d4dec96fb5f26a98590ba6f3f571b937586.1585054475.git.mprivozn@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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.13 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" As a part of c799d150d5e9dae 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 Reviewed-by: Daniel P. Berrang=C3=A9 --- tests/commandtest.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/commandtest.c b/tests/commandtest.c index f4a2c67c05..d5092b7dd0 100644 --- a/tests/commandtest.c +++ b/tests/commandtest.c @@ -1272,6 +1272,7 @@ test28(const void *unused G_GNUC_UNUSED) /* Not strictly a virCommand test, but this is the easiest place * to test this lower-level interface. */ virErrorPtr err; + g_autofree char *msg =3D g_strdup_printf("some error message: %s", g_s= trerror(ENODATA)); =20 if (virProcessRunInFork(test28Callback, NULL) !=3D -1) { fprintf(stderr, "virProcessRunInFork did not fail\n"); @@ -1285,10 +1286,10 @@ test28(const void *unused G_GNUC_UNUSED) =20 if (!(err->code =3D=3D VIR_ERR_SYSTEM_ERROR && err->domain =3D=3D 0 && - STREQ(err->message, "some error message: No data available") && + STREQ(err->message, msg) && err->level =3D=3D VIR_ERR_ERROR && STREQ(err->str1, "%s") && - STREQ(err->str2, "some error message: No data available") && + STREQ(err->str2, msg) && err->int1 =3D=3D ENODATA && err->int2 =3D=3D -1)) { fprintf(stderr, "Unexpected error object\n"); --=20 2.24.1