|
1 | 1 | #!/usr/bin/env python3 |
2 | 2 |
|
3 | | -# Copyright (C) 2021 Freie Universität Berlin, |
| 3 | +# Copyright (C) 2021 Freie Universität Berlin |
| 4 | +# Copyright (C) 2024 TU Dresden |
4 | 5 | # |
5 | 6 | # This file is subject to the terms and conditions of the GNU Lesser |
6 | 7 | # General Public License v2.1. See the file LICENSE in the top level |
7 | 8 | # directory for more details. |
8 | 9 |
|
9 | 10 | # @author Julian Holzwarth <[email protected]> |
| 11 | +# @author Mikolai Gütschow <[email protected]> |
10 | 12 |
|
11 | 13 | import os |
12 | 14 | import sys |
13 | 15 | from testrunner import run |
14 | 16 |
|
| 17 | +PRINT_MAX = int(os.getenv('CONFIG_MSG_QUEUE_PRINT_MAX')) |
15 | 18 |
|
16 | | -def testfunc(child): |
17 | | - child.expect("No messages or no message queue") |
| 19 | + |
| 20 | +def expect_none(child): |
18 | 21 | child.expect("No messages or no message queue") |
| 22 | + |
| 23 | + |
| 24 | +def expect_some(child, size, avail, range_start): |
19 | 25 | child.expect(r"Message queue of thread \d+\r\n") |
20 | | - child.expect_exact('size: 8 (avail: 8)') |
21 | | - if os.environ.get('BOARD') in ['native', 'native64']: |
22 | | - child.expect_exact('type: 0x0000, content: 0 ((nil))') |
| 26 | + child.expect_exact(f'size: {size} (avail: {avail})') |
| 27 | + |
| 28 | + expect_less = avail > PRINT_MAX |
| 29 | + |
| 30 | + if expect_less: |
| 31 | + range_end = range_start + PRINT_MAX |
23 | 32 | else: |
24 | | - child.expect(r'type: 0x0000, content: 0 \((0x)?0+\)') |
25 | | - child.expect_exact('type: 0x0001, content: 1 (0x1)') |
26 | | - child.expect_exact('type: 0x0002, content: 2 (0x2)') |
27 | | - child.expect_exact('type: 0x0003, content: 3 (0x3)') |
28 | | - child.expect_exact('type: 0x0004, content: 4 (0x4)') |
29 | | - child.expect_exact('type: 0x0005, content: 5 (0x5)') |
30 | | - child.expect_exact('type: 0x0006, content: 6 (0x6)') |
31 | | - child.expect_exact('type: 0x0007, content: 7 (0x7)') |
| 33 | + range_end = range_start + avail |
| 34 | + |
| 35 | + for counter in range(range_start, range_end): |
| 36 | + expect_content(child, counter) |
| 37 | + |
| 38 | + if expect_less: |
| 39 | + child.expect('...') |
| 40 | + |
| 41 | + |
| 42 | +def expect_content(child, counter): |
| 43 | + if counter == 0: |
| 44 | + if os.environ.get('BOARD') in ['native', 'native64']: |
| 45 | + child.expect_exact('type: 0x0000, content: 0 ((nil))') |
| 46 | + else: |
| 47 | + child.expect(r'type: 0x0000, content: 0 \((0x)?0+\)') |
| 48 | + else: |
| 49 | + child.expect_exact(f'type: 0x{counter:04x}, content: {counter} (0x{counter:x})') |
| 50 | + |
| 51 | + |
| 52 | +def testfunc(child): |
| 53 | + expect_none(child) |
| 54 | + expect_none(child) |
| 55 | + expect_some(child, 8, 8, 0) |
| 56 | + expect_some(child, 8, 4, 4) |
| 57 | + expect_some(child, 8, 8, 4) |
32 | 58 | child.expect_exact('DONE') |
33 | 59 |
|
34 | 60 |
|
|
0 commit comments