1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-20 03:53:49 +01:00
Benjamin Valentin b5ea78ad47 core/msg: make msg_avail() return 0 on no queue
For the caller there should be no difference if there is no message
in the queue and if there can't be a message in the queue.

The current API works as one would expect if there is a message queue,
but once called from a thread that does not have a message queue
configured, code that does

    while (msg_avail())

will end up in an infinite loop.

Remove this foot-gun from the API by making the return value of
msg_avail() independend of the availability of a message queue.
2021-11-29 12:04:16 +01:00

37 lines
1.2 KiB
Python
Executable File

#!/usr/bin/env python3
# Copyright (C) 2021 Freie Universität Berlin,
#
# 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 <julian.holzwarth@fu-berlin.de>
import os
import sys
from testrunner import run
def testfunc(child):
child.expect("No messages or no message queue")
child.expect("No messages or no message queue")
child.expect(r"Message queue of thread \d+\r\n")
child.expect_exact('size: 8 (avail: 8)')
if os.environ.get('BOARD') == 'native':
child.expect_exact('type: 0x0000, content: 0 ((nil))')
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)')
child.expect_exact('DONE')
if __name__ == "__main__":
sys.exit(run(testfunc))