[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 02/25] tests/unit: add fifo32 tests
From: |
Octavian Purdila |
Subject: |
[PATCH 02/25] tests/unit: add fifo32 tests |
Date: |
Wed, 18 Sep 2024 12:22:30 -0700 |
Add push/pop and peek tests for fifo32.
Signed-off-by: Octavian Purdila <tavip@google.com>
---
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"
const VMStateInfo vmstate_info_uint32;
const VMStateInfo vmstate_info_buffer;
@@ -432,6 +433,53 @@ static void test_fifo8_pushpop(void)
fifo8_destroy(&fifo);
}
+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) == 2);
+
+ e = fifo32_pop(&fifo);
+ g_assert(e == 0x11121314);
+ g_assert(fifo32_num_used(&fifo) == 1);
+
+ e = fifo32_peek(&fifo);
+ g_assert(e == 0x21222324);
+
+ g_assert(fifo32_num_used(&fifo) == 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) == 2);
+
+ e = fifo32_peek(&fifo);
+ g_assert(e == 0x11121314);
+ g_assert(fifo32_num_used(&fifo) == 2);
+
+ e = fifo32_pop(&fifo);
+ g_assert(e == 0x11121314);
+ g_assert(fifo32_num_used(&fifo) == 1);
+
+ e = fifo32_peek(&fifo);
+ g_assert(e == 0x21222324);
+ g_assert(fifo32_num_used(&fifo) == 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();
}
--
2.46.0.662.g92d0881bb0-goog
- [PATCH 00/25] NXP i.MX RT595, Octavian Purdila, 2024/09/18
- [PATCH 01/25] fifo32: add peek function, Octavian Purdila, 2024/09/18
- [PATCH 02/25] tests/unit: add fifo32 tests,
Octavian Purdila <=
- [PATCH 04/25] Add mcux-soc-svd subproject, Octavian Purdila, 2024/09/18
- [PATCH 06/25] hw/misc/flexcomm.c: add common fifo functionality, Octavian Purdila, 2024/09/18
- [PATCH 03/25] scripts: add script to generate C header files from SVD XML files, Octavian Purdila, 2024/09/18
- [PATCH 05/25] hw/misc: add support for flexcomm, Octavian Purdila, 2024/09/18
- [PATCH 07/25] hw/char: add support for flexcomm usart, Octavian Purdila, 2024/09/18
- [PATCH 08/25] hw/i2c: add support for flexcomm i2c, Octavian Purdila, 2024/09/18