From nobody Wed Nov 5 13:32:31 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1536606471998807.2255042221628; Mon, 10 Sep 2018 12:07:51 -0700 (PDT) Received: from localhost ([::1]:53569 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fzRXL-0007ZY-0d for importer@patchew.org; Mon, 10 Sep 2018 15:07:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49140) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fzRPQ-0001Hq-SB for qemu-devel@nongnu.org; Mon, 10 Sep 2018 14:59:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fzRPP-0001Dd-BF for qemu-devel@nongnu.org; Mon, 10 Sep 2018 14:59:40 -0400 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:52791) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fzRPP-0000zH-0Q for qemu-devel@nongnu.org; Mon, 10 Sep 2018 14:59:39 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 69B6221F37; Mon, 10 Sep 2018 14:59:07 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Mon, 10 Sep 2018 14:59:07 -0400 Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id 01927102A3; Mon, 10 Sep 2018 14:59:07 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=braap.org; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=mesmtp; bh=oXFEAlJ4YDyX0kBgpl6dH4hVjM Vm+r9TAR+9xxyhScQ=; b=qoozoricGP8uzmDJstVzUKgqKS92e9c/LTlybn0Qyt Wz41P/No9vLtW9zDVPtMoeU0G7oXkc18FFPEeWNtBF+MYuZ1lLHASYaW6fz+3mY3 DascqEtnkujI++xhWFUS0PuCy+/ZsrSuHiSl5s86wRpiugR6CkfQTtX8ZEfqb+ey E= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=oXFEAl J4YDyX0kBgpl6dH4hVjMVm+r9TAR+9xxyhScQ=; b=Krwsd5P93i61n5SJRaYGPd hBBdXRI/hN8B9AVtDOjep81ryN6oiXEF7Qc04+BaJAbgTiMR5/ybDwUFC/SfRdC/ TcgeKRns0f/jszUynYdIU1YvDBY+kcu2VJmrN5cccwS87sviRF+cBkOGq3ySbkar IRFRhM5lWYCO7+KHofp7KvkYJkjxy3EQYns2a2RtS9oqL2nxmZ+lOVRNS/iXPtf3 ed0NIp+Qcp7cYkFUVBdTrYDA8WO4yMHpUc21nWSTYed3nhJYzPqsga7lGiNLvtzh bd/i6gnyAOpH9qhkpR5fquXnd8XhUC1ZkA49B/DljxBNItLjfFlSskmte0qknTeA == X-ME-Proxy: X-ME-Sender: From: "Emilio G. Cota" To: qemu-devel@nongnu.org Date: Mon, 10 Sep 2018 14:58:51 -0400 Message-Id: <20180910185859.27917-5-cota@braap.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180910185859.27917-1-cota@braap.org> References: <20180910185859.27917-1-cota@braap.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 66.111.4.25 Subject: [Qemu-devel] [PATCH v2 04/12] test-qht: test removal of non-existent entries X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 This improves qht.c code coverage from 89.44% to 90.00%. Reviewed-by: Alex Benn=C3=A9e Signed-off-by: Emilio G. Cota --- tests/test-qht.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/tests/test-qht.c b/tests/test-qht.c index 283fb3db39..05b1d6807a 100644 --- a/tests/test-qht.c +++ b/tests/test-qht.c @@ -41,7 +41,7 @@ static void insert(int a, int b) } } =20 -static void rm(int init, int end) +static void do_rm(int init, int end, bool exist) { int i; =20 @@ -49,10 +49,24 @@ static void rm(int init, int end) uint32_t hash; =20 hash =3D arr[i]; - g_assert_true(qht_remove(&ht, &arr[i], hash)); + if (exist) { + g_assert_true(qht_remove(&ht, &arr[i], hash)); + } else { + g_assert_false(qht_remove(&ht, &arr[i], hash)); + } } } =20 +static void rm(int init, int end) +{ + do_rm(init, end, true); +} + +static void rm_nonexist(int init, int end) +{ + do_rm(init, end, false); +} + static void check(int a, int b, bool expected) { struct qht_stats stats; @@ -157,8 +171,15 @@ static void qht_do_test(unsigned int mode, size_t init= _entries) check_n(0); =20 qht_init(&ht, is_equal, 0, mode); + rm_nonexist(0, 4); + insert(0, 4); + rm_nonexist(5, 6); + insert(4, 6); + rm_nonexist(7, 8); + iter_rm_mod(1); =20 check_n(0); + rm_nonexist(0, 10); insert(0, N); check(0, N, true); check_n(N); @@ -183,6 +204,7 @@ static void qht_do_test(unsigned int mode, size_t init_= entries) =20 qht_reset(&ht); insert(0, N); + rm_nonexist(N, N + 32); iter_rm_mod(10); iter_rm_mod_check(10); check_n(N * 9 / 10); --=20 2.17.1