From nobody Sat Nov 23 23:48:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=google.com ARC-Seal: i=1; a=rsa-sha256; t=1728350635; cv=none; d=zohomail.com; s=zohoarc; b=KaPW20cKbkI5AozpoSpNtW0++xfc9JEna/Ut3ZrBEGq7Fhy90JneOyN082SBjfh2MvcNURoGIUICieWWfdA9B6LkmTmN/4npq4OT/J+b1JHY2Ihcv3E/2BA5NCGfk7GSz3RmX7gNCuB9AzsM/pi0Ilea/k7pAg9YOYUdOd+WN5s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728350635; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=wyZg7kxpkNCds2EZflCHxHMwXfcdXxrO/ZcaHcLL39s=; b=fuHmF9Wffn2E5eqR7Ysorcya8dNPOqiCsncHIktSLVY76l8hBTiCelN8cRlluKB+0bpthvegsnzoYBC9Y+IcMlzF9W3Fnxcdx+HtdTixNho86P0BS7DwPNSJH8ewduA+KKWdxUdQ3DORhG9lLfo0Zc+dHiFUXN2N7rb13GxeSjQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1728350635487584.0102617159191; Mon, 7 Oct 2024 18:23:55 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sxysy-0008Cd-Kj; Mon, 07 Oct 2024 21:19:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <3gYgEZwUKCuIXEZMTKSSKPI.GSQUIQY-HIZIPRSRKRY.SVK@flex--tavip.bounces.google.com>) id 1sxysQ-0007br-5l for qemu-devel@nongnu.org; Mon, 07 Oct 2024 21:19:03 -0400 Received: from mail-yw1-x114a.google.com ([2607:f8b0:4864:20::114a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <3gYgEZwUKCuIXEZMTKSSKPI.GSQUIQY-HIZIPRSRKRY.SVK@flex--tavip.bounces.google.com>) id 1sxysO-00006w-FD for qemu-devel@nongnu.org; Mon, 07 Oct 2024 21:19:01 -0400 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-6e30cf0cf1bso16065357b3.0 for ; Mon, 07 Oct 2024 18:18:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1728350338; x=1728955138; darn=nongnu.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=wyZg7kxpkNCds2EZflCHxHMwXfcdXxrO/ZcaHcLL39s=; b=sUmZs6x50LQ/pe4Gez4ZK7t8kjzZvn/cx2qAoJC/7Y4F68dzQ2xvg5k45/wjdGXgo3 hFQf/wA/gJMDCEmbwjZvVkLT1pCF9CcYNQz50G99FM2uXCZx57Db8ZQLDjWvdLu9qFQT ovBzXs1neqv3tzxBZce9oLOY7tmfUHv2RgCc3RbJlZH4rsWqQLF/aT7ccrIFGNrnYufX jIMQ9zzLKMsc57TWkNSR/qvyorhy+F9gQ3Jj93KlQJzgiVw2qwdwNDlQzNIpd1ps0MaM ZfsQsRSiBCoTu1ogZkiFizMVw9hIB36Ew55tHEq013wHhq03py+2Mj/uno8nxwVXKBIa ueKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728350338; x=1728955138; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=wyZg7kxpkNCds2EZflCHxHMwXfcdXxrO/ZcaHcLL39s=; b=oiE3LkJ3p75jGNwaF01xmFwjh718Hq5GsvpSZnLxLlwlLE0xCEt/7nbKSJSAA1IiiV EArxJDTWfmJKQ76KHEXLGw4awBb62z0T+94EYgwyQKhOR8IIEVMUIlkKjmcYSKeH4U9M gc9M30CMyq+HrPVAATxUw/hp8cIZ7Alqo51EjjW++W6jKy7BKzUKAUCwylfZlspmGEBZ JbI6XtKkXZJgi2CGR+BcvuimcswVN40kHl8pRtwMxU5PD3fHFVaoEs7P6OfSVigj/EP9 nYUgCB7W/1TG1cCJSKO0qD2ILJFN6TkE0IpCoCuoquNRaYkUVjKCPWeYPXzCBVk/m4EG gOTw== X-Gm-Message-State: AOJu0YymgggF4pwxu9UxSNvjHATwKkv4aLitwurhwsJ3lQluZN1sZrDd 8RjrgHoiWQ/LUmNnwiAWr70n4jx/VODidx0RG+iprZCM+GQnsn3Skfbx9rjfleLKVlk9RBZ/jbI vlMzmxV+xkRBItm+BxTJ4ITe/bb4X8liu5qsGB+cDgcsku26pGwK3Qav+55vnLT8ZgEQs1xwbNI T3tBHS28fJpxNz9cX8PL7cjwuIKw== X-Google-Smtp-Source: AGHT+IE3/W9CgSMU393ZW56+VU+vEEAMQd6ttBYHzgtNP0gr2mWHRr9OJi2xXWSJjWwG7FxSWygOJf1nyg== X-Received: from warp10.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:750]) (user=tavip job=sendgmr) by 2002:a81:b513:0:b0:6e3:eab:18b1 with SMTP id 00721157ae682-6e30eab1934mr52557b3.1.1728350337999; Mon, 07 Oct 2024 18:18:57 -0700 (PDT) Date: Mon, 7 Oct 2024 18:18:28 -0700 In-Reply-To: <20241008011852.1439154-1-tavip@google.com> Mime-Version: 1.0 References: <20241008011852.1439154-1-tavip@google.com> X-Mailer: git-send-email 2.47.0.rc0.187.ge670bccf7e-goog Message-ID: <20241008011852.1439154-3-tavip@google.com> Subject: [PATCH v2 02/25] tests/unit: add fifo32 tests From: Octavian Purdila To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, stefanst@google.com, pbonzini@redhat.com, peter.maydell@linaro.org, marcandre.lureau@redhat.com, berrange@redhat.com, eduardo@habkost.net, luc@lmichel.fr, damien.hedde@dahe.fr, alistair@alistair23.me, thuth@redhat.com, philmd@linaro.org, jsnow@redhat.com, crosa@redhat.com, lvivier@redhat.com Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=2607:f8b0:4864:20::114a; envelope-from=3gYgEZwUKCuIXEZMTKSSKPI.GSQUIQY-HIZIPRSRKRY.SVK@flex--tavip.bounces.google.com; helo=mail-yw1-x114a.google.com X-Spam_score_int: -95 X-Spam_score: -9.6 X-Spam_bar: --------- X-Spam_report: (-9.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.024, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, USER_IN_DEF_DKIM_WL=-7.5 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @google.com) X-ZM-MESSAGEID: 1728350636471116600 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add push/pop and peek tests for fifo32. Signed-off-by: Octavian Purdila --- tests/unit/test-fifo.c | 50 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/tests/unit/test-fifo.c b/tests/unit/test-fifo.c index 14153c41fa..d0e05ba95c 100644 --- a/tests/unit/test-fifo.c +++ b/tests/unit/test-fifo.c @@ -13,6 +13,7 @@ #include "qemu/osdep.h" #include "migration/vmstate.h" #include "qemu/fifo8.h" +#include "qemu/fifo32.h" =20 const VMStateInfo vmstate_info_uint32; const VMStateInfo vmstate_info_buffer; @@ -432,6 +433,53 @@ static void test_fifo8_pushpop(void) fifo8_destroy(&fifo); } =20 +static void test_fifo32_pushpop(void) +{ + Fifo32 fifo; + uint32_t e; + + fifo32_create(&fifo, 2); + fifo32_push(&fifo, 0x11121314); + fifo32_push(&fifo, 0x21222324); + g_assert(fifo32_num_used(&fifo) =3D=3D 2); + + e =3D fifo32_pop(&fifo); + g_assert(e =3D=3D 0x11121314); + g_assert(fifo32_num_used(&fifo) =3D=3D 1); + + e =3D fifo32_peek(&fifo); + g_assert(e =3D=3D 0x21222324); + + g_assert(fifo32_num_used(&fifo) =3D=3D 1); + fifo32_destroy(&fifo); +} + +static void test_fifo32_peek(void) +{ + Fifo32 fifo; + uint32_t e; + + fifo32_create(&fifo, 2); + fifo32_push(&fifo, 0x11121314); + fifo32_push(&fifo, 0x21222324); + g_assert(fifo32_num_used(&fifo) =3D=3D 2); + + e =3D fifo32_peek(&fifo); + g_assert(e =3D=3D 0x11121314); + g_assert(fifo32_num_used(&fifo) =3D=3D 2); + + e =3D fifo32_pop(&fifo); + g_assert(e =3D=3D 0x11121314); + g_assert(fifo32_num_used(&fifo) =3D=3D 1); + + e =3D fifo32_peek(&fifo); + g_assert(e =3D=3D 0x21222324); + g_assert(fifo32_num_used(&fifo) =3D=3D 1); + + fifo32_destroy(&fifo); +} + + int main(int argc, char *argv[]) { g_test_init(&argc, &argv, NULL); @@ -445,5 +493,7 @@ int main(int argc, char *argv[]) g_test_add_func("/fifo8/peek_bufptr_wrap", test_fifo8_peek_bufptr_wrap= ); g_test_add_func("/fifo8/pop_bufptr", test_fifo8_pop_bufptr); g_test_add_func("/fifo8/pop_bufptr_wrap", test_fifo8_pop_bufptr_wrap); + g_test_add_func("/fifo32/pushpop", test_fifo32_pushpop); + g_test_add_func("/fifo32/peek", test_fifo32_peek); return g_test_run(); } --=20 2.47.0.rc0.187.ge670bccf7e-goog