| 125 | std::atomic<int> finished_cores = 0; |
| 126 | |
| 127 | auto spinlock_smp_test() -> bool { |
| 128 | for (int i = 0; i < 10000; ++i) { |
| 129 | (void)smp_lock.Lock(); |
| 130 | shared_counter++; |
| 131 | (void)smp_lock.UnLock(); |
| 132 | } |
| 133 | |
| 134 | int finished = finished_cores.fetch_add(1) + 1; |
| 135 | int total_cores = BasicInfoSingleton::instance().core_count; |
| 136 | |
| 137 | if (finished == total_cores) { |
| 138 | bool passed = (shared_counter == total_cores * 10000); |
| 139 | if (passed) { |
| 140 | klog::Info(" All cores finished. shared_counter = {}. OK.", |
| 141 | shared_counter); |
| 142 | } else { |
| 143 | klog::Err(" All cores finished. shared_counter = {}. EXPECTED {}. FAIL.", |
| 144 | shared_counter, total_cores * 10000); |
| 145 | } |
| 146 | return passed; |
| 147 | } |
| 148 | |
| 149 | return true; |
| 150 | } |
| 151 | |
| 152 | constexpr int BUFFER_SIZE = 8192; |
| 153 | int shared_buffer[BUFFER_SIZE]; |
no test coverage detected