1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-18 12:52:44 +01:00

tests/memarray: add extend/reduce tests

This commit is contained in:
Koen Zandberg 2020-12-19 00:26:56 +01:00
parent cb221aaaf0
commit 4868094fbf
No known key found for this signature in database
GPG Key ID: 0895A893E6D2985B
3 changed files with 63 additions and 2 deletions

View File

@ -1,3 +1,7 @@
BOARD_INSUFFICIENT_MEMORY := \
arduino-duemilanove \
arduino-nano \
arduino-uno \
atmega328p \
nucleo-l011k4 \
#

View File

@ -32,11 +32,11 @@
#endif
#ifndef NUMBER_OF_TESTS
#define NUMBER_OF_TESTS (12)
#define NUMBER_OF_TESTS (1)
#endif
#ifndef NUMBER_OF_LOOPS
#define NUMBER_OF_LOOPS (2)
#define NUMBER_OF_LOOPS (1)
#endif
@ -50,6 +50,7 @@ struct block_t {
};
struct block_t block_storage_data[MAX_NUMBER_BLOCKS];
struct block_t block_storage_data_extend[MAX_NUMBER_BLOCKS];
memarray_t block_storage;
int total = 0;
@ -141,6 +142,48 @@ int main(void)
count++;
}
puts("Extend and reduce tests");
printf("Memarray available: %u\n",
(unsigned)memarray_available(&block_storage));
/* Extend with second block */
memarray_extend(&block_storage, block_storage_data_extend,
MAX_NUMBER_BLOCKS);
printf("Memarray available: %u\n",
(unsigned)memarray_available(&block_storage));
/* remove the original block */
int res = memarray_reduce(&block_storage, block_storage_data,
MAX_NUMBER_BLOCKS);
printf("Memarray reduction: %d available: %u\n",
res, (unsigned)memarray_available(&block_storage));
/* try to remove original block a second time */
res = memarray_reduce(&block_storage, block_storage_data,
MAX_NUMBER_BLOCKS);
printf("Memarray reduction: %d available: %u\n",
res, (unsigned)memarray_available(&block_storage));
/* remove the extension block */
res = memarray_reduce(&block_storage, block_storage_data_extend,
MAX_NUMBER_BLOCKS);
printf("Memarray reduction: %d available: %u\n",
res, (unsigned)memarray_available(&block_storage));
/* extend again with the original block */
memarray_extend(&block_storage, block_storage_data, MAX_NUMBER_BLOCKS);
/* remove one element */
memarray_alloc(&block_storage);
printf("Memarray available: %u\n",
(unsigned)memarray_available(&block_storage));
/* try to reduce with a missing element */
res = memarray_reduce(&block_storage, block_storage_data, MAX_NUMBER_BLOCKS);
printf("Memarray reduction: %d available: %u\n",
res, (unsigned)memarray_available(&block_storage));
printf("Finishing\n");
_ps_handler(0, NULL);

View File

@ -27,6 +27,20 @@ def testfunc(child):
for i in range(max_number_blocks):
child.expect(r'Free \({}\) \d+ Bytes at 0x[a-z0-9]+,'
' total [0-9]+\r\n'.format(i))
child.expect_exact("Extend and reduce tests")
child.expect_exact("Memarray available: {}".format(max_number_blocks))
child.expect_exact("Memarray available: {}".format(2 * max_number_blocks))
child.expect_exact("Memarray reduction: 0 available: {}"
"".format(max_number_blocks))
child.expect_exact("Memarray reduction: -1 available: {}"
"".format(max_number_blocks))
child.expect_exact("Memarray reduction: 0 available: 0")
child.expect_exact("Memarray available: {}".format(max_number_blocks - 1))
child.expect_exact("Memarray reduction: -1 available: {}"
"".format(max_number_blocks - 1))
child.expect_exact("Finishing")