fix(freertos): Fix freertos example pytest script

This commit updates the freertos/basic_freertos_smp_usage pytest script
to not follow a rigid order when testing against output logs as tasks
can spawn on any core in no particular order.
This commit is contained in:
Sudeep Mohanty
2024-09-27 12:04:57 +02:00
parent d50a64ea84
commit 1a547e34f1
2 changed files with 17 additions and 14 deletions

View File

@ -78,7 +78,7 @@ static void inc_num_atomic_iter(void *arg)
static void inc_num_mutex(void *arg)
{
int task_index = *(int*)arg;
int task_index = (int)arg;
ESP_LOGI(TAG, "mutex task %d created", task_index);
while (!timed_out) {
@ -159,7 +159,7 @@ int comp_lock_entry_func(int argc, char **argv)
s_global_num = 0;
// create 2 tasks to increase a shared number in turn
for (thread_id = 0; thread_id < SHARE_RES_THREAD_NUM; thread_id++) {
xTaskCreatePinnedToCore(inc_num_mutex, NULL, 4096, &thread_id, TASK_PRIO_3, NULL, tskNO_AFFINITY);
xTaskCreatePinnedToCore(inc_num_mutex, NULL, 4096, (void *)thread_id, TASK_PRIO_3, NULL, tskNO_AFFINITY);
}
// time out and stop running after 5 seconds

View File

@ -13,10 +13,13 @@ def test_creating_task(
dut.expect(r'esp32(?:[a-zA-Z]\d)?>')
# test creating_task
dut.write('create_task')
dut.expect('create task example: task#0 is running on core#0')
dut.expect('create task example: task#1 is running on core#0')
dut.expect(r'create task example: task#2 is running on core#\d')
dut.expect(r'create task example: task#3 is running on core#\d')
expected_patterns = [
'create task example: task#0 is running on core#0',
'create task example: task#1 is running on core#0',
r'create task example: task#2 is running on core#\d',
r'create task example: task#3 is running on core#\d',
]
dut.expect(expected_patterns, expect_all=True)
@pytest.mark.esp32c3
@ -46,14 +49,14 @@ def test_locks(
dut.expect(r'esp32(?:[a-zA-Z]\d)?>')
# test locks
dut.write('lock')
dut.expect(r'lock example: mutex task took \d+ us on core\d')
dut.expect(r'lock example: spinlock task took \d+ us on core\d')
dut.expect(r'lock example: atomic task took \d+ us on core\d')
dut.expect(r'task0 read value = 0 on core #\d')
dut.expect('task0 set value = 1')
dut.expect(r'task\d read value = 1 on core #\d')
dut.expect(r'task\d set value = 2')
dut.expect(r'task0 read value = 2 on core #\d')
expected_patterns = [
r'lock example: mutex task took \d+ us on core\d',
r'lock example: spinlock task took \d+ us on core\d',
r'lock example: atomic task took \d+ us on core\d',
r'task\d read value = \d on core #\d',
r'task\d set value = \d',
]
dut.expect(expected_patterns, expect_all=True)
@pytest.mark.esp32c3