1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

Merge pull request #12632 from aabadie/pr/tests/memarray_autotest

tests/memarray: add python script for automatic testing
This commit is contained in:
Francisco 2019-11-28 11:52:56 +01:00 committed by GitHub
commit a0783afe6d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 40 additions and 1 deletions

View File

@ -25,9 +25,15 @@
#include "memarray.h"
#define MAX_NUMBER_BLOCKS (10)
#define MESSAGE_SIZE (8U)
#ifndef MAX_NUMBER_BLOCKS
#define MAX_NUMBER_BLOCKS (10)
#endif
#ifndef NUMBER_OF_TESTS
#define NUMBER_OF_TESTS (12)
#endif
extern int _ps_handler(int argc, char **argv);
@ -94,6 +100,9 @@ void free_memory(struct block_t *head)
int main(void)
{
printf("MAX_NUMBER_BLOCKS: %d\n", MAX_NUMBER_BLOCKS);
printf("NUMBER_OF_TESTS: %d\n", NUMBER_OF_TESTS);
memory_block_init();
int count = 0;

30
tests/memarray/tests/01-run.py Executable file
View File

@ -0,0 +1,30 @@
#!/usr/bin/env python3
# Copyright (C) 2019 Inria
#
# This file is subject to the terms and conditions of the GNU Lesser
# General Public License v2.1. See the file LICENSE in the top level
# directory for more details.
import sys
from testrunner import run
def testfunc(child):
child.expect(r'MAX_NUMBER_BLOCKS: (\d+)\r\n')
max_number_blocks = int(child.match.group(1))
child.expect(r'NUMBER_OF_TESTS: (\d+)\r\n')
number_of_tests = int(child.match.group(1))
for test in range(number_of_tests):
child.expect_exact("TEST #{}:".format(test + 1))
for i in range(max_number_blocks):
child.expect(r'\({}, @@@@@@@\) Allocated \d+ Bytes at 0x[a-z0-9]+,'
r' total [0-9]+\r\n'.format(i))
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("Finishing")
if __name__ == "__main__":
sys.exit(run(testfunc))