From nobody Fri Mar 29 02:08:25 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linux.intel.com ARC-Seal: i=1; a=rsa-sha256; t=1565742525; cv=none; d=zoho.com; s=zohoarc; b=DtFm+p0j8aRxjqoKbdmiQMH3aLMlp9xnVLdxnhh3Pyp7r6lDzUOUiUqltpCKeG3Uqg6j/8EBDytckPRg2UYehGV/y6neBFbreKQ5m/Ya+lZIZUq2vSkHFSZLT7+OWXtOxIq4Pi/KosHNtHG8FSY4LX/MjgH9EgefJFAzIU7Y8Hk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565742525; h=Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:Sender:Subject:To:ARC-Authentication-Results; bh=3hY60TYcEh2MCg2/kUm8vF6ffLMLlyEGPyOiWUlEpiM=; b=B9UYlHWoUfIEAQCRscrJrBgSBi83+p9gmKmRVk/Q8lcC8kykX1ZrK+veWdC9zbO6OD0iVutNdz1aEYxXGVoe3Jnrbl7PNQehBWq3gq5jDW4uBXtlq3rIIUuTRVdXg/0DDGWQILglaasbEExeAHo31DnKmSro6hrgXlF9nSd36q0= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1565742525004241.52505478587761; Tue, 13 Aug 2019 17:28:45 -0700 (PDT) Received: from localhost ([::1]:56218 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hxh9a-0004J6-Tu for importer@patchew.org; Tue, 13 Aug 2019 20:28:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39494) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hxh9C-0003uZ-HB for qemu-devel@nongnu.org; Tue, 13 Aug 2019 20:28:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hxh9B-0005Sc-Il for qemu-devel@nongnu.org; Tue, 13 Aug 2019 20:28:14 -0400 Received: from mga17.intel.com ([192.55.52.151]:60891) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hxh9B-0005RA-96 for qemu-devel@nongnu.org; Tue, 13 Aug 2019 20:28:13 -0400 Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Aug 2019 17:28:06 -0700 Received: from richard.sh.intel.com (HELO localhost) ([10.239.159.54]) by fmsmga007.fm.intel.com with ESMTP; 13 Aug 2019 17:28:04 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,382,1559545200"; d="scan'208";a="177960620" From: Wei Yang To: qemu-devel@nongnu.org Date: Wed, 14 Aug 2019 08:27:23 +0800 Message-Id: <20190814002723.5140-1-richardw.yang@linux.intel.com> X-Mailer: git-send-email 2.17.1 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 192.55.52.151 Subject: [Qemu-devel] [PATCH] test-bitmap: test set 1 bit case for bitmap_set X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: quintela@redhat.com, corentincj@iksaif.net, pl@kamp.de, peterx@redhat.com, kraxel@redhat.com, pbonzini@redhat.com, Wei Yang Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" All current bitmap_set test cases set range across word, while the handle of a range within one word is different from that. Add case to set 1 bit as a represent for set range within one word. Signed-off-by: Wei Yang --- Thanks for Paolo's finding. --- tests/test-bitmap.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/test-bitmap.c b/tests/test-bitmap.c index 18aa584591..087e02a26c 100644 --- a/tests/test-bitmap.c +++ b/tests/test-bitmap.c @@ -67,6 +67,18 @@ static void bitmap_set_case(bmap_set_func set_func) =20 bmap =3D bitmap_new(BMAP_SIZE); =20 + /* Set one bit at offset in second word */ + for (offset =3D 0; offset <=3D BITS_PER_LONG; offset++) { + bitmap_clear(bmap, 0, BMAP_SIZE); + set_func(bmap, BITS_PER_LONG + offset, 1); + g_assert_cmpint(find_first_bit(bmap, 2 * BITS_PER_LONG), + =3D=3D, BITS_PER_LONG + offset); + g_assert_cmpint(find_next_zero_bit(bmap, + 3 * BITS_PER_LONG, + BITS_PER_LONG + offset), + =3D=3D, BITS_PER_LONG + offset + 1); + } + /* Both Aligned, set bits [BITS_PER_LONG, 3*BITS_PER_LONG] */ set_func(bmap, BITS_PER_LONG, 2 * BITS_PER_LONG); g_assert_cmpuint(bmap[1], =3D=3D, -1ul); --=20 2.17.1