From nobody Tue Feb 10 02:00:37 2026 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; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1537987340328273.3428291621143; Wed, 26 Sep 2018 11:42:20 -0700 (PDT) Received: from localhost ([::1]:60185 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5ElP-0005wh-7k for importer@patchew.org; Wed, 26 Sep 2018 14:42:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53602) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5Egm-0001b5-El for qemu-devel@nongnu.org; Wed, 26 Sep 2018 14:37:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g5Egk-0007PF-CF for qemu-devel@nongnu.org; Wed, 26 Sep 2018 14:37:32 -0400 Received: from mail-pg1-x52b.google.com ([2607:f8b0:4864:20::52b]:34444) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g5Egj-0007AE-WE for qemu-devel@nongnu.org; Wed, 26 Sep 2018 14:37:30 -0400 Received: by mail-pg1-x52b.google.com with SMTP id d19-v6so14418418pgv.1 for ; Wed, 26 Sep 2018 11:37:19 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-8-179.tukw.qwest.net. [97.113.8.179]) by smtp.gmail.com with ESMTPSA id b14-v6sm9735952pfc.178.2018.09.26.11.37.16 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 26 Sep 2018 11:37:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=X2FKDRjB8W9M0bK6Iox54anHPpZi7j/uqOqhTSev0ZY=; b=LT7zp/HBP63TW4VXWORBVjhcCF3rhIttOI7bJ//cakG+BbK++ezA2blVaC1mGcOMG5 HFy7RigV/d8nfujkvTfvEGGJmPqAcu38O6fkuVKg7Wua4NC2jgi6Dyfp4lBV2bxjvcQ5 MYy7IEvnkZjwf0gLAOW2Fc19U8+QFHX26ETtA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=X2FKDRjB8W9M0bK6Iox54anHPpZi7j/uqOqhTSev0ZY=; b=n4zhgyjrCG5UrJ1hsawRnaHiCquZZF88vHKif1EswjaqRePQlQixuq86C920Z78yU8 IJQGPutKltp5e0NlxGAG6kkLcoO5queBwgAfuOcOLtg+qoyPVcF0mMQuBNwPjc3zxmlJ 1lRULLh05+UBn4AqOfrhNgZTwQ4LreGhfLJ+dBHyYA5bMKbgpcsdUdFqJYBX5hNfSKu/ bc8h9WDWcR3HZ1tUrm7hWsqmOHwJrqeKngX/r29a5SXF3Y1Lkwuu0fGp+dB790CVzMUY TF5uP2uOHDFp3iTVZSHfUrtlwCKYvoVCuFtcgt1Vb9yhGj7o/9KdTtw3SZUqM2cXytn7 ReDg== X-Gm-Message-State: ABuFfohh55YD+5FMiQuz2Yyoum6WeED40H3KMd3QAO31MN1ECtAHexcZ tMGGSOlffQWfCmIIMxgtHPGWHvTkfgA= X-Google-Smtp-Source: ACcGV62Eky1HoYNk5To3A7C+WqVirHNtbA0zpX65+URzME57K188Qzimko47LbVUHI6s+l1efZgFYA== X-Received: by 2002:a62:9042:: with SMTP id a63-v6mr7579903pfe.52.1537987038339; Wed, 26 Sep 2018 11:37:18 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 26 Sep 2018 11:37:00 -0700 Message-Id: <20180926183709.21293-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180926183709.21293-1-richard.henderson@linaro.org> References: <20180926183709.21293-1-richard.henderson@linaro.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: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::52b Subject: [Qemu-devel] [PULL 04/13] 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: peter.maydell@linaro.org, "Emilio G. Cota" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDMRC_1 RDKM_2 RSF_0 Z_629925259 SPT_0 From: "Emilio G. Cota" This improves qht.c code coverage from 89.44% to 90.00%. Reviewed-by: Alex Benn=C3=A9e Signed-off-by: Emilio G. Cota Signed-off-by: Richard Henderson --- 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