From patchwork Wed Sep 26 18:37:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 147636 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp1071374lji; Wed, 26 Sep 2018 11:43:03 -0700 (PDT) X-Google-Smtp-Source: ACcGV60TB4ke5qEgdklleyr4PPsAu5TQs5Le2gyjoCWX2IV2ERrsjDipzLKBLUKBcKQ71XHIUAaG X-Received: by 2002:a37:4150:: with SMTP id o77-v6mr5330623qka.78.1537987383759; Wed, 26 Sep 2018 11:43:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537987383; cv=none; d=google.com; s=arc-20160816; b=PdKiE+Ob5VSnGCg2r7vZTBz2qljBB9c4bUkLSCnlGbMnBkSFxxsxxog2V380BWj2C3 Liiqzj0FE5IknJ3DPGQKk29s3M7S9w2IDHm5oqvJJvFxGFq88VOkA23QpE2gv8KVhGER jy185HZOjBp7Afz9XC0iStDAE4E0eBUUtxH4PYpMimuUPo5qc7kyixMCyMlWtkTzW/0h 72JF4J09aASMLCpZPqGj3NmA+AdTJWRIwF/IxErYB/jtwMx3N9ROKvWBRi9Rd2e0Xsl/ pMvFEGestIncxWJnd0eoK/CWD1GV2+pPvvWKuc6LpZ9a0WORfz3uENulqyhwtAmFl//+ BrhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=X2FKDRjB8W9M0bK6Iox54anHPpZi7j/uqOqhTSev0ZY=; b=MKB15j+pD4cjyFDCKqt23JNOH4Rf2BOhValbZU4EyL4KOhyxedHKa2YPXWPsj6dcm6 LkXqrYkQ70hU0RhdnHtEbh3XQVy+kFzOn234EmDuza67eW/Jq4iGy9shd2XlJIPUnzov ibeLaV5K0wFRPRtYQOTglz2c7ZVVePm5ljE9p+EbZIpYJbnsmb0DhCgQbgygmsgGZ37z gGdx95i3MHdHTtOElbvqnVyRcxi6aVrz9CwTdvg20ce8PVT7+u3qVAK6xqEGCQIetRm7 uXB17ppXG/r5SE1za7GsfllrB3jtXu3v4Rad263ionBfB4te1oz2LGPt3iq1/Wi3DcNQ rj6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="LT7zp/HB"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id g38-v6si4605180qve.248.2018.09.26.11.43.03 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 26 Sep 2018 11:43:03 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="LT7zp/HB"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:60191 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5Em7-00085L-3Y for patch@linaro.org; Wed, 26 Sep 2018 14:43:03 -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) 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-Received: by 2002:a62:9042:: with SMTP id a63-v6mr7579903pfe.52.1537987038339; Wed, 26 Sep 2018 11:37:18 -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) 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 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" This improves qht.c code coverage from 89.44% to 90.00%. Reviewed-by: Alex Bennée Signed-off-by: Emilio G. Cota Signed-off-by: Richard Henderson --- tests/test-qht.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) -- 2.17.1 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) } } -static void rm(int init, int end) +static void do_rm(int init, int end, bool exist) { int i; @@ -49,10 +49,24 @@ static void rm(int init, int end) uint32_t hash; hash = 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)); + } } } +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); 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); 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) 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);