From patchwork Fri Sep 6 13:29:07 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: 825982 Delivered-To: patch@linaro.org Received: by 2002:adf:a345:0:b0:367:895a:4699 with SMTP id d5csp803732wrb; Fri, 6 Sep 2024 06:30:54 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCX5WjIwDlL3dtJY8mWN15Ne8+7r5zGlvYpSS7qw3KyfEOwX6z61d2oVgM3zt+rGn8ox0uaVkA==@linaro.org X-Google-Smtp-Source: AGHT+IF4mrMXfQ06muOIKsKyVS4V19hGpbw/UdwYi4SxBxIqwATYFPQaG0mMUc9P4b6AzajDixcZ X-Received: by 2002:a25:a2c4:0:b0:e1d:3a7f:2f85 with SMTP id 3f1490d57ef6-e1d3a7f30c9mr1445868276.24.1725629453839; Fri, 06 Sep 2024 06:30:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725629453; cv=none; d=google.com; s=arc-20240605; b=Y4EUr/S1Ud0QTp4/ivw18vBQSIC0hjwZUOFABalVDZSMSAqgqB+07wMb+PHTGX8CP0 OzcJKawLJsIwwsfBpAWc18+g85dxZrT8LET5aW+kSl04SY+ne1Lani/li7LHCxdtjpH3 kj/XctrK4Z7XI1e1x9YSowGCnVkLLq9qDQH7+NykWDQ6DHU8ejgexLpcYJty9mJSxaxm jiBPXW88EQ1eSQ1smyc3T+pL/mlpNijZ7FcefxFcRj93FpTsgpBol1bOCtAmEbgTiNGw q/JxiRe7555MZtB9yj2OIUxNMtfQ8YKIudx6E4W3H5gmeiojKjq3TSa0Iyqox8gMwQ1f TrBQ== 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=7XRVry1WIYJD1fRST7vCZVz9k3xY9E87VG9DCYoaJ1s=; fh=17KGNHbtERzR+bqU7cV4aLplPWnDbeAlR1/rKtROqks=; b=BS/Y+VddVxV75OIBBF7Y+xP9BPYWDlMbM1uFb2xygutclxmQ+IdmwQhyh+OciO4VeE n9oZ3cINOJbvx/0tQB7EV04Cmlqvz8jelELK/2XRon7EUcIdTie0L87HrLXzaNNr0blu 0WAeqGEANRs6AESYMhaof2Aj9Sy7vuaZUr9FV6F3DhJD+S0up15Mj/h9f/Mq2BL75Pv/ NMbx35dM6+zbOYfnVfzI4Tz68naVhhbTKHzdtXtuPEbpRfO5stsKJ6mEAfA4e/LRmZXr 8949oQVHLuHhCU5FCdFICjjSp6mMAijxf3B4MsolcodFbzcoZ5Iyhv7oDv+JxW9P3I3/ ozdQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dLlkR+F0; 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 6a1803df08f44-6c53065f4edsi2935426d6.265.2024.09.06.06.30.53 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 06 Sep 2024 06:30:53 -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=dLlkR+F0; 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 1smZ1h-0003ht-BC; Fri, 06 Sep 2024 09:29:25 -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 1smZ1f-0003et-DV for qemu-devel@nongnu.org; Fri, 06 Sep 2024 09:29:23 -0400 Received: from mail-lf1-x136.google.com ([2a00:1450:4864:20::136]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1smZ1d-0008NH-Jw for qemu-devel@nongnu.org; Fri, 06 Sep 2024 09:29:23 -0400 Received: by mail-lf1-x136.google.com with SMTP id 2adb3069b0e04-53438aa64a4so2155283e87.3 for ; Fri, 06 Sep 2024 06:29:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1725629359; x=1726234159; 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=7XRVry1WIYJD1fRST7vCZVz9k3xY9E87VG9DCYoaJ1s=; b=dLlkR+F0BAyrjr75eWpp3Qhh6guLGSMWcj3ZMH6xikwANLUtqJbSrOIa36QSleWJ2+ 80Dj9Hb8eSp4d4rImyS5iA5WsrG/7vuZIbEby4AdwDJF9VhPd+nC156nk/iA1OXMz4Ma /+GPgEVcIFzBZC9HzX+wAttHIXYJ3sKEgV6KqQ3lDEFVy2bL0r8cbZLyR9xMgtKt5KpP A6Omfh2IA6FmP0VxQHn946KEiyOQ6E8lDWlawRH0AkLRBxxJK7Y1kOH0bBM9vngk/ns/ 0ZI2i5Sn6d2SSzsIxL62tbCr2sJUNPq9M/bSMMjF/6ODtNO5rfp63ZFtH7/gq06GcJIg TDXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725629359; x=1726234159; 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=7XRVry1WIYJD1fRST7vCZVz9k3xY9E87VG9DCYoaJ1s=; b=MBDDmaqDTv3amnjV5zUYu+eVkqLO1cRp1gn/6SKcBZ2Pcy8zhfARofE9Erv0AAqfM9 s1CJWLKjrjqNoetG0goqbIQ+Kzv+sQgGZvLY77IucrhN+SpbdtP3i4SXHwBwhE6I4JrR 8o3J+l2FDSAvEgg+X6zIeM4jaOd93FGgoMwzcyb+jMoIW1CXB1JkZ/zWfmocWqXC1d0k FSFiTV/DNNcxAlQsufAFYpvVVfSvh9qP9gtZ2m1+MMIea4ZUVmOuePZ4ehrGFfctLcrX MXdXezjAcxJ8gtKK3oL9Vyodoxo8lbOdfeOKeIFe0COe9E+QZZh4uvxW1zYYcZeRBG5i pvLw== X-Gm-Message-State: AOJu0YwXivycP0JNVwAgx38+8PCTGA8ucqqltz/yzQZnzBM7nKF145wX ff+cdYC2bjCydqInXPSmUycGBwaIikULjiIElugjb3O89V0vG0sOGdu7Lpip77VoKuelidwgV3a r X-Received: by 2002:a05:6512:234b:b0:52c:9e82:a971 with SMTP id 2adb3069b0e04-536587a6845mr1520480e87.7.1725629358954; Fri, 06 Sep 2024 06:29:18 -0700 (PDT) Received: from localhost.localdomain ([80.215.236.92]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a8a62045832sm276070166b.75.2024.09.06.06.29.17 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 06 Sep 2024 06:29:18 -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 v2 1/3] tests/unit: Strengthen FIFO8 tests Date: Fri, 6 Sep 2024 15:29:07 +0200 Message-ID: <20240906132909.78886-2-philmd@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240906132909.78886-1-philmd@linaro.org> References: <20240906132909.78886-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::136; envelope-from=philmd@linaro.org; helo=mail-lf1-x136.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é Reviewed-by: Mark Cave-Ayland --- 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..9b3a4940d0 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; @@ -65,7 +65,7 @@ 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; @@ -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,7 +157,7 @@ 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_in2[] = { 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc }; uint8_t data_out[4]; int count; From patchwork Fri Sep 6 13:29:08 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: 825981 Delivered-To: patch@linaro.org Received: by 2002:adf:a345:0:b0:367:895a:4699 with SMTP id d5csp803501wrb; Fri, 6 Sep 2024 06:30:28 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUrzt3eP4606+QqKnCIBrzP7olQfNsL1wjjMusIfcr99PbPVJp6EogYld3qA+rBylR5J63JkQ==@linaro.org X-Google-Smtp-Source: AGHT+IFbNHhIDpK+AqkRLLfq6ODrrO+enaqQ4OHkNvLcaPlOV0i4ez8RB0wNIwH0j8u/vQEjQxBT X-Received: by 2002:a05:620a:294a:b0:7a1:632e:e576 with SMTP id af79cd13be357-7a99738ed5bmr262006285a.54.1725629428389; Fri, 06 Sep 2024 06:30:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725629428; cv=none; d=google.com; s=arc-20240605; b=Tw9KADU7ARI23GqYAHJD3tUaozuN2GSNhH8N6sVSQMFmpAkF2V52Fcim9oVHeK2vi0 /ZrAoyb+K/9kR3ybhs4LCn/ONrNgK9aL9pygQK8eho7rOPVRgjoYpYE0zYBNN8Yh+SVx /E2pZW2fckxePJ53FAJx+8/osCeQHczYPX44x2b1WE0Ou8OyLMNEUM2W/ZN1+YFayuHa +WysTR8TC7iSfC0fj9fm9aM2saPCeszPLNNH+kVyiQgCS3lkptggtf155fJsVcLUZydY /oUDfLJt/0+V6jfR/ZNCrwjXgbQrfJ/D7Ufv6JfpVUkVvHwSkuZyL7xszxv6gwkbUmXa iqBg== 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=ogUHnqKbTeP8dZWukr0SjuV7LdIfgZ21X5AZ6K1ackk=; fh=17KGNHbtERzR+bqU7cV4aLplPWnDbeAlR1/rKtROqks=; b=jcwuj2Dtpt+Eedlkfar9s5KZumKkXS0AA8tbYuOPXc8LrbOZ9kNpVlls6vMycuQy7U jGCVOYEzlMRStWQkz2eQA5tmytfrTD0Z64f/Jc60dukWv8pk9AeB0/33GBXpPWmF5V80 62u1wzR8gtcgygltKmRMJgKOc7evtQ2n+EWfU5Pq2m+bZulP4yzqDA/h+2jgqatTytAn EOIZ8xTuf3kyNf/AFbHtB9MOHTve2rEprFIgwxJ02es5K19Nvn7tQCNMS0bDNvssHPWM wA0n6CszXwH+0Qmlc3M0CvtzGw4VYmft6E+hZsiQTnYnoH+N3CBERqq6tshohXIMfdv6 42NQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xYRSPvcj; 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 af79cd13be357-7a9a1069befsi28757185a.376.2024.09.06.06.30.28 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 06 Sep 2024 06:30:28 -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=xYRSPvcj; 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 1smZ1m-0003ul-Il; Fri, 06 Sep 2024 09:29:30 -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 1smZ1k-0003oS-Br for qemu-devel@nongnu.org; Fri, 06 Sep 2024 09:29:28 -0400 Received: from mail-ed1-x52f.google.com ([2a00:1450:4864:20::52f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1smZ1i-0008O9-Lw for qemu-devel@nongnu.org; Fri, 06 Sep 2024 09:29:27 -0400 Received: by mail-ed1-x52f.google.com with SMTP id 4fb4d7f45d1cf-5c3c34e3c39so2986845a12.2 for ; Fri, 06 Sep 2024 06:29:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1725629364; x=1726234164; 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=ogUHnqKbTeP8dZWukr0SjuV7LdIfgZ21X5AZ6K1ackk=; b=xYRSPvcjTKZ1B7qJbtZFsgpZo7+/DjdFHtBtA5f1nxRbDCNCF79+TJYmupFl+D5IAn Ki1GB3Vu2PwooZhFvKRa0G+AviDJrD7a86cUZzbl6u+lCDk34peiRT/8I6NsFnA++j+s dj09h76grr8AvGTI9e4d71ZLmEt+bvW4UR1m91D6yWWFpZcZ135m+onxD5Ar3qMsR7+G /8UUnVUEfBdkxdQmO6M1tezclbiCwN1TbdUr684t2UuXOWENNxKBjemq5XTaZc72VkAZ gytpa8Jgu9X3SmaArk2fv7kJ2PYp2vaP3r6oFor2TAhovzqHreLajJw3ADcnmQ5lYljJ r4SA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725629364; x=1726234164; 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=ogUHnqKbTeP8dZWukr0SjuV7LdIfgZ21X5AZ6K1ackk=; b=ttI+oLKTHTUUd24Yd+L+AMY0DqLXQkjRhKA665dnZAm0L1aB3bwCX93Dc/ECtVhW2q 6BXyLWouohXYVeyZzKmrOFmWNtlekZJNiv7KWs8s+h/Ry6C6SclSCBQQo1UXvY87hi4h 5jL2RgTjnolyY9AXuJuxAb6QMqUhdzIJ5CryLuv7K/lz7GtNu9b3Wf5mxs6M6rO8hTFJ K2Auoz6g7hlc2eCi8H0AJErTrIfvCO+4JrLO/7ZpNonwstchbp7tHk2x4KtB3jCsOiaF ptZly4vpgrN+FnJVCjng58IO4/GfeMw/WuSyd2n7Wy+A1YA0z6F+5SBnIVBOCJe1pZ8Z v7Ig== X-Gm-Message-State: AOJu0YxWZnAC3kQZJfEg1OQs2lCGNXuW38U95QAJ89O7uX2cvwO94it0 V5I35vtZNkagURp001/ZnrBNzl1RI1J4fgD2+y/AdXolqqxMlceJ2Z0vh0xJSJx7a/JmB0TfAxW S X-Received: by 2002:a05:6402:13d4:b0:5c3:c3f5:592e with SMTP id 4fb4d7f45d1cf-5c3dc78db9fmr1650298a12.12.1725629364307; Fri, 06 Sep 2024 06:29:24 -0700 (PDT) Received: from localhost.localdomain ([80.215.236.92]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5c3cc52b376sm2441679a12.7.2024.09.06.06.29.23 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 06 Sep 2024 06:29:23 -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 v2 2/3] tests/unit: Expand test_fifo8_peek_buf_wrap() coverage Date: Fri, 6 Sep 2024 15:29:08 +0200 Message-ID: <20240906132909.78886-3-philmd@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240906132909.78886-1-philmd@linaro.org> References: <20240906132909.78886-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::52f; envelope-from=philmd@linaro.org; helo=mail-ed1-x52f.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é Reviewed-by: Mark Cave-Ayland --- tests/unit/test-fifo.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/unit/test-fifo.c b/tests/unit/test-fifo.c index 9b3a4940d0..fada526b6c 100644 --- a/tests/unit/test-fifo.c +++ b/tests/unit/test-fifo.c @@ -158,7 +158,7 @@ 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, 0x9, 0xa, 0xb, 0xc }; - uint8_t data_out[4]; + uint8_t data_out[8]; int count; fifo8_create(&fifo, 8); @@ -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:29:09 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: 825980 Delivered-To: patch@linaro.org Received: by 2002:adf:a345:0:b0:367:895a:4699 with SMTP id d5csp803446wrb; Fri, 6 Sep 2024 06:30:21 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUBMLLegcqNEOeEQYRB/c2PC9aaK79Jji2F9UDNs2xKuG1kw6wKo/ZQWW4WctukhUCwXygZWA==@linaro.org X-Google-Smtp-Source: AGHT+IEf2mwtBgyw3jkqrHL0GwVNnWemno98tkG+mgdT62a5k5QM9ZcVHQNk1zoKJIOjnolrL6Q/ X-Received: by 2002:a05:6214:5d8c:b0:6c5:1652:523a with SMTP id 6a1803df08f44-6c52852889fmr21233846d6.45.1725629421587; Fri, 06 Sep 2024 06:30:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725629421; cv=none; d=google.com; s=arc-20240605; b=SzHHUhXctO84aSlZ0O3LYk9aP49BYnkFatrvJrpcZpVxvNbIt9ub+K61ZhTwLWWlaY tFDLVjxleM3TpxEv6SBeqN+sR5aWGZAYG+EAO9JdPs2q37MG1L0xsNcPJlbt5mkYY/mp VA0QfLVkyyIKufgPcEEmCpH7BLHjzl1bCIx49VMT+V+n1tGsmCVA4x13aTzpsdCNEJkf U/0h9ZPe0HM4gIQx2PqhVJTeCO5Ym/CDEDVXu0iZPRaIuRKfBAYYHfYm1I306sXyZiuf 5awOxd/E1FbeeLuqmpL7ju5/jWwveyk25mQ8t6HEDhtoVkRDD4y3B/w3NuhqjlZmEWxy 0c9Q== 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=MmwJGfzR3xYXiphg+dD2S7iJ9AFQ7Rwo7vO79swYL6U=; fh=17KGNHbtERzR+bqU7cV4aLplPWnDbeAlR1/rKtROqks=; b=ewH3+0c4dzKbG658ELM4n26690Y/rKWMQZmQHcNd8+8RPiomQsH+Lewl3mOW68kS9e pu6fXX1T+Sd3329vI8kuhwH+4ysGAx6a0K8J8jjPUsV3aKI84HiYNg1cIB2SKM7CBhj4 nAJWcthRD8uch7Ct0SCulUvvQNq5MLdcX6kwnwWzFl8Ld+4c9Dq4bL4yztHG3FEzTzn4 xqjIWx3kVZutLuAXwKRrPSWJ5aPq3LlCc4sJ6p11qxGdDPtB/LdAZw2XjMgX3gA5/qI9 k5Qq4Ap4hfs73MAUp4FmmVQWDXERn8UCGQ2OqKoluL/2pEeBfsHd99FFYOCL07Qkaf2Y l8OA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DkrfM16B; 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 6a1803df08f44-6c530626031si2948676d6.111.2024.09.06.06.30.21 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 06 Sep 2024 06:30:21 -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=DkrfM16B; 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 1smZ2G-0004vu-Dc; Fri, 06 Sep 2024 09:30:00 -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 1smZ1r-0004IB-8k for qemu-devel@nongnu.org; Fri, 06 Sep 2024 09:29:36 -0400 Received: from mail-lj1-x22f.google.com ([2a00:1450:4864:20::22f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1smZ1o-0008OX-QI for qemu-devel@nongnu.org; Fri, 06 Sep 2024 09:29:34 -0400 Received: by mail-lj1-x22f.google.com with SMTP id 38308e7fff4ca-2f4f24263acso36036771fa.0 for ; Fri, 06 Sep 2024 06:29:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1725629370; x=1726234170; 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=MmwJGfzR3xYXiphg+dD2S7iJ9AFQ7Rwo7vO79swYL6U=; b=DkrfM16BEmbR27RdO3qaIybB7xsFhb8NPrmQaoEfQ5wWFPaHI/fw6SdhM4ax0Mm1H+ tgimQqWdEE3BuwfuWsI2+j1ZKTsfSRJnUN4CHKrj+SS/MxFrbh71J55I6TgFFnMVzNu1 z/gnshfo5AYm9iWfRFQoljYYdS0EuiOq0q1uU8RyhXzo8c1rnNjWFew2vvC4a//oeYux XViga3EkHpvMK4GXUll35sRKnUCtwKezgRM2PVk7JQGXR7Tk5BSDadPPkJ9kvEiEEeg6 P48MG4k+A+FX/OWY9xMIfduV3Mf5N9ejj8PUMBCBSIeNcU8bp0WbqlqVn4g5/RaEZmL/ BOOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725629370; x=1726234170; 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=MmwJGfzR3xYXiphg+dD2S7iJ9AFQ7Rwo7vO79swYL6U=; b=hWathfqekB2Ri5NZQ17ptJLkRwFjsmzBzExvdHqAbfpg9bTAHpPY+pqn69iAQTOPJX aN/hVobZtQ3y+0c+lInGPMk/bb4iv08zgyvGiqYXyA3oguw1ck44tofVvVrDUHBmToUV vHKBMAqcDp0rDajokq4VfGxNbB2L/YDlrukv5zvtO2PLwvRwBwvles4IjUJR58tS91ex E59FDM7isPz1ZSx+bP8D60wHY3Y5GF0+pD/xoo8C8F8OIelIPIlnnynmQXnzmiAhzvbj MFs+haqcNVP10KXAgsMm83LgaTfFL4Up7mS+R6GvFvJIa0XRCHEy8tMqqx89iZAnINMa GoGg== X-Gm-Message-State: AOJu0YwHZIyhmVr/BGn9ufv89HMv3KaWUlb3zhJ8XAwWQWR/VTMfbetd j0tCq7c97nn6lT34RUsKcSeM4OPZhqq+MCLDi3Yfmdx3qbTQau5Mv2q5Q80SxwFUnShMHdXR5T/ E X-Received: by 2002:a05:651c:b22:b0:2f7:5049:160 with SMTP id 38308e7fff4ca-2f7504902fbmr29979361fa.13.1725629369829; Fri, 06 Sep 2024 06:29:29 -0700 (PDT) Received: from localhost.localdomain ([80.215.236.92]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a8a61fbaeddsm278591966b.3.2024.09.06.06.29.28 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 06 Sep 2024 06:29:29 -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 v2 3/3] tests/unit: Comment FIFO8 tests Date: Fri, 6 Sep 2024 15:29:09 +0200 Message-ID: <20240906132909.78886-4-philmd@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240906132909.78886-1-philmd@linaro.org> References: <20240906132909.78886-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::22f; envelope-from=philmd@linaro.org; helo=mail-lj1-x22f.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é Reviewed-by: Mark Cave-Ayland --- tests/unit/test-fifo.c | 188 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 187 insertions(+), 1 deletion(-) diff --git a/tests/unit/test-fifo.c b/tests/unit/test-fifo.c index fada526b6c..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); @@ -70,18 +105,45 @@ static void test_fifo8_peek_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_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);