From nobody Tue Feb 10 02:43:37 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 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=1583771286; cv=none; d=zohomail.com; s=zohoarc; b=NQwQWnqG3kBGyYSvk9VAfKOVv6hyTiZb3LLLnsYjDJ7XtgEJtOmDG7DcJafG6uoLy6fm7SGSJUPy5NfF91M/b1lQ5x3dlIVEtY/CGUnHWfhpozZhdOkG544MjFBXPCFj0poZZtu53kKhRyi4jdsV5lEOyOgX1S3p6miWDpuoe9I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583771286; 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=4dut/km5jtBnjXsu/U6AA/xEZrwB+ZgRVj/STXS+r3c=; b=T/o+lTnYIqpd+zTahwWFw3UCBtFOdandlPW0RElgR9pelHrFdVdaobwhwbycEQ+WpdKlUzi0MDkUhbaEiHOBlpLZgASX0LIqjTMkAptLa2p71m/h/y3lbRl5TEwEtS5iOwW47VR64poDzuI6xlVaOhN8z8ezIIdh334lp2RzyqM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 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-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1583771286598581.915658554053; Mon, 9 Mar 2020 09:28:06 -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-207-78K1c-C5N5ujmmr1xiIk5Q-1; Mon, 09 Mar 2020 12:24:23 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D39901088388; Mon, 9 Mar 2020 16:24:15 +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 A74AB19C6A; Mon, 9 Mar 2020 16:24:15 +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 52DD386A2F; Mon, 9 Mar 2020 16:24:15 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 029GNhSZ020952 for ; Mon, 9 Mar 2020 12:23:43 -0400 Received: by smtp.corp.redhat.com (Postfix) id C8B9A90A03; Mon, 9 Mar 2020 16:23:43 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4FAE790779 for ; Mon, 9 Mar 2020 16:23:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583771285; 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=4dut/km5jtBnjXsu/U6AA/xEZrwB+ZgRVj/STXS+r3c=; b=dPs1+TFExTk3diQvBEUwxx/KlkyK72TqYxSAN0O0P4x9VqJSTVAv/XwpqqzJKeYMB2iI53 WpqnHgi3faM8H9HIQOn3JTFBldeGUN2VtOevd3gR+EAjeap08eysSxflnNUZOkj3W67uu1 tQs0zvX+DNN5PZnuQGUsUruZMGwuLHA= X-MC-Unique: 78K1c-C5N5ujmmr1xiIk5Q-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 28/30] qemublocktest: XMLjsonXML: Test formatting/parsing of modern JSON Date: Mon, 9 Mar 2020 17:23:08 +0100 Message-Id: <091b87df4b75124934ef1888ccb50866e96489f9.1583770683.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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.84 on 10.5.11.23 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" The test was invoking the JSON formatter with the 'legacy' flag thus formatting bunch of obsolete JSON blockdev definitions. We also should test the modern ones. Add a boolean and re-run all the tests in both cases. Additionally for any modern invocation we should also validate that the output conforms to the QAPI schema. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- tests/qemublocktest.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/tests/qemublocktest.c b/tests/qemublocktest.c index f803c9c6b3..77484cc8e7 100644 --- a/tests/qemublocktest.c +++ b/tests/qemublocktest.c @@ -41,6 +41,9 @@ VIR_LOG_INIT("tests.storagetest"); struct testBackingXMLjsonXMLdata { int type; const char *xml; + bool legacy; + virHashTablePtr schema; + virJSONValuePtr schemaroot; }; static int @@ -57,6 +60,7 @@ testBackingXMLjsonXML(const void *args) g_autofree char *actualxml =3D NULL; g_autoptr(virStorageSource) xmlsrc =3D NULL; g_autoptr(virStorageSource) jsonsrc =3D NULL; + g_auto(virBuffer) debug =3D VIR_BUFFER_INITIALIZER; if (!(xmlsrc =3D virStorageSourceNew())) return -1; @@ -71,12 +75,27 @@ testBackingXMLjsonXML(const void *args) return -1; } - if (!(backendprops =3D qemuBlockStorageSourceGetBackendProps(xmlsrc, t= rue, false, + if (!(backendprops =3D qemuBlockStorageSourceGetBackendProps(xmlsrc, + data->legac= y, + false, false))) { fprintf(stderr, "failed to format disk source json\n"); return -1; } + if (!data->legacy) { + if (testQEMUSchemaValidate(backendprops, data->schemaroot, + data->schema, &debug) < 0) { + g_autofree char *debugmsg =3D virBufferContentAndReset(&debug); + g_autofree char *debugprops =3D virJSONValueToString(backendpr= ops, true); + + VIR_TEST_VERBOSE("json does not conform to QAPI schema"); + VIR_TEST_DEBUG("json:\n%s\ndoes not match schema. Debug output= :\n %s", + debugprops, NULLSTR(debugmsg)); + return -1; + } + } + if (virJSONValueObjectCreate(&wrapper, "a:file", &backendprops, NULL) = < 0) return -1; @@ -911,6 +930,10 @@ mymain(void) do { \ xmljsonxmldata.type =3D tpe; \ xmljsonxmldata.xml =3D xmlstr; \ + xmljsonxmldata.legacy =3D true; \ + if (virTestRun(virTestCounterNext(), testBackingXMLjsonXML, \ + &xmljsonxmldata) < 0) \ + xmljsonxmldata.legacy =3D false; \ if (virTestRun(virTestCounterNext(), testBackingXMLjsonXML, \ &xmljsonxmldata) < 0) \ ret =3D -1; \ @@ -919,6 +942,9 @@ mymain(void) #define TEST_JSON_FORMAT_NET(xmlstr) \ TEST_JSON_FORMAT(VIR_STORAGE_TYPE_NETWORK, xmlstr) + xmljsonxmldata.schema =3D qmp_schema_x86_64; + xmljsonxmldata.schemaroot =3D qmp_schemaroot_x86_64_blockdev_add; + TEST_JSON_FORMAT(VIR_STORAGE_TYPE_FILE, "\n"); /* type VIR_STORAGE_TYPE_BLOCK is not tested since it parses back to '= file' */ --=20 2.24.1