From 658151da3e26dd7684d9d0c2b636eaa2810ae7a4 Mon Sep 17 00:00:00 2001 From: Kumar Gala Date: Thu, 25 Mar 2021 12:13:08 -0500 Subject: [PATCH] tests: device: tweak test to test linker sorting There was a linker script change the broke the sorting such that priority 2 and 20 would not necessary get sorted correctly. Modify the test to try and catch any such issues in the future. We modify the DEVICE_DEFINE of the larger priority first, so if the linker isn't sorting it would get linked first in theory, and we also tweak the priority value from 4 to 20 so if we aren't sorting correctly between 2 and 20 we'll catch that. Signed-off-by: Kumar Gala --- tests/kernel/device/src/test_driver_init.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/kernel/device/src/test_driver_init.c b/tests/kernel/device/src/test_driver_init.c index f8b27220bdf..087f56d0932 100644 --- a/tests/kernel/device/src/test_driver_init.c +++ b/tests/kernel/device/src/test_driver_init.c @@ -150,6 +150,14 @@ DEVICE_DEFINE(my_driver_level_4, MY_DRIVER_LV_4, &my_driver_lv_4_init, device_pm_control_nop, NULL, NULL, APPLICATION, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, &funcs_my_drivers); +/* We use priority value of 20 to create a possible sorting conflict with + * priority value of 2. So if the linker sorting isn't woring correctly + * we'll find out. + */ +DEVICE_DEFINE(my_driver_priority_4, MY_DRIVER_PRI_4, + &my_driver_pri_4_init, device_pm_control_nop, + NULL, NULL, POST_KERNEL, 20, &funcs_my_drivers); + DEVICE_DEFINE(my_driver_priority_1, MY_DRIVER_PRI_1, &my_driver_pri_1_init, device_pm_control_nop, NULL, NULL, POST_KERNEL, 1, &funcs_my_drivers); @@ -161,7 +169,3 @@ DEVICE_DEFINE(my_driver_priority_2, MY_DRIVER_PRI_2, DEVICE_DEFINE(my_driver_priority_3, MY_DRIVER_PRI_3, &my_driver_pri_3_init, device_pm_control_nop, NULL, NULL, POST_KERNEL, 3, &funcs_my_drivers); - -DEVICE_DEFINE(my_driver_priority_4, MY_DRIVER_PRI_4, - &my_driver_pri_4_init, device_pm_control_nop, - NULL, NULL, POST_KERNEL, 4, &funcs_my_drivers);