From patchwork Fri Sep 6 13:12:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 825978 Delivered-To: patch@linaro.org Received: by 2002:adf:a345:0:b0:367:895a:4699 with SMTP id d5csp795531wrb; Fri, 6 Sep 2024 06:13:42 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUQ6qvBEGZ4d8i52DQpQP7PYYm7AccRhbHwnYFffoYyrFMwOVKaucoGleT1rhSoZJSZqo32Gw==@linaro.org X-Google-Smtp-Source: AGHT+IEfgQFLHcaiILK+Hu8GQpbIVdCE6n6dYbazzotyvF1ZBKnMLrbC2+36FHOMjgeiT38BEz+l X-Received: by 2002:a05:6808:1806:b0:3e0:34fc:2352 with SMTP id 5614622812f47-3e034fc25bcmr109259b6e.19.1725628421924; Fri, 06 Sep 2024 06:13:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725628421; cv=none; d=google.com; s=arc-20240605; b=CVvYEqaKRexUyd11rCkN563ONyz4SU8oMJEXNbkmJIOT7k2O8MrZkOKK8J6mV56StK HU5qmMAWgQKAIyT82jo4k26H9fBSuTe/HUqOp4MsXYxLAAv6BvVHXsubHzEAfyy0OShk ahcYoeKWVrJfyNF9e74SnExz6p1Ae/E/kk3a1WUgB/mew+PBi96eQi7EXsgND0j4QX6F cgNAKRWRiJIt2ye+a4oRib1CRsVexa6g0x+s5Gn5DMCUCv6K2+u7PMoJrFjAdZ/+momz decF+foujr+EbBTId7+iYaGq0RaEy5SaOMSEIx5XBUDWjPfGMWxl+otUtEsnNDjc4BmX yiSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=xlW+VXX8IoMKaXfrpm1YbHCvNIPynyn64aMHFczAQAA=; fh=17KGNHbtERzR+bqU7cV4aLplPWnDbeAlR1/rKtROqks=; b=TzOKuMX0FCkweJWAaYcWMSZioQ8qQs7Siu/R/V6sA0ILeuXkLLmh7dFJeNO5bZtxTu IVzLtdx+8KCt4pyZlN9InDMYQjEzPR7VJwwDh39IzJ+hwk9B6OwfhP5H5A0mj2DO9SDq Vdhzmq6Z25dyOQe0YuuzKOhRYzHX5toDE/03oDp6twxD3t892oHhVgd85DrtH7nBHOFD XmVRAYPhEJrcBqZSluZbhw4rTIg7TlTnx6kidEavmYfibLSlqdo+qBoc5OHxjzlpz4Uk jbts1sSjinZhnUV/t+Bg7QT2rwuEf7n3J+hDj/0y5djbqxRp4HvatBcxFqqSYXdA5TkX QLmg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="MUl+/r2e"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id ada2fe7eead31-49bdbfc1233si810854137.644.2024.09.06.06.13.41 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 06 Sep 2024 06:13:41 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="MUl+/r2e"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1smYlL-0003Xc-43; Fri, 06 Sep 2024 09:12:31 -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 ) id 1smYlJ-0003T4-O6 for qemu-devel@nongnu.org; Fri, 06 Sep 2024 09:12:29 -0400 Received: from mail-ej1-x62e.google.com ([2a00:1450:4864:20::62e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1smYlI-0006WQ-6Y for qemu-devel@nongnu.org; Fri, 06 Sep 2024 09:12:29 -0400 Received: by mail-ej1-x62e.google.com with SMTP id a640c23a62f3a-a89c8db505bso281646866b.0 for ; Fri, 06 Sep 2024 06:12:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1725628346; x=1726233146; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=xlW+VXX8IoMKaXfrpm1YbHCvNIPynyn64aMHFczAQAA=; b=MUl+/r2eV+Llh2jRFh4QKPcnmKGyKcbS/4jwIj4qLqDUp+nbcjD51vCjSZM3iGW1jx WfGnJmgIJZtBEtNb1/VfXl+QzgHfyZGgxrahREyll90oMvQGHBvtbE2DE1iBvB/IIRSQ 2u+EoVrvu07fVODGHfJ3/OTeQhC+bJJzU2ScwQt9nfvk2520ThpmcqRMijkTSqNqYPH6 YuLeh4QbuLpYizQlHHZ/A572iuhl8LmlnOC209bHYOcQvpDMPjYcA0oL+0qLJunyT7oV 5yjWwTgQ8aEMZmtGZx4VxsO+NDBB8QOFT0AZjcrcMAgHfmCOAA6WIypI5fFigM2kAelf 3DGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725628346; x=1726233146; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xlW+VXX8IoMKaXfrpm1YbHCvNIPynyn64aMHFczAQAA=; b=WkQeKNSayTnE7LCHq5Zmf60h97PNi4C8/jJV12kedZyYtKDCHScduIVpROTRzR6xA+ WOP55/AlFL6xVXp516oZzB+3SNq+izLGaFsH2eI4O0iYt/mIcWwTEafjd41wrbstny3p NdySo+azagyBgA17WpQKH5xM3/WBSiVm97G+4M/5SC+Uv0LETy2UsEz3MYHX0tRv4clZ DgJj6x/nSM4J3AHnT5xoizAAsnOOKkpFxmwchXecPpWHGQwnnmLcC+IyxByWT2BdxT3H lBmwcMoaQvu+7kNT7uxy+UZAoxGenwM99vl8wpp7RXiGjNXydoia+Lbnrs7It37CMpf8 rbUg== X-Gm-Message-State: AOJu0YzvqG41bmazg942cJHawL8VsU+fzz84S7/4DoCp6+LP5jkQgmsE FyZ2j3YDVSzHaXG8utlhnFgXUCMJAGcp0hzYUZeugvkzPS2v5NTzJwaADA6ECSKU1rlziwr/N1E 8 X-Received: by 2002:a17:907:703:b0:a86:78fd:1df0 with SMTP id a640c23a62f3a-a8a88668305mr207090666b.34.1725628345695; Fri, 06 Sep 2024 06:12:25 -0700 (PDT) Received: from localhost.localdomain ([80.215.236.92]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a8a8b7da1d0sm93248566b.50.2024.09.06.06.12.24 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 06 Sep 2024 06:12:25 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Mark Cave-Ayland , Octavian Purdila , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH 1/3] tests/unit: Strengthen FIFO8 tests Date: Fri, 6 Sep 2024 15:12:15 +0200 Message-ID: <20240906131217.78159-2-philmd@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240906131217.78159-1-philmd@linaro.org> References: <20240906131217.78159-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::62e; envelope-from=philmd@linaro.org; helo=mail-ej1-x62e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, 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, T_SCC_BODY_TEXT_LINE=-0.01 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Replace reused bytes { 0x1, 0x2, 0x3, 0x4 } by { 0x9, 0xa, 0xb, 0xc } to be sure a different value is overwritten. Signed-off-by: Philippe Mathieu-Daudé --- tests/unit/test-fifo.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/unit/test-fifo.c b/tests/unit/test-fifo.c index 1e54cde871..60436a7600 100644 --- a/tests/unit/test-fifo.c +++ b/tests/unit/test-fifo.c @@ -22,7 +22,7 @@ static void test_fifo8_pop_bufptr_wrap(void) { Fifo8 fifo; uint8_t data_in1[] = { 0x1, 0x2, 0x3, 0x4 }; - uint8_t data_in2[] = { 0x5, 0x6, 0x7, 0x8, 0x1, 0x2 }; + uint8_t data_in2[] = { 0x5, 0x6, 0x7, 0x8, 0x9, 0xa }; const uint8_t *buf; uint32_t count; @@ -112,7 +112,7 @@ static void test_fifo8_pop_buf_wrap(void) { Fifo8 fifo; uint8_t data_in1[] = { 0x1, 0x2, 0x3, 0x4 }; - uint8_t data_in2[] = { 0x5, 0x6, 0x7, 0x8, 0x1, 0x2, 0x3, 0x4 }; + uint8_t data_in2[] = { 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc }; uint8_t data_out[4]; int count; @@ -126,8 +126,8 @@ static void test_fifo8_pop_buf_wrap(void) g_assert(count == 4); count = fifo8_pop_buf(&fifo, data_out, 4); g_assert(count == 4); - g_assert(data_out[0] == 0x1 && data_out[1] == 0x2 && - data_out[2] == 0x3 && data_out[3] == 0x4); + g_assert(data_out[0] == 0x9 && data_out[1] == 0xa && + data_out[2] == 0xb && data_out[3] == 0xc); g_assert(fifo8_num_used(&fifo) == 0); fifo8_destroy(&fifo); @@ -157,8 +157,8 @@ static void test_fifo8_peek_buf_wrap(void) { Fifo8 fifo; uint8_t data_in1[] = { 0x1, 0x2, 0x3, 0x4 }; - uint8_t data_in2[] = { 0x5, 0x6, 0x7, 0x8, 0x1, 0x2, 0x3, 0x4 }; - uint8_t data_out[4]; + uint8_t data_in2[] = { 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc }; + uint8_t data_out[8]; int count; fifo8_create(&fifo, 8); From patchwork Fri Sep 6 13:12:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 825977 Delivered-To: patch@linaro.org Received: by 2002:adf:a345:0:b0:367:895a:4699 with SMTP id d5csp795493wrb; Fri, 6 Sep 2024 06:13:35 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVOhEj5Bv8jMdfDHliB/M6GIgm1fj3kEwmHUUNo0CWWWWyBEdcZ6cR84jk4Hhl0UZ17rJ2v5Q==@linaro.org X-Google-Smtp-Source: AGHT+IHVxWRM0PDgb8Hq1t9b0Y/Y+dlN7YQtIopwXlV0DY2Tvz8yqu0OyvUZU5orXW8CNytOoAuU X-Received: by 2002:a05:6871:6a4:b0:277:f399:705b with SMTP id 586e51a60fabf-27b82db44afmr2939522fac.1.1725628415726; Fri, 06 Sep 2024 06:13:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725628415; cv=none; d=google.com; s=arc-20240605; b=BO2UCVtR/Ypsn8IQY6/IXQBlq15sEP08AKZqBhFkw8jGQHNozEReIxqjNbi6wAmWTH 0KbiZMtNu6kdMlPUWO61WXDr19iklPqCwiUt5O2wMc9lB4z+FIxNj7Pvwrlfw9dU+E61 ZnUKoBA7UFLNmC60NIXRPYZpg1qXqBbsdUWAuPqaWEOfXLNNRzoB309Oez9klBnuELwn oyCk1yZauAnnjR27UXu6zg82+zQygynfRZAKwa30vvgRC4uPi771WWwDxy1eW2vBRD0G Uo94aRf4fDPS0suyba5zQwdgr71GKH/MHjrwiiY/ed/MQcd44Zr3N7SFabwQp4xf4DAm WeuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=0Irjp7OCdsQc3Bib9jvUGA7OwDJdphBQq6tqlaHYr+o=; fh=17KGNHbtERzR+bqU7cV4aLplPWnDbeAlR1/rKtROqks=; b=ceHHUi4V9/wQDcbyKsKfauOMhSussPfUI0m262XSBbVguDNuGv3SWZzH1x4UmI8eug ih8lZuszXxgklwEt6Dchfz+7EsotCa1wBjuflFdxTW444tn4dw9Kd58FC7Ddxu0rFWUl Sor3oKOcJJ/jrqS5DYgf16KegW6exliNSa7ZNG2ppo+JJtFsmUyc/bH2cSjk5uPnMotk gm+X9IPXojtQS1I7bNU/lVLt/g9Oudlok4leEganQNfSWpVpZhFgqjv8hAaeviUe0JcQ ygF8AbFEeekqJdHOiBWJbgc2Rka//z2ype7UiO1wL5uX0LVFKoMpVOCZ5KWwiRaRO9sM CROw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MY3L1fUy; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id ada2fe7eead31-49bdbff895esi763469137.796.2024.09.06.06.13.35 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 06 Sep 2024 06:13:35 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MY3L1fUy; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1smYlP-0003mE-O8; Fri, 06 Sep 2024 09:12:35 -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 ) id 1smYlO-0003l3-Dx for qemu-devel@nongnu.org; Fri, 06 Sep 2024 09:12:34 -0400 Received: from mail-ej1-x62d.google.com ([2a00:1450:4864:20::62d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1smYlM-0006Wh-V9 for qemu-devel@nongnu.org; Fri, 06 Sep 2024 09:12:34 -0400 Received: by mail-ej1-x62d.google.com with SMTP id a640c23a62f3a-a8682bb5e79so276562166b.2 for ; Fri, 06 Sep 2024 06:12:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1725628351; x=1726233151; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=0Irjp7OCdsQc3Bib9jvUGA7OwDJdphBQq6tqlaHYr+o=; b=MY3L1fUy80YXZHUDWmsK8hXO2xQX/xwQyUSvwf56eBZxqYnNpCdlHoxFk3bV9+NdvE +Sv6nav+J4EMEi2Y1nS96HFEX2fgWK5yCKxUEcOJxA5YkjpzcTAF9iqODW2Af9d3kaIS 6iQ+2Y4k7V6b0kVXzcONI6v62Fm7L/bXepz6s2RrjHT8eRSldrM1o3zl51tPvWOn2KMY 6XJe4purszdK6fj6z03fWVUK7i17BOcNADa/1LqQut5mJeHoIP4y4P0VvFvpovOcawso HKneBKxth6Bler5/oEUSC4khAfOiUYGRr2N1WHh8s8yXKfCQrlL/GTcSuBwCKVVoIq3n Aycw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725628351; x=1726233151; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0Irjp7OCdsQc3Bib9jvUGA7OwDJdphBQq6tqlaHYr+o=; b=rMtrXHw8qg1zfjsvLPLfpqY7Oit53VvEM50f9vxqsgrSF56XNBDcrAX4IoCDhGbCe0 1N2J8yNlFCBYd9SS1ZOwi+UoYDvnPo0anronMypM5vekR+lUIcsASWQdtMehMSGxAotH i+41MaEz00mCKOTZP++rSPwyuQorB8USCgZwuPi7H1iibqFLvr362wedZzJvvIx+8JIg zn+KxcxfZleDyBkMkLuGJwzFdNVGKZknJxFkk8p2RmUq4FD+8F2jM+7JDJq4Waoe5nS9 CGK4ZKEu+tWVmIpTLExjB3KFZlAz2TCq6MMIjgueca0hFu1Rs/g53KpFuCaCZJYVDfHF oNBQ== X-Gm-Message-State: AOJu0YxqWiW1rNDH8jMXRHQXbd6W6v0yXVFJZIriIhzKIhrF49X1CmXs PZkebBGKLk0TrJacO81PTlIEZt09oDV5SgwHVmJgu3vTwG9oJyAMMU1vT1I43dk6qHIrfaZE6/6 l X-Received: by 2002:a17:907:3e88:b0:a77:e48d:bae with SMTP id a640c23a62f3a-a8a88667cc2mr224309866b.28.1725628350981; Fri, 06 Sep 2024 06:12:30 -0700 (PDT) Received: from localhost.localdomain ([80.215.236.92]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a8a6236d369sm275343366b.98.2024.09.06.06.12.30 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 06 Sep 2024 06:12:30 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Mark Cave-Ayland , Octavian Purdila , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH 2/3] tests/unit: Expand test_fifo8_peek_buf_wrap() coverage Date: Fri, 6 Sep 2024 15:12:16 +0200 Message-ID: <20240906131217.78159-3-philmd@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240906131217.78159-1-philmd@linaro.org> References: <20240906131217.78159-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::62d; envelope-from=philmd@linaro.org; helo=mail-ej1-x62d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, 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, T_SCC_BODY_TEXT_LINE=-0.01 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Test fifo8_peek_buf() can fill a buffer with wrapped data. Signed-off-by: Philippe Mathieu-Daudé --- tests/unit/test-fifo.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/unit/test-fifo.c b/tests/unit/test-fifo.c index 60436a7600..4706bf8708 100644 --- a/tests/unit/test-fifo.c +++ b/tests/unit/test-fifo.c @@ -174,6 +174,13 @@ static void test_fifo8_peek_buf_wrap(void) g_assert(data_out[0] == 0x5 && data_out[1] == 0x6 && data_out[2] == 0x7 && data_out[3] == 0x8); + count = fifo8_peek_buf(&fifo, data_out, 8); + g_assert(count == 8); + g_assert(data_out[0] == 0x5 && data_out[1] == 0x6 && + data_out[2] == 0x7 && data_out[3] == 0x8); + g_assert(data_out[4] == 0x9 && data_out[5] == 0xa && + data_out[6] == 0xb && data_out[7] == 0xc); + g_assert(fifo8_num_used(&fifo) == 8); fifo8_destroy(&fifo); } From patchwork Fri Sep 6 13:12:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 825976 Delivered-To: patch@linaro.org Received: by 2002:adf:a345:0:b0:367:895a:4699 with SMTP id d5csp795259wrb; Fri, 6 Sep 2024 06:13:14 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVtU32TyXnx+UwMwHpg83sxy1aEEaeJ7EVl9RPmC2f0CQQbo8MaomF11H3lghnAwgkJ+0sutA==@linaro.org X-Google-Smtp-Source: AGHT+IEtOF6WaM0bjaOa1KojK0StaCSuBPw+9fYIjbGLb+fq/TZK9t6aTas/h5aRKVHBslkGl+4U X-Received: by 2002:a05:6870:d38e:b0:278:2697:ee5a with SMTP id 586e51a60fabf-27b83024d7emr2917988fac.42.1725628393864; Fri, 06 Sep 2024 06:13:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725628393; cv=none; d=google.com; s=arc-20240605; b=Mlj4QUmI7zrYYAhhV9ZBG9R09OgOLeHX17oZqacd41QOzeAXCtIdahbzk28O1p07/6 cyvcQ5uxnpjOZqeh98DXn18wY/5ezmXtCs+IysG3BXaEW4ypLDmD1hBIox3UxiJyMFYD xJUO6albA/qe+GZ8RsFNbcd1GfF77LqB/67Hq9P85d0NGrfVuZyToyqrMdYQrwPEtyTC OP6H8koyOVUzsFLgDYgl44GyV+k1Gjw9CJGWuSqt4IPkfuLd55WGCxSQ9XdNoNfBjUXz dw1WhkufwhWZ6B5uZtVDXnlBewxzBdMJb8l8czLCZDMkbGqAMD0xcwpBnOOIqW/AaUrZ sx7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=1GD53cCFToaPHDaf/+msIM+Wg31jrU+mGaggw6OMsyo=; fh=17KGNHbtERzR+bqU7cV4aLplPWnDbeAlR1/rKtROqks=; b=lOT3NJfdcg9ZEpVB/IKxGQXZzt4Ep7fgy6/SUztlxSjfKkpp43mA8EiWDw9o35p6Ia 4dA/EpisOQT5Annse7Khq44cdO5WXH1gRALyd/L8C/yOAf5TvH59UFpNtc+GP5eWWEYe WvarNFjPamiKmLywqcou8WYP11FaOGL3TZ48hag2C5e1wf2R5lsOc6kCDi58i02DAwcP 7HwCl0jpn/VvdyInuABH+rVxY5TtwemF7czTiEaXu0x7vzrw8DolQDvNzpAgRM4T5p22 NgSu5a06GYJG3BowMAOtqOG4bAju+caoCbgNFup3uDwBIilPWfVecN3uxMZJfer5Qsmc jEaQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qY04hxEc; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 71dfb90a1353d-50129aa8cccsi565046e0c.196.2024.09.06.06.13.13 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 06 Sep 2024 06:13:13 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qY04hxEc; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1smYlW-0003xy-9f; Fri, 06 Sep 2024 09:12:42 -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 ) id 1smYlV-0003xG-3G for qemu-devel@nongnu.org; Fri, 06 Sep 2024 09:12:41 -0400 Received: from mail-lf1-x132.google.com ([2a00:1450:4864:20::132]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1smYlT-0006X4-0Q for qemu-devel@nongnu.org; Fri, 06 Sep 2024 09:12:40 -0400 Received: by mail-lf1-x132.google.com with SMTP id 2adb3069b0e04-53658f30749so732061e87.3 for ; Fri, 06 Sep 2024 06:12:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1725628356; x=1726233156; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=1GD53cCFToaPHDaf/+msIM+Wg31jrU+mGaggw6OMsyo=; b=qY04hxEcaxRbIaayk87lZg5BWEhyphMTnQeSsYWqGsguYFuS+2ZQcONhcoZbs3b4wH snUnMUXjd01z5ryRNAXOwEADXNW0EARvCMJSgT4CZPP3u/KYrZG3aqUhqh4F316kddx+ i383g2GrHCfi/R+wp5n13yUMrof7v09DvoRmnborC8KQRTY1cgHsGXAHe1MPWwoD72V7 vkLZvOwpEXalss44YLv9MpVaElBA1infRtAqPtOw+eQ9w8N7SIOt/KTRNHI915AWlU+g 5Xyexv+hxLZQiivHPL9cNh4NR2SDree2Q1JYLeW1ZALXQ1vIgwbqpaE/xMaUXkdfoa31 ewqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725628356; x=1726233156; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1GD53cCFToaPHDaf/+msIM+Wg31jrU+mGaggw6OMsyo=; b=Xnw9rkEIQzBlsaePEalQvkwOpkgy/4fKyycAe0vHUg24/pqf+bdJ4RMLG6r7FZ3ASa r9gE1/HWUMlMvixCMgL1sRf3syY1CvY4Jy8cWP26NfKUtGMRggMnvIcITsfeLqLX2zLT 8zErH22rIqeGKiwyRiwYtmB4KmPM2W1g+J61eVA9g+u7FDKUhw6fYb2X2Vul6WQ2zDMG xypMcXTuro5WHNB1Lh7m1QwGpuig93hVjtMNdm0sVrbfW8Nxp3mRluHO99TMEAi6NdHo jUCY5Yp9V/ZFKxg99IN5qgUW+aaC5geXIUFZJflxU56FLGb/xNir2VAy73Efqx1Bo6VD zMzQ== X-Gm-Message-State: AOJu0YyH7CYNycLIxDkPBw0inOFwohYdNotPlV6/mIVQFOoLa19yr7QO 3c/nmx1cBbqZ2FyomA4b2mtR8x/VVQAy/bfbCR4X4aDLpoE9mx15W08nMYySz/9BBtB3bOcZiLX m X-Received: by 2002:a05:6512:3f15:b0:52e:f2a6:8e1a with SMTP id 2adb3069b0e04-536587b51f7mr1934963e87.29.1725628356506; Fri, 06 Sep 2024 06:12:36 -0700 (PDT) Received: from localhost.localdomain ([80.215.236.92]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a8a83ed05c9sm122141066b.114.2024.09.06.06.12.35 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 06 Sep 2024 06:12:36 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Mark Cave-Ayland , Octavian Purdila , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH 3/3] tests/unit: Comment FIFO8 tests Date: Fri, 6 Sep 2024 15:12:17 +0200 Message-ID: <20240906131217.78159-4-philmd@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240906131217.78159-1-philmd@linaro.org> References: <20240906131217.78159-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::132; envelope-from=philmd@linaro.org; helo=mail-lf1-x132.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, 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, T_SCC_BODY_TEXT_LINE=-0.01 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Add comments describing how the FIFO evolves during each test. Signed-off-by: Philippe Mathieu-Daudé --- tests/unit/test-fifo.c | 190 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 188 insertions(+), 2 deletions(-) diff --git a/tests/unit/test-fifo.c b/tests/unit/test-fifo.c index 4706bf8708..14153c41fa 100644 --- a/tests/unit/test-fifo.c +++ b/tests/unit/test-fifo.c @@ -27,14 +27,36 @@ static void test_fifo8_pop_bufptr_wrap(void) uint32_t count; fifo8_create(&fifo, 8); + /* + * head --v-- tail used = 0 + * FIFO: [ . . . . . . . . ] + */ fifo8_push_all(&fifo, data_in1, sizeof(data_in1)); + /* + * head --v ]-- tail used = 4 + * FIFO: [ 1 2 3 4 . . . . ] + */ buf = fifo8_pop_bufptr(&fifo, 2, &count); + /* + * head --v ]-- tail used = 2 + * FIFO: [ 1 2 3 4 . . . . ] + * buf --^ count = 2 + */ g_assert(count == 2); g_assert(buf[0] == 0x1 && buf[1] == 0x2); fifo8_push_all(&fifo, data_in2, sizeof(data_in2)); + /* + * tail --]v-- head used = 8 + * FIFO: [ 9 a 3 4 5 6 7 8 ] + */ buf = fifo8_pop_bufptr(&fifo, 8, &count); + /* + * head --v ]-- tail used = 2 + * FIFO: [ 9 a 3 4 5 6 7 8 ] + * buf --^ count = 6 + */ g_assert(count == 6); g_assert(buf[0] == 0x3 && buf[1] == 0x4 && buf[2] == 0x5 && buf[3] == 0x6 && buf[4] == 0x7 && buf[5] == 0x8); @@ -51,9 +73,22 @@ static void test_fifo8_pop_bufptr(void) uint32_t count; fifo8_create(&fifo, 8); + /* + * head --v-- tail used = 0 + * FIFO: [ . . . . . . . . ] + */ fifo8_push_all(&fifo, data_in, sizeof(data_in)); + /* + * head --v ]-- tail used = 4 + * FIFO: [ 1 2 3 4 . . . . ] + */ buf = fifo8_pop_bufptr(&fifo, 2, &count); + /* + * head --v ]-- tail used = 2 + * FIFO: [ 1 2 3 4 . . . . ] + * buf --^ count = 2 + */ g_assert(count == 2); g_assert(buf[0] == 0x1 && buf[1] == 0x2); @@ -65,23 +100,50 @@ static void test_fifo8_peek_bufptr_wrap(void) { Fifo8 fifo; uint8_t data_in1[] = { 0x1, 0x2, 0x3, 0x4 }; - uint8_t data_in2[] = { 0x5, 0x6, 0x7, 0x8, 0x1, 0x2 }; + uint8_t data_in2[] = { 0x5, 0x6, 0x7, 0x8, 0x9, 0xa }; const uint8_t *buf; uint32_t count; fifo8_create(&fifo, 8); + /* + * head --v-- tail used = 0 + * FIFO: { . . . . . . . . } + */ fifo8_push_all(&fifo, data_in1, sizeof(data_in1)); + /* + * head --v ]-- tail used = 4 + * FIFO: { 1 2 3 4 . . . . } + */ buf = fifo8_peek_bufptr(&fifo, 2, &count); + /* + * head --v ]-- tail used = 4 + * FIFO: { 1 2 3 4 . . . . } + * buf: [ 1 2 ] count = 2 + */ g_assert(count == 2); g_assert(buf[0] == 0x1 && buf[1] == 0x2); buf = fifo8_pop_bufptr(&fifo, 2, &count); + /* + * head --v ]-- tail used = 2 + * FIFO: { 1 2 3 4 . . . . } + * buf: [ 1 2 ] count = 2 + */ g_assert(count == 2); g_assert(buf[0] == 0x1 && buf[1] == 0x2); fifo8_push_all(&fifo, data_in2, sizeof(data_in2)); + /* + * tail ---]v-- head used = 8 + * FIFO: { 9 a 3 4 5 6 7 8 } + */ buf = fifo8_peek_bufptr(&fifo, 8, &count); + /* + * tail --]v-- head used = 8 + * FIFO: { 9 a 3 4 5 6 7 8 } + * buf: [ 3 4 5 6 7 8 ] count = 6 + */ g_assert(count == 6); g_assert(buf[0] == 0x3 && buf[1] == 0x4 && buf[2] == 0x5 && buf[3] == 0x6 && buf[4] == 0x7 && buf[5] == 0x8); @@ -98,9 +160,22 @@ static void test_fifo8_peek_bufptr(void) uint32_t count; fifo8_create(&fifo, 8); + /* + * head --v-- tail used = 0 + * FIFO: { . . . . . . . . } + */ fifo8_push_all(&fifo, data_in, sizeof(data_in)); + /* + * head --v ]-- tail used = 4 + * FIFO: { 1 2 3 4 . . . . } + */ buf = fifo8_peek_bufptr(&fifo, 2, &count); + /* + * head --v ]-- tail used = 4 + * FIFO: { 1 2 3 4 . . . . } + * buf: [ 1 2 ] count = 2 + */ g_assert(count == 2); g_assert(buf[0] == 0x1 && buf[1] == 0x2); @@ -117,14 +192,38 @@ static void test_fifo8_pop_buf_wrap(void) int count; fifo8_create(&fifo, 8); + /* + * head --v-- tail used = 0 + * FIFO: { . . . . . . . . } + */ fifo8_push_all(&fifo, data_in1, sizeof(data_in1)); + /* + * head --v ]-- tail used = 4 + * FIFO: { 1 2 3 4 . . . . } + */ fifo8_pop_buf(&fifo, NULL, 4); + /* + * tail --]v-- head used = 0 + * FIFO: [ 1 2 3 4 . . . . ] + */ fifo8_push_all(&fifo, data_in2, sizeof(data_in2)); + /* + * tail --]v-- head used = 8 + * FIFO: { 9 a b c 5 6 7 8 } + */ count = fifo8_pop_buf(&fifo, NULL, 4); + /* + * head --v ]-- tail used = 4 + * FIFO: { 9 a b c 5 6 7 8 } + */ g_assert(count == 4); count = fifo8_pop_buf(&fifo, data_out, 4); + /* + * tail --]v-- head used = 0 + * FIFO: { 9 a b c 5 6 7 8 } + */ g_assert(count == 4); g_assert(data_out[0] == 0x9 && data_out[1] == 0xa && data_out[2] == 0xb && data_out[3] == 0xc); @@ -141,9 +240,21 @@ static void test_fifo8_pop_buf(void) int count; fifo8_create(&fifo, 8); + /* + * head --v-- tail used = 0 + * FIFO: { . . . . . . . . } + */ fifo8_push_all(&fifo, data_in, sizeof(data_in)); + /* + * head --v ]-- tail used = 4 + * FIFO: { 1 2 3 4 . . . . } + */ count = fifo8_pop_buf(&fifo, NULL, 4); + /* + * tail --]v-- head used = 0 + * FIFO: { 1 2 3 4 . . . . } + */ g_assert(count == 4); count = fifo8_pop_buf(&fifo, data_out, 4); g_assert(data_out[0] == 0x5 && data_out[1] == 0x6 && @@ -162,19 +273,45 @@ static void test_fifo8_peek_buf_wrap(void) int count; fifo8_create(&fifo, 8); + /* + * head --v-- tail used = 0 + * FIFO: { . . . . . . . . } + */ fifo8_push_all(&fifo, data_in1, sizeof(data_in1)); + /* + * head --v ]-- tail used = 4 + * FIFO: { 1 2 3 4 . . . . } + */ fifo8_pop_buf(&fifo, NULL, 4); + /* + * tail --]v-- head used = 0 + * FIFO: { 1 2 3 4 . . . . } + */ fifo8_push_all(&fifo, data_in2, sizeof(data_in2)); + /* + * tail --]v-- head used = 8 + * FIFO: { 9 a b c 5 6 7 8 } + */ count = fifo8_peek_buf(&fifo, NULL, 4); g_assert(count == 4); count = fifo8_peek_buf(&fifo, data_out, 4); + /* + * tail --]v-- head used = 8 + * FIFO: { 9 a b c 5 6 7 8 } + * buf: [ 5 6 7 8 ] count = 4 + */ g_assert(count == 4); g_assert(data_out[0] == 0x5 && data_out[1] == 0x6 && data_out[2] == 0x7 && data_out[3] == 0x8); count = fifo8_peek_buf(&fifo, data_out, 8); + /* + * tail --]v-- head used = 8 + * FIFO: { 9 a b c 5 6 7 8 } + * buf: [ 5 6 7 8 9 a b c ] count = 8 + */ g_assert(count == 8); g_assert(data_out[0] == 0x5 && data_out[1] == 0x6 && data_out[2] == 0x7 && data_out[3] == 0x8); @@ -193,14 +330,27 @@ static void test_fifo8_peek_buf(void) int count; fifo8_create(&fifo, 8); + /* + * head --v-- tail used = 0 + * FIFO: { . . . . . . . . } + */ fifo8_push_all(&fifo, data_in, sizeof(data_in)); + /* + * head --v ]-- tail used = 4 + * FIFO: { 1 2 3 4 . . . . } + */ count = fifo8_peek_buf(&fifo, NULL, 4); g_assert(count == 4); + g_assert(data_out[0] == 0xff && data_out[1] == 0xff && data_out[2] == 0xff && data_out[3] == 0xff); - count = fifo8_peek_buf(&fifo, data_out, 4); + /* + * head --v ]-- tail used = 4 + * FIFO: { 1 2 3 4 . . . . } + * buf: [ 1 2 3 4 ] count = 4 + */ g_assert(count == 4); g_assert(data_out[0] == 0x1 && data_out[1] == 0x2 && data_out[2] == 0x3 && data_out[3] == 0x4); @@ -215,12 +365,28 @@ static void test_fifo8_peek(void) uint8_t c; fifo8_create(&fifo, 8); + /* + * head --v-- tail used = 0 + * FIFO: { . . . . . . . . } + */ fifo8_push(&fifo, 0x1); + /* + * head --v]-- tail used = 1 + * FIFO: { 1 . . . . . . . } + */ fifo8_push(&fifo, 0x2); + /* + * head --v ]-- tail used = 2 + * FIFO: { 1 2 . . . . . . } + */ c = fifo8_peek(&fifo); g_assert(c == 0x1); fifo8_pop(&fifo); + /* + * head --v]-- tail used = 1 + * FIFO: { 1 2 . . . . . . } + */ c = fifo8_peek(&fifo); g_assert(c == 0x2); @@ -234,12 +400,32 @@ static void test_fifo8_pushpop(void) uint8_t c; fifo8_create(&fifo, 8); + /* + * head --v-- tail used = 0 + * FIFO: { . . . . . . . . } + */ fifo8_push(&fifo, 0x1); + /* + * head --v]-- tail used = 1 + * FIFO: { 1 . . . . . . . } + */ fifo8_push(&fifo, 0x2); + /* + * head --v ]-- tail used = 2 + * FIFO: { 1 2 . . . . . . } + */ c = fifo8_pop(&fifo); + /* + * head --v]-- tail used = 1 + * FIFO: { 1 2 . . . . . . } + */ g_assert(c == 0x1); c = fifo8_pop(&fifo); + /* + * tail --]v-- head used = 0 + * FIFO: { 1 2 . . . . . . } + */ g_assert(c == 0x2); g_assert(fifo8_num_used(&fifo) == 0);