Two Functions cmd_test_xtimer_mutex_lock_timeout_low_prio_thread and thread_low_prio_test are added. This testfunction will test xtimer_mutex_lock_timeout with two threads (main thread and lower prio than main thread). The main thread creates another thread and sleeps. While the main thread sleeps the other thread takes the mutex and wakes the main thread up. Then the main thread calls xtimer_mutex_lock_timeout and the second thread unlocks the mutex and the main thread gets it and waits for the created thread to end. Has test messages showing the thread count. To make sure the created thread ends. (test messages may be removed in the future)
45 lines
1.4 KiB
Python
Executable File
45 lines
1.4 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
# Copyright (C) 2019 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 sys
|
|
import pexpect
|
|
from testrunner import run
|
|
|
|
|
|
def testfunc(child):
|
|
# Try to wait for the shell
|
|
for _ in range(0, 10):
|
|
child.sendline("help")
|
|
if child.expect_exact(["> ", pexpect.TIMEOUT], timeout=1) == 0:
|
|
break
|
|
child.sendline("mutex_timeout_long_unlocked")
|
|
child.expect("starting test: xtimer mutex lock timeout")
|
|
child.expect("OK")
|
|
child.expect_exact("> ")
|
|
child.sendline("mutex_timeout_long_locked")
|
|
child.expect("starting test: xtimer mutex lock timeout")
|
|
child.expect("OK")
|
|
child.expect_exact("> ")
|
|
child.sendline("mutex_timeout_long_locked_low")
|
|
child.expect("starting test: xtimer mutex lock timeout with thread")
|
|
child.expect("threads = 2")
|
|
child.expect("THREAD low prio: start")
|
|
child.expect("MAIN THREAD: calling xtimer_mutex_lock_timeout")
|
|
child.expect("OK")
|
|
child.expect("threads = 3")
|
|
child.expect("MAIN THREAD: waiting for created thread to end")
|
|
child.expect("THREAD low prio: exiting low")
|
|
child.expect("threads = 2")
|
|
child.expect_exact("> ")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(run(testfunc))
|