From nobody Wed Nov 5 13:13:04 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 153454956178165.1434797900846; Fri, 17 Aug 2018 16:46:01 -0700 (PDT) Received: from localhost ([::1]:36800 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fqoRI-0006Om-Dn for importer@patchew.org; Fri, 17 Aug 2018 19:45:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57566) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fqoPA-0004q3-MR for qemu-devel@nongnu.org; Fri, 17 Aug 2018 19:43:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fqoBj-0003Hp-S4 for qemu-devel@nongnu.org; Fri, 17 Aug 2018 19:29:55 -0400 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:58609) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fqoBj-0003HE-N5 for qemu-devel@nongnu.org; Fri, 17 Aug 2018 19:29:51 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 7AFB7225DD; Fri, 17 Aug 2018 19:29:51 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Fri, 17 Aug 2018 19:29:51 -0400 Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id 1DACE10255; Fri, 17 Aug 2018 19:29:51 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=braap.org; h=cc :date:from:in-reply-to:message-id:references:subject:to :x-me-sender:x-me-sender:x-sasl-enc; s=mesmtp; bh=hWH4N6sQn7wQPw RgEdSUU8g4ZKdWu0GCeB38wDM+m4Q=; b=VyB+hpWrTDsGr/9UQIiZ/KDdaRa7lL FgOFii7IfBLkOicQJhb+ccEMsVBdm0x3SSUFXIW5jKPoy6UBUTXQ59sufHf6meDR zLjz4WMFkorx2+nImAlAk7tWobhEe16NNdhbU/jRzV8bdp63gurNpS+ESW+ISa7S N0cM7eczYFPmw= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=hWH4N6sQn7wQPwRgEdSUU8g4ZKdWu0GCeB38wDM+m4Q=; b=ExbqLnnJ oR+mM3XsbYcih6+dnzFKfrRDqSwZ/gQRbWAsCqNJMcKz1AZTmz0FBk0k/zpjBuUh uvnPcQEsiQI8GpHkcdNs0npTW3Uu6wuFfofq0aewhOJnBA5aaf8eyDAvxfVuNw+z LGZqdLsqBmA+/AT0fh+/CrAN5XLySmRMa6cUvbK475tFSAqMZXD3i7gCaSKFEsPM 9zJk+tNLIPitKIu3y0MK/ZbusQ1gayWnk6Up7HM+eSxmL6P3aaTGvgOUBX9XVS4X JMUv6wvTuFWW9pyKBY+Yft4Ed+yOxqJF7ta4L6PylOhJoObNwOU4bxcjw2V+CHor o+FUL8bR6NMazQ== X-ME-Proxy: X-ME-Sender: From: "Emilio G. Cota" To: qemu-devel@nongnu.org Date: Fri, 17 Aug 2018 19:29:21 -0400 Message-Id: <20180817232923.28899-5-cota@braap.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180817232923.28899-1-cota@braap.org> References: <20180817232923.28899-1-cota@braap.org> 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 4/6] 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 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This improves qht.c code coverage from 89.44% to 90.00%. Signed-off-by: Emilio G. Cota Reviewed-by: Alex Benn=C3=A9e --- 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