From nobody Sun Feb 8 20:59:46 2026 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=1603359362; cv=none; d=zohomail.com; s=zohoarc; b=W22eRyy5+Jaj1IhDsMdIN/R11fTgzFx6GDa+hBcLfMgo/22oEoqKNTI8AEivpjWuliT3p/TR3Kq0iUpkdcEwv7gMxnwRFQriELO/h8fWSsFzr171N1Pd5sbfB0qb2pthyM6mE4Tv43GE4/UeO1ew9m3IQfUDJi+EFaPjSxdJmxQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603359362; 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=V425lll+DTivxz8w0y/g3rgFJ0hgJgMylHR9ZxYUdFg=; b=ZTqcoVWftcreE78yzrUnqirNRmIV+XAsteG3sBh41Z7JaKBZY84K8Gg7/6KK7zwLNaPzxeERHK661g0Nf1YhKBSTKAwYQwCgDoyVIeyxxGJcyAA6cY/EIy9BFnMKTiYFVrVV9a4pDKtG2C3Dy7M5FINzG5jfcfs7TH/+10TltVg= 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) header.from= 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 1603359362502767.7405037171651; Thu, 22 Oct 2020 02:36:02 -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-69-sQ8_l-6_MMG92m6u-_FF6Q-1; Thu, 22 Oct 2020 05:35:58 -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 5AF3A1882FA8; Thu, 22 Oct 2020 09:35:51 +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 3A8836EF6B; Thu, 22 Oct 2020 09:35:51 +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 045B8181A07B; Thu, 22 Oct 2020 09:35:51 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 09M9ZKrx024516 for ; Thu, 22 Oct 2020 05:35:20 -0400 Received: by smtp.corp.redhat.com (Postfix) id 84B665B4A3; Thu, 22 Oct 2020 09:35:20 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id D40DD5B4C0 for ; Thu, 22 Oct 2020 09:35:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603359361; 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=V425lll+DTivxz8w0y/g3rgFJ0hgJgMylHR9ZxYUdFg=; b=gnkBtQz/2DHSO73HbP7PCPiA4ec/vP5+y/rm30cFSdGW/mu91N3KjgxDGNPu6dPfnNBlYw fKu4N5uhMTIKTBpxwJhKioaWU/ToCPSkD2vEurm2dHj06t8PfrotNNXNimKwf/J4trLyoG yiEbjpLTr8SzuW8V6m/yFt6IxM2EQNo= X-MC-Unique: sQ8_l-6_MMG92m6u-_FF6Q-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 08/15] tests: hash: Prepare for replacement of virHashCreate Date: Thu, 22 Oct 2020 11:34:59 +0200 Message-Id: <48dbe9a2c4858882de8399ee563fbc569551a08a.1603358617.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 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 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) Content-Type: text/plain; charset="utf-8" Most callers pass a random number. We have virHashNew which doesn't give the callers the option to configure the table. Since we are going to switch to virHashNew replace it in tests and remove multiple instances of the 'testHashGrow' case as it doesn't make sense with the new semantics. Signed-off-by: Peter Krempa Reviewed-by: Pavel Hrdina --- tests/virhashtest.c | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/tests/virhashtest.c b/tests/virhashtest.c index 7b1b8dd38c..bc93c07d1f 100644 --- a/tests/virhashtest.c +++ b/tests/virhashtest.c @@ -15,12 +15,12 @@ VIR_LOG_INIT("tests.hashtest"); static virHashTablePtr -testHashInit(int size) +testHashInit(void) { virHashTablePtr hash; ssize_t i; - if (!(hash =3D virHashCreate(size, NULL))) + if (!(hash =3D virHashNew(NULL))) return NULL; /* entries are added in reverse order so that they will be linked in @@ -83,13 +83,12 @@ struct testInfo { static int -testHashGrow(const void *data) +testHashGrow(const void *data G_GNUC_UNUSED) { - const struct testInfo *info =3D data; virHashTablePtr hash; int ret =3D -1; - if (!(hash =3D testHashInit(info->count))) + if (!(hash =3D testHashInit())) return -1; if (testHashCheckCount(hash, G_N_ELEMENTS(uuids)) < 0) @@ -111,7 +110,7 @@ testHashUpdate(const void *data G_GNUC_UNUSED) size_t i; int ret =3D -1; - if (!(hash =3D testHashInit(0))) + if (!(hash =3D testHashInit())) return -1; for (i =3D 0; i < G_N_ELEMENTS(uuids_subset); i++) { @@ -149,7 +148,7 @@ testHashRemove(const void *data G_GNUC_UNUSED) size_t i; int ret =3D -1; - if (!(hash =3D testHashInit(0))) + if (!(hash =3D testHashInit())) return -1; for (i =3D 0; i < G_N_ELEMENTS(uuids_subset); i++) { @@ -216,7 +215,7 @@ testHashRemoveForEach(const void *data) virHashTablePtr hash; int ret =3D -1; - if (!(hash =3D testHashInit(0))) + if (!(hash =3D testHashInit())) return -1; if (virHashForEach(hash, (virHashIterator) info->data, hash)) { @@ -243,7 +242,7 @@ testHashSteal(const void *data G_GNUC_UNUSED) size_t i; int ret =3D -1; - if (!(hash =3D testHashInit(0))) + if (!(hash =3D testHashInit())) return -1; for (i =3D 0; i < G_N_ELEMENTS(uuids_subset); i++) { @@ -297,7 +296,7 @@ testHashRemoveSet(const void *data G_GNUC_UNUSED) int rcount; int ret =3D -1; - if (!(hash =3D testHashInit(0))) + if (!(hash =3D testHashInit())) return -1; /* seed the generator so that rand() provides reproducible sequence */ @@ -340,7 +339,7 @@ testHashSearch(const void *data G_GNUC_UNUSED) void *entry; int ret =3D -1; - if (!(hash =3D testHashInit(0))) + if (!(hash =3D testHashInit())) return -1; entry =3D virHashSearch(hash, testHashSearchIter, NULL, NULL); @@ -544,15 +543,10 @@ mymain(void) testHash ## cmd ## data, \ testHashCount ## cmd ## data) -#define DO_TEST_COUNT(name, cmd, count) \ - DO_TEST_FULL(name "(" #count ")", cmd, NULL, count) - #define DO_TEST(name, cmd) \ DO_TEST_FULL(name, cmd, NULL, -1) - DO_TEST_COUNT("Grow", Grow, 1); - DO_TEST_COUNT("Grow", Grow, 10); - DO_TEST_COUNT("Grow", Grow, 42); + DO_TEST("Grow", Grow); DO_TEST("Update", Update); DO_TEST("Remove", Remove); DO_TEST_DATA("Remove in ForEach", RemoveForEach, Some); --=20 2.26.2