From nobody Tue Nov 26 11:25:05 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.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 207.211.31.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=1579185318; cv=none; d=zohomail.com; s=zohoarc; b=kUTmxuuY8uuubLHrNHM+qBLRwwknzIFSRjTbgmY67WvoClP2u1VHZ5bgKJxhYnppdpvwaMwh4Nh3jTrqdmPhwLBXPibrk7oIRW8tcHYArdm3pd2sTkI0d72KGTZyVnqa7w/VTA+mWVwhOCBLBncWB4eUO0sR/Oq8NPeKvJNvwRQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1579185318; 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=/6t6GKI7UZvXXrIsWoiOO2evw/Qy/7h+DPVhOQlBGRQ=; b=d377gshdKzC+9BseC/ZkzacafBrZagslZWMFYPv16sJH5icG4h+Idb4ab67N7SIPLQOL8LnFJVzlbfkB7UNihtAyLv08nCZPuIjNa0DOWNcR4kpUHU11BM+k1BeWpe2Wiqnt/60Dg0lw+CrORCeCK//JQI4+zotdffPO4//QNWs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.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 [207.211.31.120]) by mx.zohomail.com with SMTPS id 157918531883976.8826746860583; Thu, 16 Jan 2020 06:35:18 -0800 (PST) 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-273-Zf_OPkVkPXerEvqJn2dM8Q-1; Thu, 16 Jan 2020 09:35:16 -0500 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 21C28109E307; Thu, 16 Jan 2020 14:35:10 +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 AD48728D2B; Thu, 16 Jan 2020 14:35:09 +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 5972618034EA; Thu, 16 Jan 2020 14:35:09 +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 00GEZ7cb021951 for ; Thu, 16 Jan 2020 09:35:07 -0500 Received: by smtp.corp.redhat.com (Postfix) id 4087D28D0C; Thu, 16 Jan 2020 14:35:07 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9892F28D00 for ; Thu, 16 Jan 2020 14:35:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579185317; 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=/6t6GKI7UZvXXrIsWoiOO2evw/Qy/7h+DPVhOQlBGRQ=; b=ayQpz6/Uze8rhmu9cS8UQw1oDjtajRrFv4UYz9qUeL9FjssSxbciWlXULeBCdIEduLQbI3 8Y5hTLLRZUuBzM17ZIdIESkAoMb/3m3X+90k6nUeEIG5AkPDBtEb5fwDWTZ6IAf10i8gMI KWNS7nIORCYiMaZOrekgfh/OI9b1T3A= From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 2/2] tests: hash: Test case for adding duplicate hash entry Date: Thu, 16 Jan 2020 15:34:31 +0100 Message-Id: In-Reply-To: References: 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.84 on 10.5.11.23 X-MC-Unique: Zf_OPkVkPXerEvqJn2dM8Q-1 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" Test that adding a duplicate entry is rejected properly. This also allows to see the error message of the duplicate key addition in verbose mode. Signed-off-by: Peter Krempa --- tests/virhashtest.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/virhashtest.c b/tests/virhashtest.c index 66fa3a428e..4d05cbb0f8 100644 --- a/tests/virhashtest.c +++ b/tests/virhashtest.c @@ -510,6 +510,28 @@ testHashEqual(const void *data G_GNUC_UNUSED) } +static int +testHashDuplicate(const void *data G_GNUC_UNUSED) +{ + g_autoptr(virHashTable) hash =3D NULL; + + if (!(hash =3D virHashCreate(0, NULL))) + return -1; + + if (virHashAddEntry(hash, "a", NULL) < 0) { + VIR_TEST_VERBOSE("\nfailed to add key 'a' to hash"); + return -1; + } + + if (virHashAddEntry(hash, "a", NULL) >=3D 0) { + VIR_TEST_VERBOSE("\nadding of key 'a' should have failed"); + return -1; + } + + return 0; +} + + static int mymain(void) { @@ -546,6 +568,7 @@ mymain(void) DO_TEST("Search", Search); DO_TEST("GetItems", GetItems); DO_TEST("Equal", Equal); + DO_TEST("Duplicate entry", Duplicate); return (ret =3D=3D 0) ? EXIT_SUCCESS : EXIT_FAILURE; } --=20 2.24.1