MCPcopy Create free account
hub / github.com/F-Stack/f-stack / test_thread_priority

Function test_thread_priority

dpdk/app/test/test_threads.c:78–127  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

76}
77
78static int
79test_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
129static int
130test_thread_affinity(void)

Callers

nothing calls this directly

Calls 3

rte_thread_createFunction · 0.50
rte_thread_set_priorityFunction · 0.50
rte_thread_get_priorityFunction · 0.50

Tested by

no test coverage detected