summaryrefslogtreecommitdiff
path: root/test/smp/regression/threadx_byte_memory_basic_test.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/smp/regression/threadx_byte_memory_basic_test.c')
-rw-r--r--test/smp/regression/threadx_byte_memory_basic_test.c47
1 files changed, 29 insertions, 18 deletions
diff --git a/test/smp/regression/threadx_byte_memory_basic_test.c b/test/smp/regression/threadx_byte_memory_basic_test.c
index 36f41331..45a2518d 100644
--- a/test/smp/regression/threadx_byte_memory_basic_test.c
+++ b/test/smp/regression/threadx_byte_memory_basic_test.c
@@ -1,8 +1,20 @@
+/***************************************************************************/
+/* Copyright (c) 2024 Microsoft Corporation */
+/* Copyright (c) 2026 Eclipse ThreadX contributors */
+/* */
+/* This program and the accompanying materials are made available under */
+/* the terms of the MIT License which is available at */
+/* https://opensource.org/licenses/MIT. */
+/* */
+/* SPDX-License-Identifier: MIT */
+/***************************************************************************/
+
/* This test is designed to test simple memory byte pool creation, deletion, and
allocates and releases. */
#include <stdio.h>
#include "tx_api.h"
+#include "threadx_test_port.h"
typedef struct BYTE_MEMORY_TEST_STRUCT
{
@@ -91,7 +103,7 @@ CHAR *pointer;
/* Attempt to create a byte pool from a timer. */
pointer = (CHAR *) 0x30000;
- status = tx_byte_pool_create(&pool_2, "pool 2", pointer, 108);
+ status = tx_byte_pool_create(&pool_2, "pool 2", pointer, TX_TEST_BYTE_POOL_BYTES(108));
/* Check status. */
if (status != TX_CALLER_ERROR)
@@ -103,7 +115,7 @@ CHAR *pointer;
/* Attempt to create a byte pool with an invalid size. */
status = _txe_byte_pool_create(&pool_3, "pool 3", pointer,
- 108, (sizeof(TX_BYTE_POOL)+1));
+ TX_TEST_BYTE_POOL_BYTES(108), (sizeof(TX_BYTE_POOL)+1));
/* Check status. */
if (status != TX_POOL_ERROR)
@@ -186,7 +198,7 @@ UINT status;
/* Attempt to create a byte pool from an ISR. */
- status = tx_byte_pool_create(&pool_2, "pool 0", (void *) 0x100000, 108);
+ status = tx_byte_pool_create(&pool_2, "pool 0", (void *) 0x100000, TX_TEST_BYTE_POOL_BYTES(108));
/* Check status. */
if (status != TX_CALLER_ERROR)
@@ -256,8 +268,8 @@ CHAR *pointer;
}
/* Create byte pools 0 and 1. */
- status = tx_byte_pool_create(&pool_0, "pool 0", pointer, 108);
- pointer = pointer + 108;
+ status = tx_byte_pool_create(&pool_0, "pool 0", pointer, TX_TEST_BYTE_POOL_CAPACITY_BYTES(24, 3));
+ pointer = pointer + TX_TEST_BYTE_POOL_CAPACITY_BYTES(24, 3);
/* Check status. */
if (status != TX_SUCCESS)
@@ -267,8 +279,8 @@ CHAR *pointer;
test_control_return(1);
}
- status = tx_byte_pool_create(&pool_1, "pool 1", pointer, 200);
- pointer = pointer + 200;
+ status = tx_byte_pool_create(&pool_1, "pool 1", pointer, TX_TEST_BYTE_POOL_BYTES(200));
+ pointer = pointer + TX_TEST_BYTE_POOL_BYTES(200);
/* Check status. */
if (status != TX_SUCCESS)
@@ -279,9 +291,9 @@ CHAR *pointer;
}
/* Test for search pointer issue on wrapped seach with prior block to search pointer merged. */
- status = tx_byte_pool_create(&pool_4, "pool 4", pointer, 300);
+ status = tx_byte_pool_create(&pool_4, "pool 4", pointer, TX_TEST_BYTE_POOL_CAPACITY_BYTES(84, 3));
pool_4_memory = pointer;
- pointer = pointer + 300;
+ pointer = pointer + TX_TEST_BYTE_POOL_CAPACITY_BYTES(84, 3);
/* Check status. */
if (status != TX_SUCCESS)
@@ -353,7 +365,7 @@ CHAR *pointer_2;
CHAR *pointer_3;
CHAR *pointer_4;
INT i;
-ULONG array[20];
+TX_TEST_POINTER_WORD array[20];
UCHAR *save_search;
@@ -394,7 +406,7 @@ UCHAR *save_search;
/* Try to create a NULL pool. */
pointer_1 = (CHAR *) 0x30000;
- status = tx_byte_pool_create(TX_NULL, "pool 0", pointer_1, 108);
+ status = tx_byte_pool_create(TX_NULL, "pool 0", pointer_1, TX_TEST_BYTE_POOL_BYTES(108));
/* Check status. */
if (status != TX_POOL_ERROR)
@@ -406,7 +418,7 @@ UCHAR *save_search;
}
/* Try to create the same pool. */
- status = tx_byte_pool_create(&pool_0, "pool 0", pointer_1, 108);
+ status = tx_byte_pool_create(&pool_0, "pool 0", pointer_1, TX_TEST_BYTE_POOL_BYTES(108));
/* Check status. */
if (status != TX_POOL_ERROR)
@@ -418,7 +430,7 @@ UCHAR *save_search;
}
/* Try to create a pool with a NULL start address. */
- status = tx_byte_pool_create(&pool_2, "pool 2", TX_NULL, 108);
+ status = tx_byte_pool_create(&pool_2, "pool 2", TX_NULL, TX_TEST_BYTE_POOL_BYTES(108));
/* Check status. */
if (status != TX_PTR_ERROR)
@@ -626,7 +638,7 @@ UCHAR *save_search;
/* Test another bad block release.... pool pointer is not a valid pool! */
array[0] = 0;
- array[1] = (ULONG) &array[3];
+ TX_TEST_STORE_POINTER(array[1], &array[3]);
array[2] = 0;
array[3] = 0;
status = _tx_byte_release(&array[2]);
@@ -865,7 +877,7 @@ UCHAR *save_search;
}
/* Move the search pointer to the third block to exercise that code in the byte search algorithm. */
- pool_0.tx_byte_pool_search = (UCHAR *) pointer_3-8;
+ pool_0.tx_byte_pool_search = (UCHAR *) pointer_3 - TX_TEST_BYTE_POOL_SEARCH_OFFSET;
/* Now allocate the block again. */
status = tx_byte_allocate(&pool_0, (VOID **) &pointer_2, 24, TX_NO_WAIT);
@@ -885,7 +897,7 @@ UCHAR *save_search;
status += tx_byte_release(pointer_1);
/* Move the search pointer to the third block to exercise that code in the byte search algorithm. */
- pool_0.tx_byte_pool_search = (UCHAR *) pointer_3-8;
+ pool_0.tx_byte_pool_search = (UCHAR *) pointer_3 - TX_TEST_BYTE_POOL_SEARCH_OFFSET;
/* Allocate a large block to force the search pointer update. */
status = tx_byte_allocate(&pool_0, (VOID **) &pointer_3, 88, TX_NO_WAIT);
@@ -961,7 +973,7 @@ UCHAR *save_search;
}
/* Create pool 4. */
- status = tx_byte_pool_create(&pool_4, "pool 4", pool_4_memory, 300);
+ status = tx_byte_pool_create(&pool_4, "pool 4", pool_4_memory, TX_TEST_BYTE_POOL_CAPACITY_BYTES(84, 3));
/* Check status. */
if (status != TX_SUCCESS)
@@ -1061,4 +1073,3 @@ UCHAR *save_search;
printf("SUCCESS!\n");
test_control_return(0);
}
-