forked from RIOT-OS/RIOT
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request RIOT-OS#21047 from mguetschow/msg-queue-print
core/msg: re-enable IRQs before printing for highlevel_stdio
- Loading branch information
Showing
5 changed files
with
116 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,10 @@ | ||
include ../Makefile.core_common | ||
|
||
CONFIG_MSG_QUEUE_PRINT_MAX ?= 6 | ||
|
||
CFLAGS += -DCONFIG_MSG_QUEUE_PRINT_MAX=$(CONFIG_MSG_QUEUE_PRINT_MAX) | ||
|
||
include $(RIOTBASE)/Makefile.include | ||
|
||
# Make config available in Python test script via environment variables | ||
export CONFIG_MSG_QUEUE_PRINT_MAX |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
/* | ||
* Copyright (C) 2021 Freie Universität Berlin, | ||
* Copyright (C) 2021 Freie Universität Berlin | ||
* Copyright (C) 2024 TU Dresden | ||
* | ||
* 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 | ||
|
@@ -15,6 +16,7 @@ | |
* | ||
* | ||
* @author Julian Holzwarth <[email protected]> | ||
* @author Mikolai Gütschow <[email protected]> | ||
* | ||
*/ | ||
|
||
|
@@ -29,19 +31,37 @@ msg_t msg_queue[QUEUE_SIZE]; | |
|
||
int main(void) | ||
{ | ||
msg_t messages[QUEUE_SIZE]; | ||
msg_t msg; | ||
|
||
msg_queue_print(); | ||
msg_init_queue(msg_queue, QUEUE_SIZE); | ||
msg_queue_print(); | ||
|
||
/* fill message queue */ | ||
for (uintptr_t i = 0; i < QUEUE_SIZE; i++) { | ||
messages[i].type = i; | ||
messages[i].content.ptr = (void *) i; | ||
msg_send_to_self(&messages[i]); | ||
msg.type = i; | ||
msg.content.ptr = (void *) i; | ||
msg_send_to_self(&msg); | ||
} | ||
|
||
msg_queue_print(); | ||
|
||
/* drain half of message queue */ | ||
for (uintptr_t i = 0; i < QUEUE_SIZE/2; i++) { | ||
msg_receive(&msg); | ||
} | ||
|
||
msg_queue_print(); | ||
|
||
/* fill up message queue again */ | ||
for (uintptr_t i = QUEUE_SIZE; i < QUEUE_SIZE + QUEUE_SIZE/2; i++) { | ||
msg.type = i; | ||
msg.content.ptr = (void *) i; | ||
msg_send_to_self(&msg); | ||
} | ||
|
||
msg_queue_print(); | ||
|
||
puts("DONE"); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,60 @@ | ||
#!/usr/bin/env python3 | ||
|
||
# Copyright (C) 2021 Freie Universität Berlin, | ||
# Copyright (C) 2021 Freie Universität Berlin | ||
# Copyright (C) 2024 TU Dresden | ||
# | ||
# 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. | ||
|
||
# @author Julian Holzwarth <[email protected]> | ||
# @author Mikolai Gütschow <[email protected]> | ||
|
||
import os | ||
import sys | ||
from testrunner import run | ||
|
||
PRINT_MAX = int(os.getenv('CONFIG_MSG_QUEUE_PRINT_MAX')) | ||
|
||
def testfunc(child): | ||
child.expect("No messages or no message queue") | ||
|
||
def expect_none(child): | ||
child.expect("No messages or no message queue") | ||
|
||
|
||
def expect_some(child, size, avail, range_start): | ||
child.expect(r"Message queue of thread \d+\r\n") | ||
child.expect_exact('size: 8 (avail: 8)') | ||
if os.environ.get('BOARD') in ['native', 'native64']: | ||
child.expect_exact('type: 0x0000, content: 0 ((nil))') | ||
child.expect_exact(f'size: {size} (avail: {avail})') | ||
|
||
expect_less = avail > PRINT_MAX | ||
|
||
if expect_less: | ||
range_end = range_start + PRINT_MAX | ||
else: | ||
child.expect(r'type: 0x0000, content: 0 \((0x)?0+\)') | ||
child.expect_exact('type: 0x0001, content: 1 (0x1)') | ||
child.expect_exact('type: 0x0002, content: 2 (0x2)') | ||
child.expect_exact('type: 0x0003, content: 3 (0x3)') | ||
child.expect_exact('type: 0x0004, content: 4 (0x4)') | ||
child.expect_exact('type: 0x0005, content: 5 (0x5)') | ||
child.expect_exact('type: 0x0006, content: 6 (0x6)') | ||
child.expect_exact('type: 0x0007, content: 7 (0x7)') | ||
range_end = range_start + avail | ||
|
||
for counter in range(range_start, range_end): | ||
expect_content(child, counter) | ||
|
||
if expect_less: | ||
child.expect('...') | ||
|
||
|
||
def expect_content(child, counter): | ||
if counter == 0: | ||
if os.environ.get('BOARD') in ['native', 'native64']: | ||
child.expect_exact('type: 0x0000, content: 0 ((nil))') | ||
else: | ||
child.expect(r'type: 0x0000, content: 0 \((0x)?0+\)') | ||
else: | ||
child.expect_exact(f'type: 0x{counter:04x}, content: {counter} (0x{counter:x})') | ||
|
||
|
||
def testfunc(child): | ||
expect_none(child) | ||
expect_none(child) | ||
expect_some(child, 8, 8, 0) | ||
expect_some(child, 8, 4, 4) | ||
expect_some(child, 8, 8, 4) | ||
child.expect_exact('DONE') | ||
|
||
|
||
|