| 76 | } |
| 77 | |
| 78 | static int |
| 79 | test_thread_priority(void) |
| 80 | { |
| 81 | rte_thread_t thread_id; |
| 82 | enum rte_thread_priority priority; |
| 83 | |
| 84 | thread_id_ready = 0; |
| 85 | RTE_TEST_ASSERT(rte_thread_create(&thread_id, NULL, thread_main, NULL) == 0, |
| 86 | "Failed to create thread"); |
| 87 | |
| 88 | while (__atomic_load_n(&thread_id_ready, __ATOMIC_ACQUIRE) == 0) |
| 89 | ; |
| 90 | |
| 91 | priority = RTE_THREAD_PRIORITY_NORMAL; |
| 92 | RTE_TEST_ASSERT(rte_thread_set_priority(thread_id, priority) == 0, |
| 93 | "Failed to set thread priority"); |
| 94 | RTE_TEST_ASSERT(rte_thread_get_priority(thread_id, &priority) == 0, |
| 95 | "Failed to get thread priority"); |
| 96 | RTE_TEST_ASSERT(priority == RTE_THREAD_PRIORITY_NORMAL, |
| 97 | "Priority set mismatches priority get"); |
| 98 | |
| 99 | priority = RTE_THREAD_PRIORITY_REALTIME_CRITICAL; |
| 100 | #ifndef RTE_EXEC_ENV_WINDOWS |
| 101 | RTE_TEST_ASSERT(rte_thread_set_priority(thread_id, priority) == ENOTSUP, |
| 102 | "Priority set to critical should fail"); |
| 103 | RTE_TEST_ASSERT(rte_thread_get_priority(thread_id, &priority) == 0, |
| 104 | "Failed to get thread priority"); |
| 105 | RTE_TEST_ASSERT(priority == RTE_THREAD_PRIORITY_NORMAL, |
| 106 | "Failed set to critical should have retained normal"); |
| 107 | #else |
| 108 | RTE_TEST_ASSERT(rte_thread_set_priority(thread_id, priority) == 0, |
| 109 | "Priority set to critical should succeed"); |
| 110 | RTE_TEST_ASSERT(rte_thread_get_priority(thread_id, &priority) == 0, |
| 111 | "Failed to get thread priority"); |
| 112 | RTE_TEST_ASSERT(priority == RTE_THREAD_PRIORITY_REALTIME_CRITICAL, |
| 113 | "Priority set mismatches priority get"); |
| 114 | #endif |
| 115 | |
| 116 | priority = RTE_THREAD_PRIORITY_NORMAL; |
| 117 | RTE_TEST_ASSERT(rte_thread_set_priority(thread_id, priority) == 0, |
| 118 | "Failed to set thread priority"); |
| 119 | RTE_TEST_ASSERT(rte_thread_get_priority(thread_id, &priority) == 0, |
| 120 | "Failed to get thread priority"); |
| 121 | RTE_TEST_ASSERT(priority == RTE_THREAD_PRIORITY_NORMAL, |
| 122 | "Priority set mismatches priority get"); |
| 123 | |
| 124 | __atomic_store_n(&thread_id_ready, 2, __ATOMIC_RELEASE); |
| 125 | |
| 126 | return 0; |
| 127 | } |
| 128 | |
| 129 | static int |
| 130 | test_thread_affinity(void) |
nothing calls this directly
no test coverage detected