From nobody Fri May 3 14:24:20 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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=1628780141; cv=none; d=zohomail.com; s=zohoarc; b=M07kmjo/cTq08W3sV5GTgx6UzFh0degtnXO7LQfe86rnQeQ5OQDGAOfZv5gYNwOoSIFoATmviC7Gexf8+rl6tZcnLO4GN3jdovOpxmLj0ChPM2IzsW3o8zfcemA4CfdlEyojq/2B+tUf8K28eWvGC60KDJW1LVBVz0SuO956Yg8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1628780141; 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=WH+4ogLh8aq8Z9aStFRhOUPt66EaJFuocXNv59W9u+I=; b=RaBOPrDR2nKr00kqAU40poqUQlyfJmb5lpaVIaJXfaCAhBpXIKGEvkpsi1aPcjdsUTlvSodrU9aCUBXHoDRStE5b5mnSQDTtm6YUvKZQbbrvyLi7P+mrSG/vTCUB2T7HG72UbyIM6N0UU9//l8YpUwsOcE8ElWZfoa+ivWC6W/Q= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1628780141483719.2148719618144; Thu, 12 Aug 2021 07:55:41 -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-489-6WIcKj1qMrWLbf1AoqmmCw-1; Thu, 12 Aug 2021 10:55:39 -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 90D9EC7403; Thu, 12 Aug 2021 14:55:33 +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 4AA21A22D; Thu, 12 Aug 2021 14:55:33 +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 12F134A716; Thu, 12 Aug 2021 14:55:33 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 17CEtAJa009435 for ; Thu, 12 Aug 2021 10:55:10 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7E1B15C23A; Thu, 12 Aug 2021 14:55:10 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id CF3215C25A for ; Thu, 12 Aug 2021 14:55:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628780140; 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=WH+4ogLh8aq8Z9aStFRhOUPt66EaJFuocXNv59W9u+I=; b=iYP0c1hrUFccbxzb1M+6WONL+CjK0JVZ4mwCZuvm8gBFzwvqGoPyBONcfqnTnqAw+ueYo1 VyCRBl1mn6N1tkw93Ozka7De+nkynBr36HgbV05gV7Vy7Q9/030C1aaLh47qtpgBDkYhPx q6+kIfQNeC/OEuirzGnRA7vd6Xc3pVM= X-MC-Unique: 6WIcKj1qMrWLbf1AoqmmCw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH] tests: qemu: Don't crash when capability file can't be parsed Date: Thu, 12 Aug 2021 16:55:04 +0200 Message-Id: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1628780141825100001 Content-Type: text/plain; charset="utf-8" In case the test directory contains invalid XML (this doesn't happen upstream, but can when developing, e.g. by forgetting git conflict markers) the tests would crash as in case when 'testQemuInfoSetArgs' fails we'd still invoke the test in qemuxml2argv and qemuxml2xml tests. Add a 'break' statement to avoid invocation of the test and add a debug message. Signed-off-by: Peter Krempa --- tests/qemuxml2argvtest.c | 4 +++- tests/qemuxml2xmltest.c | 1 + tests/testutilsqemu.c | 4 +++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index b552f5deed..3f43e76842 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -943,8 +943,10 @@ mymain(void) }; \ info.qapiSchemaCache =3D qapiSchemaCache; \ if (testQemuInfoSetArgs(&info, capscache, capslatest, \ - __VA_ARGS__, ARG_END) < 0) \ + __VA_ARGS__, ARG_END) < 0) { \ ret =3D -1; \ + break; \ + } \ testInfoSetPaths(&info, _suffix); \ if (virTestRun("QEMU XML-2-ARGV " _name _suffix, \ testCompareXMLToArgv, &info) < 0) \ diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 9652d2a7ce..3b453f9746 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -157,6 +157,7 @@ mymain(void) qemuTestCapsCacheInsert(driver.qemuCapsCache, info.qemuCaps) <= 0) { \ VIR_TEST_DEBUG("Failed to generate test data for '%s'", _name)= ; \ ret =3D -1; \ + break; \ } \ \ if (when & WHEN_INACTIVE) { \ diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c index 9a0666724a..f166eaf502 100644 --- a/tests/testutilsqemu.c +++ b/tests/testutilsqemu.c @@ -785,8 +785,10 @@ testQemuInfoSetArgs(struct testQemuInfo *info, } if (!g_hash_table_lookup_extended(capscache, capsfile, NULL, (void= **) &cachedcaps)) { - if (!(qemuCaps =3D qemuTestParseCapabilitiesArch(info->arch, c= apsfile))) + if (!(qemuCaps =3D qemuTestParseCapabilitiesArch(info->arch, c= apsfile))) { + VIR_TEST_VERBOSE("failed to parse capabilities file '%s'",= capsfile); goto cleanup; + } cachedcaps =3D qemuCaps; --=20 2.31.1