MCPcopy Create free account
hub / github.com/Simple-XX/SimpleKernel / test_affinity_set_get

Function test_affinity_set_get

tests/system_test/affinity_test.cpp:64–108  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

62// ===========================================================================
63
64void test_affinity_set_get(void* /*arg*/) {
65 klog::Info("=== Affinity Set/Get Test ===");
66
67 bool passed = true;
68
69 // Set affinity to CPU 0 only
70 uint64_t new_mask = 1UL;
71 int ret = sys_sched_setaffinity(0, sizeof(uint64_t), &new_mask);
72 if (ret != 0) {
73 klog::Err("test_affinity_set_get: setaffinity returned {}, expected 0",
74 ret);
75 passed = false;
76 }
77
78 // Read back and verify
79 uint64_t read_mask = 0;
80 if (passed) {
81 ret = sys_sched_getaffinity(0, sizeof(uint64_t), &read_mask);
82 if (ret != 0) {
83 klog::Err("test_affinity_set_get: getaffinity returned {}, expected 0",
84 ret);
85 passed = false;
86 }
87 }
88
89 if (passed && read_mask != 1UL) {
90 klog::Err("test_affinity_set_get: read_mask={:#x}, expected 0x1",
91 read_mask);
92 passed = false;
93 }
94
95 // Restore default affinity
96 uint64_t all_mask = UINT64_MAX;
97 (void)sys_sched_setaffinity(0, sizeof(uint64_t), &all_mask);
98
99 if (passed) {
100 klog::Info("Affinity Set/Get Test: PASSED");
101 } else {
102 klog::Err("Affinity Set/Get Test: FAILED");
103 g_tests_failed++;
104 }
105
106 g_tests_completed++;
107 sys_exit(passed ? 0 : 1);
108}
109
110// ===========================================================================
111// test_affinity_other_task

Callers

nothing calls this directly

Calls 5

InfoFunction · 0.85
sys_sched_setaffinityFunction · 0.85
ErrFunction · 0.85
sys_sched_getaffinityFunction · 0.85
sys_exitFunction · 0.85

Tested by

no test coverage detected