diff mbox series

[v2,1/3] tests/unit: Strengthen FIFO8 tests

Message ID 20240906132909.78886-2-philmd@linaro.org
State New
Headers show
Series tests/unit: Slightly expand FIFO8 tests | expand

Commit Message

Philippe Mathieu-Daudé Sept. 6, 2024, 1:29 p.m. UTC
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é <philmd@linaro.org>
---
 tests/unit/test-fifo.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

Comments

Mark Cave-Ayland Sept. 6, 2024, 9:01 p.m. UTC | #1
On 06/09/2024 14:29, Philippe Mathieu-Daudé wrote:

> 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é <philmd@linaro.org>
> ---
>   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;

That's a fair point: otherwise it could be easier for a bug in the Fifo8 
implementation to slip through:

Reviewed-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>


ATB,

Mark.
diff mbox series

Patch

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;