tests/thread_msg_seq: better guarantee sequence of output lines
This also changes to expectations of the test script. It does not rely on fixed thread IDs anymore, because boards with CDC ACM as stdio have a different first thread then boards with "normal" stdio via UART. This resolves issue #14256
This commit is contained in:
parent
1ad2d07181
commit
370e166f31
@ -57,16 +57,15 @@ int main(void)
|
|||||||
p_main = sched_active_pid;
|
p_main = sched_active_pid;
|
||||||
|
|
||||||
p1 = thread_create(t1_stack, sizeof(t1_stack), THREAD_PRIORITY_MAIN - 1,
|
p1 = thread_create(t1_stack, sizeof(t1_stack), THREAD_PRIORITY_MAIN - 1,
|
||||||
THREAD_CREATE_WOUT_YIELD | THREAD_CREATE_STACKTEST,
|
THREAD_CREATE_STACKTEST, sub_thread, "nr1", "nr1");
|
||||||
sub_thread, "nr1", "nr1");
|
|
||||||
p2 = thread_create(t2_stack, sizeof(t2_stack), THREAD_PRIORITY_MAIN - 1,
|
|
||||||
THREAD_CREATE_WOUT_YIELD | THREAD_CREATE_STACKTEST,
|
|
||||||
sub_thread, "nr2", "nr2");
|
|
||||||
p3 = thread_create(t3_stack, sizeof(t3_stack), THREAD_PRIORITY_MAIN - 1,
|
|
||||||
THREAD_CREATE_WOUT_YIELD | THREAD_CREATE_STACKTEST,
|
|
||||||
sub_thread, "nr3", "nr3");
|
|
||||||
|
|
||||||
|
p2 = thread_create(t2_stack, sizeof(t2_stack), THREAD_PRIORITY_MAIN - 1,
|
||||||
|
THREAD_CREATE_STACKTEST, sub_thread, "nr2", "nr2");
|
||||||
|
|
||||||
|
p3 = thread_create(t3_stack, sizeof(t3_stack), THREAD_PRIORITY_MAIN - 1,
|
||||||
|
THREAD_CREATE_STACKTEST, sub_thread, "nr3", "nr3");
|
||||||
puts("THREADS CREATED\n");
|
puts("THREADS CREATED\n");
|
||||||
|
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
msg_receive(&msg);
|
msg_receive(&msg);
|
||||||
printf("Got msg from pid %" PRIkernel_pid ": \"%s\"\n", msg.sender_pid, (char *)msg.content.ptr);
|
printf("Got msg from pid %" PRIkernel_pid ": \"%s\"\n", msg.sender_pid, (char *)msg.content.ptr);
|
||||||
|
|||||||
@ -3,19 +3,26 @@
|
|||||||
import sys
|
import sys
|
||||||
from testrunner import run
|
from testrunner import run
|
||||||
|
|
||||||
|
THREAD_NAMES = ("nr1", "nr2", "nr3")
|
||||||
|
|
||||||
|
|
||||||
def testfunc(child):
|
def testfunc(child):
|
||||||
child.expect_exact("START")
|
child.expect_exact("START")
|
||||||
|
# Collect pids
|
||||||
|
thread_pids = []
|
||||||
|
for name in THREAD_NAMES:
|
||||||
|
child.expect(r"THREAD {} \(pid:(\d+)\) start".format(name))
|
||||||
|
thread_pids.append(int(child.match.group(1)))
|
||||||
child.expect_exact("THREADS CREATED")
|
child.expect_exact("THREADS CREATED")
|
||||||
child.expect_exact("THREAD nr1 (pid:3) start")
|
|
||||||
child.expect_exact("THREAD nr1 (pid:3) end.")
|
for index, name in enumerate(THREAD_NAMES):
|
||||||
child.expect_exact("THREAD nr2 (pid:4) start")
|
child.expect(r"THREAD {} \(pid:(\d+)\) end.".format(name))
|
||||||
child.expect_exact("THREAD nr3 (pid:5) start")
|
thread_pid = int(child.match.group(1))
|
||||||
child.expect_exact("Got msg from pid 3: \"nr1\"")
|
assert thread_pid == thread_pids[index]
|
||||||
child.expect_exact("THREAD nr2 (pid:4) end.")
|
child.expect(r'Got msg from pid (\d+): "{}"'.format(name))
|
||||||
child.expect_exact("Got msg from pid 4: \"nr2\"")
|
thread_pid = int(child.match.group(1))
|
||||||
child.expect_exact("THREAD nr3 (pid:5) end.")
|
assert thread_pid == thread_pids[index]
|
||||||
child.expect_exact("Got msg from pid 5: \"nr3\"")
|
|
||||||
child.expect_exact("SUCCESS")
|
child.expect_exact("SUCCESS")
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user