Changeset a35b458 in mainline for kernel/test
- Timestamp:
- 2018-03-02T20:10:49Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f1380b7
- Parents:
- 3061bc1
- git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-02-28 17:38:31)
- git-committer:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:10:49)
- Location:
- kernel/test
- Files:
-
- 26 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/test/atomic/atomic1.c
r3061bc1 ra35b458 35 35 { 36 36 atomic_t a; 37 37 38 38 atomic_set(&a, 10); 39 39 if (atomic_get(&a) != 10) 40 40 return "Failed atomic_set()/atomic_get()"; 41 41 42 42 if (atomic_postinc(&a) != 10) 43 43 return "Failed atomic_postinc()"; 44 44 if (atomic_get(&a) != 11) 45 45 return "Failed atomic_get() after atomic_postinc()"; 46 46 47 47 if (atomic_postdec(&a) != 11) 48 48 return "Failed atomic_postdec()"; 49 49 if (atomic_get(&a) != 10) 50 50 return "Failed atomic_get() after atomic_postdec()"; 51 51 52 52 if (atomic_preinc(&a) != 11) 53 53 return "Failed atomic_preinc()"; 54 54 if (atomic_get(&a) != 11) 55 55 return "Failed atomic_get() after atomic_preinc()"; 56 56 57 57 if (atomic_predec(&a) != 10) 58 58 return "Failed atomic_predec()"; 59 59 if (atomic_get(&a) != 10) 60 60 return "Failed atomic_get() after atomic_predec()"; 61 61 62 62 return NULL; 63 63 } -
kernel/test/avltree/avltree1.c
r3061bc1 ra35b458 56 56 { 57 57 avltree_node_t *tmp; 58 58 59 59 if (!node) 60 60 return NULL; 61 61 62 62 if (node->lft) { 63 63 tmp = test_tree_parents(node->lft); … … 81 81 { 82 82 int h1, h2, diff; 83 83 84 84 if (!node) 85 85 return 0; 86 86 87 87 h1 = test_tree_balance(node->lft); 88 88 h2 = test_tree_balance(node->rgt); 89 89 diff = h2 - h1; 90 90 91 91 if ((diff != node->balance) || ((diff != -1) && (diff != 0) && (diff != 1))) 92 92 TPRINTF("Bad balance\n"); 93 93 94 94 return ((h1 > h2) ? (h1 + 1) : (h2 + 1)); 95 95 } … … 110 110 return; 111 111 } 112 112 113 113 if (node == NULL) 114 114 return; 115 115 116 116 TPRINTF("%" PRIu64 "[%" PRIu8 "]", node->key, node->balance); 117 117 if (node->lft != NULL || node->rgt != NULL) { 118 118 TPRINTF("("); 119 119 120 120 print_tree_structure_flat(node->lft, level + 1); 121 121 if (node->rgt != NULL) { … … 123 123 print_tree_structure_flat(node->rgt, level + 1); 124 124 } 125 125 126 126 TPRINTF(")"); 127 127 } … … 131 131 { 132 132 int i; 133 133 134 134 for (i = 0; i < NODE_COUNT - 1; i++) 135 135 avltree_nodes[i].par = &avltree_nodes[i + 1]; 136 136 137 137 avltree_nodes[i].par = NULL; 138 138 139 139 /* 140 140 * Node keys which will be used for insertion. Up to NODE_COUNT size of 141 141 * array. 142 142 */ 143 143 144 144 /* First tree node and same key */ 145 145 avltree_nodes[0].key = 60; 146 146 avltree_nodes[1].key = 60; 147 147 avltree_nodes[2].key = 60; 148 148 149 149 /* LL rotation */ 150 150 avltree_nodes[3].key = 50; 151 151 avltree_nodes[4].key = 40; 152 152 avltree_nodes[5].key = 30; 153 153 154 154 /* LR rotation */ 155 155 avltree_nodes[6].key = 20; … … 157 157 avltree_nodes[8].key = 25; 158 158 avltree_nodes[9].key = 25; 159 159 160 160 /* LL rotation in lower floor */ 161 161 avltree_nodes[10].key = 35; 162 162 163 163 /* RR rotation */ 164 164 avltree_nodes[11].key = 70; 165 165 avltree_nodes[12].key = 80; 166 166 167 167 /* RL rotation */ 168 168 avltree_nodes[13].key = 90; 169 169 avltree_nodes[14].key = 85; 170 170 171 171 /* Insert 0 key */ 172 172 avltree_nodes[15].key = 0; 173 173 avltree_nodes[16].key = 0; 174 174 175 175 /* Insert reverse */ 176 176 avltree_nodes[17].key = 600; … … 178 178 avltree_nodes[19].key = 400; 179 179 avltree_nodes[20].key = 300; 180 180 181 181 for (i = 21; i < NODE_COUNT; i++) 182 182 avltree_nodes[i].key = i * 3; 183 183 184 184 first_free_node = &avltree_nodes[0]; 185 185 } … … 188 188 { 189 189 avltree_node_t *node; 190 190 191 191 node = first_free_node; 192 192 first_free_node = first_free_node->par; 193 193 194 194 return node; 195 195 } … … 199 199 unsigned int i; 200 200 avltree_node_t *newnode; 201 201 202 202 avltree_create(tree); 203 203 204 204 TPRINTF("Inserting %zu nodes...", node_count); 205 205 206 206 for (i = 0; i < node_count; i++) { 207 207 newnode = alloc_avltree_node(); 208 208 209 209 avltree_insert(tree, newnode); 210 210 test_tree_parents(tree->root); 211 211 test_tree_balance(tree->root); 212 212 } 213 213 214 214 TPRINTF("done.\n"); 215 215 } … … 220 220 avltree_node_t *delnode; 221 221 unsigned int i; 222 222 223 223 switch (node_position) { 224 224 case 0: 225 225 TPRINTF("Deleting root nodes..."); 226 226 227 227 while (tree->root != NULL) { 228 228 delnode = tree->root; … … 234 234 case 1: 235 235 TPRINTF("Deleting nodes according to creation time..."); 236 236 237 237 for (i = 0; i < node_count; i++) { 238 238 avltree_delete(tree, &avltree_nodes[i]); … … 242 242 break; 243 243 } 244 244 245 245 TPRINTF("done.\n"); 246 246 } … … 249 249 { 250 250 unsigned int i = 0; 251 251 252 252 TPRINTF("Deleting minimum nodes..."); 253 253 254 254 while (tree->root != NULL) { 255 255 i++; … … 258 258 test_tree_balance(tree->root); 259 259 } 260 260 261 261 if (i != node_count) 262 262 TPRINTF("Bad node count. Some nodes have been lost!\n"); 263 263 264 264 TPRINTF("done.\n"); 265 265 } … … 270 270 test_tree_insert(&avltree, NODE_COUNT); 271 271 test_tree_delete(&avltree, NODE_COUNT, 0); 272 272 273 273 alloc_avltree_node_prepare(); 274 274 test_tree_insert(&avltree, NODE_COUNT); 275 275 test_tree_delete(&avltree, NODE_COUNT, 1); 276 276 277 277 alloc_avltree_node_prepare(); 278 278 test_tree_insert(&avltree, NODE_COUNT); 279 279 test_tree_delmin(&avltree, NODE_COUNT); 280 280 281 281 return NULL; 282 282 } -
kernel/test/btree/btree1.c
r3061bc1 ra35b458 38 38 btree_t t; 39 39 int i; 40 40 41 41 btree_create(&t); 42 42 43 43 TPRINTF("Inserting keys.\n"); 44 44 btree_insert(&t, 19, data, NULL); … … 77 77 for (i = 100; i >= 50; i--) 78 78 btree_insert(&t, i, data, NULL); 79 79 80 80 if (!test_quiet) 81 81 btree_print(&t); 82 82 83 83 TPRINTF("Removing keys.\n"); 84 84 btree_remove(&t, 50, NULL); … … 156 156 btree_remove(&t, 35, NULL); 157 157 btree_remove(&t, 36, NULL); 158 158 159 159 if (!test_quiet) 160 160 btree_print(&t); 161 161 162 162 return NULL; 163 163 } -
kernel/test/cht/cht1.c
r3061bc1 ra35b458 99 99 if (cht_find_lazy(h, (void*)0)) 100 100 return "Found lazy in empty table."; 101 101 102 102 if (cht_find(h, (void*)0)) 103 103 return "Found in empty table."; 104 104 105 105 if (cht_remove_key(h, (void*)0)) 106 106 return "Removed from empty table."; 107 107 108 108 const int val_cnt = 6; 109 109 val_t *v[6] = { NULL }; 110 110 111 111 for (int i = 0; i < val_cnt; ++i) 112 112 v[i] = malloc(sizeof(val_t), 0); 113 113 114 114 size_t key[] = { 1, 1, 1, 11, 12, 13 }; 115 115 116 116 /* First three are identical */ 117 117 for (int i = 0; i < 3; ++i) 118 118 set_val(v[i], 1, key[i]); 119 119 120 120 /* Same hash, different key.*/ 121 121 set_val(v[3], 1, key[3]); 122 122 123 123 /* Different hashes and keys. */ 124 124 set_val(v[4], 2, key[4]); 125 125 set_val(v[5], 3, key[5]); 126 126 127 127 cht_link_t *dup; 128 128 129 129 if (!cht_insert_unique(h, &v[0]->link, &dup)) 130 130 return "Duplicates in empty"; … … 132 132 if (cht_insert_unique(h, &v[1]->link, &dup)) 133 133 return "Inserted a duplicate"; 134 134 135 135 if (dup != &v[0]->link) 136 136 return "Returned wrong duplicate"; … … 138 138 if (!cht_insert_unique(h, &v[3]->link, &dup)) 139 139 return "Refused non-equal item but with a hash in table."; 140 140 141 141 cht_insert(h, &v[1]->link); 142 142 cht_insert(h, &v[2]->link); 143 143 144 144 bool ok = true; 145 145 ok = ok && cht_insert_unique(h, &v[4]->link, &dup); 146 146 ok = ok && cht_insert_unique(h, &v[5]->link, &dup); 147 147 148 148 if (!ok) 149 149 return "Refused unique ins 4, 5."; 150 150 151 151 if (cht_find(h, (void*)0)) 152 152 return "Phantom find."; 153 153 154 154 cht_link_t *item = cht_find(h, (void*)v[5]->unique_id); 155 155 if (!item || item != &v[5]->link) … … 159 159 if (item) 160 160 return "Found nonexisting duplicate 5"; 161 161 162 162 item = cht_find(h, (void*)v[3]->unique_id); 163 163 if (!item || item != &v[3]->link) … … 167 167 if (item) 168 168 return "Found nonexisting duplicate 3, same hash as others."; 169 169 170 170 item = cht_find(h, (void*)v[0]->unique_id); 171 171 ((val_t*)item)->mark = true; 172 172 173 173 for (int k = 1; k < 3; ++k) { 174 174 item = cht_find_next(h, item); 175 175 if (!item) 176 176 return "Did not find an inserted duplicate"; 177 177 178 178 val_t *val = ((val_t*)item); 179 179 180 180 if (val->unique_id != v[0]->unique_id) 181 181 return "Found item with a different key."; … … 184 184 val->mark = true; 185 185 } 186 186 187 187 for (int i = 0; i < 3; ++i) { 188 188 if (!v[i]->mark) 189 189 return "Did not find all duplicates"; 190 190 191 191 v[i]->mark = false; 192 192 } … … 196 196 197 197 item = cht_find_next(h, cht_find(h, (void*)key[0])); 198 198 199 199 ((val_t*)item)->mark = true; 200 200 if (!cht_remove_item(h, item)) 201 201 return "Failed to remove inserted item"; 202 202 203 203 item = cht_find(h, (void*)key[0]); 204 204 if (!item || ((val_t*)item)->mark) 205 205 return "Did not find proper item."; 206 206 207 207 item = cht_find_next(h, item); 208 208 if (!item || ((val_t*)item)->mark) … … 212 212 if (item) 213 213 return "Found removed duplicate"; 214 214 215 215 if (2 != cht_remove_key(h, (void*)key[0])) 216 216 return "Failed to remove all duplicates"; 217 217 218 218 if (cht_find(h, (void*)key[0])) 219 219 return "Found removed key"; 220 220 221 221 if (!cht_find(h, (void*)key[3])) 222 222 return "Removed incorrect key"; 223 223 224 224 for (size_t k = 0; k < sizeof(v) / sizeof(v[0]); ++k) { 225 225 cht_remove_key(h, (void*)key[k]); 226 226 } 227 227 228 228 for (size_t k = 0; k < sizeof(v) / sizeof(v[0]); ++k) { 229 229 if (cht_find(h, (void*)key[k])) … … 239 239 if (!cht_create_simple(&h, &val_ops)) 240 240 return "Could not create the table."; 241 241 242 242 rcu_read_lock(); 243 243 const char *err = do_sanity_test(&h); 244 244 rcu_read_unlock(); 245 245 246 246 cht_destroy(&h); 247 247 … … 321 321 goto out_of_mem; 322 322 } 323 323 324 324 s->free = true; 325 325 s->key = (i << 8) + work->id; 326 326 327 327 cht_insert(work->h, &s->link); 328 328 } 329 329 TPRINTF("}"); 330 330 331 331 thread_sleep(2); 332 332 … … 334 334 for (size_t i = 0; i < work->wave_elems; ++i) { 335 335 size_t key = (i << 8) + work->id; 336 336 337 337 if (1 != cht_remove_key(work->h, (void*)key)) { 338 338 TPRINTF("Err: Failed to remove inserted item\n"); … … 342 342 TPRINTF(">"); 343 343 } 344 344 345 345 /* Request that others stop. */ 346 346 *work->stop = 1; … … 365 365 stress_work_t *work = (stress_work_t *)arg; 366 366 assert(0 == *work->stop); 367 367 368 368 size_t loops = 0; 369 369 size_t seed = work->id; 370 370 371 371 while (0 == *work->stop && !work->failed) { 372 372 seed = next_rand(seed); … … 374 374 seed = next_rand(seed); 375 375 size_t elem_idx = seed % work->elem_cnt; 376 376 377 377 ++loops; 378 378 if (0 == loops % (1024 * 1024)) { … … 381 381 TPRINTF("*"); 382 382 } 383 383 384 384 if (upd) { 385 385 seed = next_rand(seed); 386 386 bool item_op = seed & 1; 387 387 388 388 if (work->elem[elem_idx].inserted) { 389 389 if (item_op) { … … 401 401 } else if (work->elem[elem_idx].deleted) { 402 402 work->elem[elem_idx].deleted = false; 403 403 404 404 if (item_op) { 405 405 rcu_read_lock(); … … 414 414 cht_insert(work->h, &work->elem[elem_idx].link); 415 415 } 416 416 417 417 work->elem[elem_idx].inserted = true; 418 418 } … … 452 452 { 453 453 cht_t h; 454 454 455 455 if (!cht_create_simple(&h, &stress_ops)) { 456 456 TPRINTF("Failed to create the table\n"); … … 464 464 size_t total_thr_cnt = op_thread_cnt + resize_thread_cnt; 465 465 size_t items_per_thread = 1024; 466 466 467 467 size_t work_cnt = op_thread_cnt + resize_thread_cnt; 468 468 size_t item_cnt = op_thread_cnt * items_per_thread; 469 469 470 470 /* Alloc hash table items. */ 471 471 size_t size = item_cnt * sizeof(stress_t) + work_cnt * sizeof(stress_work_t) 472 472 + sizeof(int); 473 473 474 474 TPRINTF("Alloc and init table items. \n"); 475 475 void *p = malloc(size, FRAME_ATOMIC); … … 479 479 return false; 480 480 } 481 481 482 482 stress_t *pitem = p + work_cnt * sizeof(stress_work_t); 483 483 stress_work_t *pwork = p; 484 484 int *pstop = (int*)(pitem + item_cnt); 485 485 486 486 *pstop = 0; 487 487 488 488 /* Init work items. */ 489 489 for (size_t i = 0; i < op_thread_cnt; ++i) { … … 496 496 pwork[i].failed = false; 497 497 } 498 498 499 499 for (size_t i = op_thread_cnt; i < op_thread_cnt + resize_thread_cnt; ++i) { 500 500 pwork[i].h = &h; … … 505 505 pwork[i].failed = false; 506 506 } 507 507 508 508 /* Init table elements. */ 509 509 for (size_t k = 0; k < op_thread_cnt; ++k) { … … 515 515 } 516 516 } 517 517 518 518 TPRINTF("Running %zu ins/del/find stress threads + %zu resizers.\n", 519 519 op_thread_cnt, resize_thread_cnt); 520 520 521 521 /* Create and run threads. */ 522 522 thread_t *thr[max_thread_cnt + resize_thread_cnt]; 523 523 524 524 for (size_t i = 0; i < total_thr_cnt; ++i) { 525 525 if (i < op_thread_cnt) … … 527 527 else 528 528 thr[i] = thread_create(resize_stresser, &pwork[i], TASK, 0, "cht-resize"); 529 529 530 530 assert(thr[i]); 531 531 thread_wire(thr[i], &cpus[i % config.cpu_active]); 532 532 thread_ready(thr[i]); 533 533 } 534 534 535 535 bool failed = false; 536 536 537 537 /* Wait for all threads to return. */ 538 538 TPRINTF("Joining resize stressers.\n"); … … 542 542 failed = pwork[i].failed || failed; 543 543 } 544 544 545 545 TPRINTF("Joining op stressers.\n"); 546 546 for (int i = (int)op_thread_cnt - 1; i >= 0; --i) { … … 550 550 failed = pwork[i].failed || failed; 551 551 } 552 552 553 553 cht_destroy(&h); 554 554 free(p); … … 566 566 return err; 567 567 printf("Basic sanity test: ok.\n"); 568 568 569 569 if (!do_stress()) 570 570 return "CHT stress test failed."; -
kernel/test/debug/mips1.c
r3061bc1 ra35b458 40 40 { 41 41 TPRINTF("If kconsole is compiled in, you should enter debug mode now.\n"); 42 42 43 43 asm volatile ( 44 44 "break\n" 45 45 ); 46 46 47 47 return "Back from debug mode"; 48 48 } -
kernel/test/fault/fault1.c
r3061bc1 ra35b458 40 40 { 41 41 ((int *)(0))[1] = 0; 42 42 43 43 return "Written to NULL"; 44 44 } -
kernel/test/mm/falloc1.c
r3061bc1 ra35b458 45 45 if (TEST_RUNS < 2) 46 46 return "Test is compiled with TEST_RUNS < 2"; 47 47 48 48 uintptr_t *frames = (uintptr_t *) 49 49 malloc(MAX_FRAMES * sizeof(uintptr_t), 0); 50 50 if (frames == NULL) 51 51 return "Unable to allocate frames"; 52 52 53 53 unsigned int results[MAX_FRAMES + 1]; 54 54 55 55 for (unsigned int run = 0; run < TEST_RUNS; run++) { 56 56 for (size_t count = 1; count <= MAX_FRAMES; count++) { 57 57 size_t bytes = FRAMES2SIZE(count); 58 58 59 59 TPRINTF("Allocating %zu frames blocks (%zu bytes) ... ", 60 60 count, bytes); 61 61 62 62 unsigned int allocated = 0; 63 63 for (unsigned int i = 0; i < (MAX_FRAMES / count); i++) { … … 70 70 } 71 71 } 72 72 73 73 TPRINTF("%d blocks allocated.\n", allocated); 74 74 75 75 if (run > 0) { 76 76 if (results[count] != allocated) … … 78 78 } else 79 79 results[count] = allocated; 80 80 81 81 TPRINTF("Deallocating ... "); 82 82 83 83 for (unsigned int i = 0; i < allocated; i++) 84 84 frame_free(frames[i], count); 85 85 86 86 TPRINTF("done.\n"); 87 87 } 88 88 } 89 89 90 90 free(frames); 91 91 92 92 return NULL; 93 93 } -
kernel/test/mm/falloc2.c
r3061bc1 ra35b458 51 51 { 52 52 uint8_t val = THREAD->tid % THREADS; 53 53 54 54 uintptr_t *frames = (uintptr_t *) 55 55 malloc(MAX_FRAMES * sizeof(uintptr_t), FRAME_ATOMIC); … … 61 61 return; 62 62 } 63 63 64 64 thread_detach(THREAD); 65 65 66 66 for (unsigned int run = 0; run < THREAD_RUNS; run++) { 67 67 for (size_t count = 1; count <= MAX_FRAMES; count++) { 68 68 size_t bytes = FRAMES2SIZE(count); 69 69 70 70 TPRINTF("Thread #%" PRIu64 " (cpu%u): " 71 71 "Allocating %zu frames blocks (%zu bytes) ... \n", THREAD->tid, 72 72 CPU->id, count, bytes); 73 73 74 74 unsigned int allocated = 0; 75 75 for (unsigned int i = 0; i < (MAX_FRAMES / count); i++) { … … 81 81 break; 82 82 } 83 83 84 84 TPRINTF("Thread #%" PRIu64 " (cpu%u): " 85 85 "%u blocks allocated.\n", THREAD->tid, CPU->id, … … 87 87 TPRINTF("Thread #%" PRIu64 " (cpu%u): " 88 88 "Deallocating ... \n", THREAD->tid, CPU->id); 89 89 90 90 for (unsigned int i = 0; i < allocated; i++) { 91 91 for (size_t k = 0; k < bytes; k++) { … … 101 101 frame_free(frames[i], count); 102 102 } 103 103 104 104 TPRINTF("Thread #%" PRIu64 " (cpu%u): " 105 105 "Finished run.\n", THREAD->tid, CPU->id); 106 106 } 107 107 } 108 108 109 109 cleanup: 110 110 free(frames); 111 111 112 112 TPRINTF("Thread #%" PRIu64 " (cpu%u): Exiting\n", 113 113 THREAD->tid, CPU->id); … … 119 119 atomic_set(&thread_count, THREADS); 120 120 atomic_set(&thread_fail, 0); 121 121 122 122 for (unsigned int i = 0; i < THREADS; i++) { 123 123 thread_t *thrd = thread_create(falloc, NULL, TASK, … … 129 129 thread_ready(thrd); 130 130 } 131 131 132 132 while (atomic_get(&thread_count) > 0) { 133 133 TPRINTF("Threads left: %" PRIua "\n", … … 135 135 thread_sleep(1); 136 136 } 137 137 138 138 if (atomic_get(&thread_fail) == 0) 139 139 return NULL; 140 140 141 141 return "Test failed"; 142 142 } -
kernel/test/mm/mapping1.c
r3061bc1 ra35b458 42 42 { 43 43 uintptr_t frame = frame_alloc(1, FRAME_NONE, 0); 44 44 45 45 uintptr_t page0 = km_map(frame, FRAME_SIZE, 46 46 PAGE_READ | PAGE_WRITE | PAGE_CACHEABLE); 47 47 TPRINTF("Virtual address %p mapped to physical address %p.\n", 48 48 (void *) page0, (void *) frame); 49 49 50 50 uintptr_t page1 = km_map(frame, FRAME_SIZE, 51 51 PAGE_READ | PAGE_WRITE | PAGE_CACHEABLE); 52 52 TPRINTF("Virtual address %p mapped to physical address %p.\n", 53 53 (void *) page1, (void *) frame); 54 54 55 55 for (unsigned int i = 0; i < 2; i++) { 56 56 TPRINTF("Writing magic using the first virtual address.\n"); 57 57 58 58 *((uint32_t *) page0) = TEST_MAGIC; 59 59 60 60 TPRINTF("Reading magic using the second virtual address.\n"); 61 61 62 62 uint32_t v = *((uint32_t *) page1); 63 63 64 64 if (v != TEST_MAGIC) { 65 65 km_unmap(page0, PAGE_SIZE); … … 68 68 return "Criss-cross read does not match the value written."; 69 69 } 70 70 71 71 TPRINTF("Writing zero using the second virtual address.\n"); 72 72 73 73 *((uint32_t *) page1) = 0; 74 74 75 75 TPRINTF("Reading zero using the first virtual address.\n"); 76 76 77 77 v = *((uint32_t *) page0); 78 78 79 79 if (v != 0) { 80 80 km_unmap(page0, PAGE_SIZE); … … 84 84 } 85 85 } 86 86 87 87 km_unmap(page0, PAGE_SIZE); 88 88 km_unmap(page1, PAGE_SIZE); 89 89 frame_free(frame, 1); 90 90 91 91 return NULL; 92 92 } -
kernel/test/mm/purge1.c
r3061bc1 ra35b458 44 44 tlb_entry_t entryi; 45 45 tlb_entry_t entryd; 46 46 47 47 int i; 48 48 49 49 entryd.word[0] = 0; 50 50 entryd.word[1] = 0; 51 51 52 52 entryd.p = true; /* present */ 53 53 entryd.ma = MA_WRITEBACK; … … 58 58 entryd.ppn = 0; 59 59 entryd.ps = PAGE_WIDTH; 60 60 61 61 entryi.word[0] = 0; 62 62 entryi.word[1] = 0; 63 63 64 64 entryi.p = true; /* present */ 65 65 entryi.ma = MA_WRITEBACK; … … 70 70 entryi.ppn = 0; 71 71 entryi.ps = PAGE_WIDTH; 72 72 73 73 for (i = 0; i < 100; i++) { 74 74 itc_mapping_insert(0 + i * (1 << PAGE_WIDTH), 8, entryi); 75 75 dtc_mapping_insert(0 + i * (1 << PAGE_WIDTH), 9, entryd); 76 76 } 77 77 78 78 tlb_invalidate_pages(8, 0x0c000, 14); 79 79 80 80 /* tlb_invalidate_all(); */ 81 81 82 82 return NULL; 83 83 } -
kernel/test/mm/slab1.c
r3061bc1 ra35b458 42 42 slab_cache_t *cache; 43 43 int i; 44 44 45 45 TPRINTF("Creating cache, object size: %d.\n", size); 46 46 47 47 cache = slab_cache_create("test_cache", size, 0, NULL, NULL, 48 48 SLAB_CACHE_NOMAGAZINE); 49 49 50 50 TPRINTF("Allocating %d items...", count); 51 51 52 52 for (i = 0; i < count; i++) { 53 53 data[i] = slab_alloc(cache, 0); 54 54 memsetb(data[i], size, 0); 55 55 } 56 56 57 57 TPRINTF("done.\n"); 58 58 59 59 TPRINTF("Freeing %d items...", count); 60 60 61 61 for (i = 0; i < count; i++) 62 62 slab_free(cache, data[i]); 63 63 64 64 TPRINTF("done.\n"); 65 65 66 66 TPRINTF("Allocating %d items...", count); 67 67 68 68 for (i = 0; i < count; i++) { 69 69 data[i] = slab_alloc(cache, 0); 70 70 memsetb(data[i], size, 0); 71 71 } 72 72 73 73 TPRINTF("done.\n"); 74 74 75 75 TPRINTF("Freeing %d items...", count / 2); 76 76 77 77 for (i = count - 1; i >= count / 2; i--) 78 78 slab_free(cache, data[i]); 79 79 80 80 TPRINTF("done.\n"); 81 81 82 82 TPRINTF("Allocating %d items...", count / 2); 83 83 84 84 for (i = count / 2; i < count; i++) { 85 85 data[i] = slab_alloc(cache, 0); 86 86 memsetb(data[i], size, 0); 87 87 } 88 88 89 89 TPRINTF("done.\n"); 90 90 91 91 TPRINTF("Freeing %d items...", count); 92 92 93 93 for (i = 0; i < count; i++) 94 94 slab_free(cache, data[i]); 95 95 96 96 TPRINTF("done.\n"); 97 97 98 98 slab_cache_destroy(cache); 99 99 100 100 TPRINTF("Test complete.\n"); 101 101 } … … 125 125 int offs = (int) (sysarg_t) data; 126 126 int i, j; 127 127 128 128 thread_detach(THREAD); 129 129 130 130 TPRINTF("Starting thread #%" PRIu64 "...\n", THREAD->tid); 131 131 132 132 for (j = 0; j < 10; j++) { 133 133 for (i = 0; i < THR_MEM_COUNT; i++) … … 140 140 slab_free(thr_cache, thr_data[offs][i]); 141 141 } 142 142 143 143 TPRINTF("Thread #%" PRIu64 " finished\n", THREAD->tid); 144 144 145 145 semaphore_up(&thr_sem); 146 146 } … … 150 150 thread_t *t; 151 151 int i; 152 152 153 153 thr_cache = slab_cache_create("thread_cache", THR_MEM_SIZE, 0, NULL, NULL, 154 154 SLAB_CACHE_NOMAGAZINE); 155 155 156 156 semaphore_initialize(&thr_sem, 0); 157 157 for (i = 0; i < THREADS; i++) { … … 164 164 for (i = 0; i < THREADS; i++) 165 165 semaphore_down(&thr_sem); 166 166 167 167 slab_cache_destroy(thr_cache); 168 168 169 169 TPRINTF("Test complete.\n"); 170 170 } … … 174 174 testsimple(); 175 175 testthreads(); 176 176 177 177 return NULL; 178 178 } -
kernel/test/mm/slab2.c
r3061bc1 ra35b458 48 48 slab_cache_t *cache2; 49 49 int i; 50 50 51 51 void *data1, *data2; 52 52 void *olddata1 = NULL, *olddata2 = NULL; 53 53 54 54 cache1 = slab_cache_create("test_cache1", ITEM_SIZE, 0, NULL, NULL, 0); 55 55 cache2 = slab_cache_create("test_cache2", ITEM_SIZE, 0, NULL, NULL, 0); 56 56 57 57 TPRINTF("Allocating..."); 58 58 59 59 /* Use atomic alloc, so that we find end of memory */ 60 60 do { … … 75 75 olddata2 = data2; 76 76 } while (true); 77 77 78 78 TPRINTF("done.\n"); 79 79 80 80 TPRINTF("Deallocating cache2..."); 81 81 82 82 /* We do not have memory - now deallocate cache2 */ 83 83 while (olddata2) { … … 86 86 olddata2 = data2; 87 87 } 88 88 89 89 TPRINTF("done.\n"); 90 90 91 91 TPRINTF("Allocating to cache1...\n"); 92 92 93 93 for (i = 0; i < 30; i++) { 94 94 data1 = slab_alloc(cache1, FRAME_ATOMIC); … … 109 109 olddata1 = data1; 110 110 } 111 111 112 112 TPRINTF("Deallocating cache1..."); 113 113 114 114 while (olddata1) { 115 115 data1 = *((void **) olddata1); … … 117 117 olddata1 = data1; 118 118 } 119 119 120 120 TPRINTF("done.\n"); 121 121 122 122 if (!test_quiet) 123 123 slab_print_list(); 124 124 125 125 slab_cache_destroy(cache1); 126 126 slab_cache_destroy(cache2); … … 137 137 { 138 138 void *data = NULL, *new; 139 139 140 140 thread_detach(THREAD); 141 141 142 142 mutex_lock(&starter_mutex); 143 143 condvar_wait(&thread_starter,&starter_mutex); 144 144 mutex_unlock(&starter_mutex); 145 145 146 146 TPRINTF("Starting thread #%" PRIu64 "...\n", THREAD->tid); 147 147 148 148 /* Alloc all */ 149 149 TPRINTF("Thread #%" PRIu64 " allocating...\n", THREAD->tid); 150 150 151 151 while (true) { 152 152 /* Call with atomic to detect end of memory */ … … 157 157 data = new; 158 158 } 159 159 160 160 TPRINTF("Thread #%" PRIu64 " releasing...\n", THREAD->tid); 161 161 162 162 while (data) { 163 163 new = *((void **)data); … … 166 166 data = new; 167 167 } 168 168 169 169 TPRINTF("Thread #%" PRIu64 " allocating...\n", THREAD->tid); 170 170 171 171 while (true) { 172 172 /* Call with atomic to detect end of memory */ … … 177 177 data = new; 178 178 } 179 179 180 180 TPRINTF("Thread #%" PRIu64 " releasing...\n", THREAD->tid); 181 181 182 182 while (data) { 183 183 new = *((void **)data); … … 186 186 data = new; 187 187 } 188 188 189 189 TPRINTF("Thread #%" PRIu64 " finished\n", THREAD->tid); 190 190 191 191 if (!test_quiet) 192 192 slab_print_list(); 193 193 194 194 semaphore_up(&thr_sem); 195 195 } … … 202 202 thread_t *t; 203 203 int i; 204 204 205 205 TPRINTF("Running stress test with size %d\n", size); 206 206 207 207 condvar_initialize(&thread_starter); 208 208 mutex_initialize(&starter_mutex, MUTEX_PASSIVE); 209 209 210 210 thr_cache = slab_cache_create("thread_cache", size, 0, NULL, NULL, 0); 211 211 semaphore_initialize(&thr_sem,0); … … 218 218 thread_sleep(1); 219 219 condvar_broadcast(&thread_starter); 220 220 221 221 for (i = 0; i < THREADS; i++) 222 222 semaphore_down(&thr_sem); 223 223 224 224 slab_cache_destroy(thr_cache); 225 225 TPRINTF("Stress test complete.\n"); … … 230 230 TPRINTF("Running reclaim single-thread test .. pass 1\n"); 231 231 totalmemtest(); 232 232 233 233 TPRINTF("Running reclaim single-thread test .. pass 2\n"); 234 234 totalmemtest(); 235 235 236 236 TPRINTF("Reclaim test OK.\n"); 237 237 238 238 multitest(128); 239 239 multitest(2048); 240 240 multitest(8192); 241 241 242 242 return NULL; 243 243 } -
kernel/test/print/print1.c
r3061bc1 ra35b458 36 36 TPRINTF("Expected output: \" tex\"\n"); 37 37 TPRINTF("Real output: \"%*.*s\"\n\n", 5, 3, "text"); 38 38 39 39 TPRINTF("Testing printf(\"%%10.8s\", \"very long text\"):\n"); 40 40 TPRINTF("Expected output: \" very lon\"\n"); 41 41 TPRINTF("Real output: \"%10.8s\"\n\n", "very long text"); 42 42 43 43 TPRINTF("Testing printf(\"%%8.10s\", \"text\"):\n"); 44 44 TPRINTF("Expected output: \" text\"\n"); 45 45 TPRINTF("Real output: \"%8.10s\"\n\n", "text"); 46 46 47 47 TPRINTF("Testing printf(\"%%8.10s\", \"very long text\"):\n"); 48 48 TPRINTF("Expected output: \"very long \"\n"); 49 49 TPRINTF("Real output: \"%8.10s\"\n\n", "very long text"); 50 50 51 51 TPRINTF("Testing printf(\"%%-*.*s\", 7, 7, \"text\"):\n"); 52 52 TPRINTF("Expected output: \"text \"\n"); 53 53 TPRINTF("Real output: \"%-*.*s\"\n\n", 7, 7, "text"); 54 54 55 55 return NULL; 56 56 } -
kernel/test/print/print2.c
r3061bc1 ra35b458 36 36 TPRINTF("Expected output: [a]\n"); 37 37 TPRINTF("Real output: [%c]\n\n", 'a'); 38 38 39 39 TPRINTF("Testing printf(\"%%d %%3.2d %%-3.2d %%2.3d %%-2.3d\", 1, 2, 3, 4, 5):\n"); 40 40 TPRINTF("Expected output: [1] [ 02] [03 ] [004] [005]\n"); 41 41 TPRINTF("Real output: [%d] [%3.2d] [%-3.2d] [%2.3d] [%-2.3d]\n\n", 1, 2, 3, 4, 5); 42 42 43 43 TPRINTF("Testing printf(\"%%d %%3.2d %%-3.2d %%2.3d %%-2.3d\", -1, -2, -3, -4, -5):\n"); 44 44 TPRINTF("Expected output: [-1] [-02] [-03] [-004] [-005]\n"); 45 45 TPRINTF("Real output: [%d] [%3.2d] [%-3.2d] [%2.3d] [%-2.3d]\n\n", -1, -2, -3, -4, -5); 46 46 47 47 TPRINTF("Testing printf(\"%%lld %%3.2lld %%-3.2lld %%2.3lld %%-2.3lld\", (long long) -1, (long long) -2, (long long) -3, (long long) -4, (long long) -5):\n"); 48 48 TPRINTF("Expected output: [-1] [-02] [-03] [-004] [-005]\n"); 49 49 TPRINTF("Real output: [%lld] [%3.2lld] [%-3.2lld] [%2.3lld] [%-2.3lld]\n\n", (long long) -1, (long long) -2, (long long) -3, (long long) -4, (long long) -5); 50 50 51 51 TPRINTF("Testing printf(\"%%#x %%5.3#x %%-5.3#x %%3.5#x %%-3.5#x\", 17, 18, 19, 20, 21):\n"); 52 52 TPRINTF("Expected output: [0x11] [0x012] [0x013] [0x00014] [0x00015]\n"); 53 53 TPRINTF("Real output: [%#x] [%#5.3x] [%#-5.3x] [%#3.5x] [%#-3.5x]\n\n", 17, 18, 19, 20, 21); 54 54 55 55 char ch[12]; 56 56 ptrdiff_t d, neg_d; 57 57 58 58 d = &ch[0] - &ch[12]; 59 59 neg_d = (unsigned)(-d); … … 61 61 TPRINTF("Expected output: [-12] [12] [c] [-12] [14]\n"); 62 62 TPRINTF("Real output: [%td] [%tu] [%tx] [%ti] [%to]\n\n", d, neg_d, neg_d, d, neg_d); 63 63 64 64 sysarg_t nat = 0x12345678; 65 65 66 66 TPRINTF("Testing printf(\"%%#" PRIx64 " %%#" PRIx32 " %%#" PRIx16 " %%#" PRIx8 " %%#" PRIxn " %%#" PRIx64 " %%s\", (uint64_t) UINT64_C(0x1234567887654321), (uint32_t) UINT32_C(0x12345678), (uint16_t) UINT16_C(0x1234), (uint8_t) UINT8_C(0x12), nat, (uint64_t) UINT64_C(0x1234567887654321), \"Lovely string\"):\n"); 67 67 TPRINTF("Expected output: [0x1234567887654321] [0x12345678] [0x1234] [0x12] [0x12345678] [0x1234567887654321] \"Lovely string\"\n"); 68 68 TPRINTF("Real output: [%#" PRIx64 "] [%#" PRIx32 "] [%#" PRIx16 "] [%#" PRIx8 "] [%#" PRIxn "] [%#" PRIx64 "] \"%s\"\n\n", (uint64_t) UINT64_C(0x1234567887654321), (uint32_t) UINT32_C(0x12345678), (uint16_t) UINT16_C(0x1234), (uint8_t) UINT8_C(0x12), nat, (uint64_t) UINT64_C(0x1234567887654321), "Lovely string"); 69 69 70 70 return NULL; 71 71 } -
kernel/test/print/print3.c
r3061bc1 ra35b458 38 38 char buffer[BUFFER_SIZE]; 39 39 int retval; 40 40 41 41 TPRINTF("Testing snprintf(buffer, " STRING(BUFFER_SIZE) ", \"Short text without parameters.\"):\n"); 42 42 TPRINTF("Expected result: retval=30 buffer=\"Short text without parameters.\"\n"); 43 43 retval = snprintf(buffer, BUFFER_SIZE, "Short text without parameters."); 44 44 TPRINTF("Real result: retval=%d buffer=\"%s\"\n\n", retval, buffer); 45 45 46 46 TPRINTF("Testing snprintf(buffer, " STRING(BUFFER_SIZE) ", \"Very very very long text without parameters.\"):\n"); 47 47 TPRINTF("Expected result: retval=44 buffer=\"Very very very long text withou\"\n"); 48 48 retval = snprintf(buffer, BUFFER_SIZE, "Very very very long text without parameters."); 49 49 TPRINTF("Real result: retval=%d buffer=\"%s\"\n\n", retval, buffer); 50 50 51 51 TPRINTF("Testing snprintf(buffer, " STRING(BUFFER_SIZE) ", \"Short %%s.\", \"text\"):\n"); 52 52 TPRINTF("Expected result: retval=11 buffer=\"Short text.\"\n"); 53 53 retval = snprintf(buffer, BUFFER_SIZE, "Short %s.", "text"); 54 54 TPRINTF("Real result: retval=%d buffer=\"%s\"\n\n", retval, buffer); 55 55 56 56 TPRINTF("Testing snprintf(buffer, " STRING(BUFFER_SIZE) ", \"Very long %%s. This text's length is more than %%d. We are interested in the result.\", \"text\", " STRING(BUFFER_SIZE) "):\n"); 57 57 TPRINTF("Expected result: retval=84 buffer=\"Very long text. This text's len\"\n"); 58 58 retval = snprintf(buffer, BUFFER_SIZE, "Very long %s. This text's length is more than %d. We are interested in the result.", "text", BUFFER_SIZE); 59 59 TPRINTF("Real result: retval=%d buffer=\"%s\"\n\n", retval, buffer); 60 60 61 61 return NULL; 62 62 } -
kernel/test/print/print4.c
r3061bc1 ra35b458 34 34 { 35 35 TPRINTF("ASCII printable characters (32 - 127) using printf(\"%%c\") and printf(\"%%lc\"):\n"); 36 36 37 37 uint8_t group; 38 38 for (group = 1; group < 4; group++) { 39 39 TPRINTF("%#x: ", group << 5); 40 40 41 41 uint8_t index; 42 42 for (index = 0; index < 32; index++) 43 43 TPRINTF("%c", (char) ((group << 5) + index)); 44 44 45 45 TPRINTF(" "); 46 46 for (index = 0; index < 32; index++) 47 47 TPRINTF("%lc", (wint_t) ((group << 5) + index)); 48 48 49 49 TPRINTF("\n"); 50 50 } 51 51 52 52 TPRINTF("\nExtended ASCII characters (128 - 255) using printf(\"%%lc\"):\n"); 53 53 54 54 for (group = 4; group < 8; group++) { 55 55 TPRINTF("%#x: ", group << 5); 56 56 57 57 uint8_t index; 58 58 for (index = 0; index < 32; index++) 59 59 TPRINTF("%lc", (wint_t) ((group << 5) + index)); 60 60 61 61 TPRINTF("\n"); 62 62 } 63 63 64 64 TPRINTF("\nUTF-8 strings using printf(\"%%s\"):\n"); 65 65 TPRINTF("English: %s\n", "Quick brown fox jumps over the lazy dog"); … … 70 70 TPRINTF("Russian: %s\n", "Леннон познакомился с художницей-авангардисткой"); 71 71 TPRINTF("Armenian: %s\n", "Սկսեց հրատարակվել Երուսաղեմի հայկական"); 72 72 73 73 TPRINTF("\nUTF-32 strings using printf(\"%%ls\"):\n"); 74 74 TPRINTF("English: %ls\n", L"Quick brown fox jumps over the lazy dog"); … … 79 79 TPRINTF("Russian: %ls\n", L"Леннон познакомился с художницей-авангардисткой"); 80 80 TPRINTF("Armenian: %ls\n", L"Սկսեց հրատարակվել Երուսաղեմի հայկական"); 81 81 82 82 return NULL; 83 83 } -
kernel/test/print/print5.c
r3061bc1 ra35b458 48 48 TPRINTF("Expected output: \"(NULL)\"\n"); 49 49 TPRINTF("Real output: \"%s\"\n\n", (char *) NULL); 50 50 51 51 TPRINTF("Testing printf(\"%%c %%3.2c %%-3.2c %%2.3c %%-2.3c\", 'a', 'b', 'c', 'd', 'e'):\n"); 52 52 TPRINTF("Expected output: [a] [ b] [c ] [ d] [e ]\n"); 53 53 TPRINTF("Real output: [%c] [%3.2c] [%-3.2c] [%2.3c] [%-2.3c]\n\n", 'a', 'b', 'c', 'd', 'e'); 54 54 55 55 return NULL; 56 56 } -
kernel/test/smpcall/smpcall1.c
r3061bc1 ra35b458 66 66 size_t *pcall_cnt = (size_t*)p; 67 67 smp_call_t call_info[MAX_CPUS]; 68 68 69 69 unsigned int cpu_count = min(config.cpu_active, MAX_CPUS); 70 70 71 71 for (int iter = 0; iter < ITERATIONS; ++iter) { 72 72 /* Synchronous version. */ … … 79 79 smp_call(cpu_id, inc, pcall_cnt); 80 80 } 81 81 82 82 /* 83 83 * Async calls run in parallel on different cpus, so passing the … … 85 85 */ 86 86 size_t local_cnt[MAX_CPUS] = {0}; 87 87 88 88 /* Now start asynchronous calls. */ 89 89 for (unsigned cpu_id = 0; cpu_id < cpu_count; ++cpu_id) { 90 90 smp_call_async(cpu_id, inc, &local_cnt[cpu_id], &call_info[cpu_id]); 91 91 } 92 92 93 93 /* And wait for all async calls to complete. */ 94 94 for (unsigned cpu_id = 0; cpu_id < cpu_count; ++cpu_id) { … … 112 112 size_t call_cnt[MAX_CPUS] = {0}; 113 113 thread_t *thread[MAX_CPUS] = { NULL }; 114 114 115 115 unsigned int cpu_count = min(config.cpu_active, MAX_CPUS); 116 116 size_t running_thread_cnt = 0; 117 117 118 118 TPRINTF("Spawning threads on %u cpus.\n", cpu_count); 119 119 120 120 /* Create a wired thread on each cpu. */ 121 121 for (unsigned int id = 0; id < cpu_count; ++id) { 122 122 thread[id] = thread_create(test_thread, &call_cnt[id], TASK, 123 123 THREAD_FLAG_NONE, "smp-call-test"); 124 124 125 125 if (thread[id]) { 126 126 thread_wire(thread[id], &cpus[id]); … … 133 133 size_t exp_calls = calc_exp_calls(running_thread_cnt); 134 134 size_t exp_calls_sum = exp_calls * cpu_count; 135 135 136 136 TPRINTF("Running %zu wired threads. Expecting %zu calls. Be patient.\n", 137 137 running_thread_cnt, exp_calls_sum); … … 142 142 } 143 143 } 144 144 145 145 /* Wait for threads to complete. */ 146 146 for (unsigned int i = 0; i < cpu_count; ++i) { … … 152 152 153 153 TPRINTF("Threads finished. Checking number of smp_call()s.\n"); 154 154 155 155 bool ok = true; 156 156 size_t calls_sum = 0; 157 157 158 158 for (size_t i = 0; i < cpu_count; ++i) { 159 159 if (thread[i] != NULL) { … … 164 164 } 165 165 } 166 166 167 167 calls_sum += call_cnt[i]; 168 168 } 169 169 170 170 if (calls_sum != exp_calls_sum) { 171 171 TPRINTF("Error: total acknowledged sum: %zu instead of %zu.\n", 172 172 calls_sum, exp_calls_sum); 173 173 174 174 ok = false; 175 175 } 176 176 177 177 if (ok) { 178 178 TPRINTF("Success: number of received smp_calls is as expected (%zu).\n", … … 181 181 } else 182 182 return "Failed: incorrect acknowledged smp_calls.\n"; 183 183 184 184 } -
kernel/test/synch/rcu1.c
r3061bc1 ra35b458 67 67 TPRINTF("."); 68 68 } 69 69 70 70 if (!p->exited) { 71 71 *presult = ETIMEOUT; … … 81 81 { 82 82 assert(thread[k] == NULL); 83 83 84 84 thread[k] = thread_create(func, arg, TASK, THREAD_FLAG_NONE, 85 85 "test-rcu-thread"); 86 86 87 87 if(thread[k]) { 88 88 /* Distribute evenly. */ … … 95 95 { 96 96 size_t thread_cnt = get_thread_cnt(); 97 97 98 98 one_idx = 0; 99 99 100 100 for (size_t i = 0; i < thread_cnt; ++i) { 101 101 run_thread(i, func, NULL); … … 106 106 { 107 107 size_t thread_cnt = get_thread_cnt(); 108 108 109 109 one_idx = 0; 110 110 111 111 for (size_t i = 0; i < thread_cnt; ++i) { 112 112 if (thread[i]) { … … 115 115 errno_t ret = thread_join_timeout(thread[i], 5 * 1000 * 1000, 0); 116 116 joined = (ret != ETIMEOUT); 117 117 118 118 if (ret == EOK) { 119 119 TPRINTF("%zu threads remain\n", thread_cnt - i - 1); 120 120 } 121 121 } while (!joined); 122 122 123 123 thread_detach(thread[i]); 124 124 thread[i] = NULL; … … 140 140 141 141 --one_idx; 142 142 143 143 if (thread[one_idx]) { 144 144 thread_join(thread[one_idx]); … … 154 154 { 155 155 size_t nop_iters = (size_t)arg; 156 156 157 157 TPRINTF("Enter nop-reader\n"); 158 158 159 159 for (size_t i = 0; i < nop_iters; ++i) { 160 160 rcu_read_lock(); 161 161 rcu_read_unlock(); 162 162 } 163 163 164 164 TPRINTF("Exit nop-reader\n"); 165 165 } … … 169 169 assert(0 < steps && from <= to && 0 < to); 170 170 size_t inc = (to - from) / (steps - 1); 171 171 172 172 for (size_t i = 0; i < steps - 1; ++i) { 173 173 seq[i] = i * inc + from; 174 174 } 175 175 176 176 seq[steps - 1] = to; 177 177 } … … 181 181 size_t seq[MAX_THREADS] = {0}; 182 182 get_seq(100, 100000, get_thread_cnt(), seq); 183 183 184 184 TPRINTF("\nRun %zu thr: repeat empty no-op reader sections\n", get_thread_cnt()); 185 185 186 186 for (size_t k = 0; k < get_thread_cnt(); ++k) 187 187 run_one(nop_reader, (void*)seq[k]); 188 188 189 189 TPRINTF("\nJoining %zu no-op readers\n", get_thread_cnt()); 190 190 join_all(); 191 191 192 192 return true; 193 193 } … … 202 202 size_t nop_iters = (size_t)arg; 203 203 size_t outer_iters = iter_cnt / nop_iters; 204 204 205 205 TPRINTF("Enter long-reader\n"); 206 206 207 207 for (size_t i = 0; i < outer_iters; ++i) { 208 208 rcu_read_lock(); 209 209 210 210 for (volatile size_t k = 0; k < nop_iters; ++k) { 211 211 /* nop, but increment volatile k */ 212 212 } 213 213 214 214 rcu_read_unlock(); 215 215 } 216 216 217 217 TPRINTF("Exit long-reader\n"); 218 218 } … … 222 222 size_t seq[MAX_THREADS] = {0}; 223 223 get_seq(10, 1000 * 1000, get_thread_cnt(), seq); 224 224 225 225 TPRINTF("\nRun %zu thr: repeat long reader sections, will preempt, no cbs.\n", 226 226 get_thread_cnt()); 227 227 228 228 for (size_t k = 0; k < get_thread_cnt(); ++k) 229 229 run_one(long_reader, (void*)seq[k]); 230 230 231 231 TPRINTF("\nJoining %zu readers with long reader sections.\n", get_thread_cnt()); 232 232 join_all(); 233 233 234 234 return true; 235 235 } … … 253 253 rcu_item_t *a = malloc(sizeof(rcu_item_t), FRAME_ATOMIC); 254 254 rcu_item_t *b = malloc(sizeof(rcu_item_t), FRAME_ATOMIC); 255 255 256 256 if (a && b) { 257 257 rcu_call(a, count_cb); … … 272 272 size_t exp_cnt = nop_updater_iters * get_thread_cnt(); 273 273 size_t max_used_mem = sizeof(rcu_item_t) * exp_cnt; 274 274 275 275 TPRINTF("\nRun %zu thr: post %zu no-op callbacks (%zu B used), no readers.\n", 276 276 get_thread_cnt(), exp_cnt, max_used_mem); 277 277 278 278 run_all(nop_updater); 279 279 TPRINTF("\nJoining %zu no-op callback threads\n", get_thread_cnt()); 280 280 join_all(); 281 281 282 282 size_t loop_cnt = 0, max_loops = 15; 283 283 … … 287 287 thread_sleep(1); 288 288 } 289 289 290 290 return loop_cnt < max_loops; 291 291 } … … 312 312 { 313 313 TPRINTF("Enter one-cb-reader\n"); 314 315 rcu_read_lock(); 316 314 315 rcu_read_lock(); 316 317 317 item_w_cookie_t *item = malloc(sizeof(item_w_cookie_t), FRAME_ATOMIC); 318 318 319 319 if (item) { 320 320 item->cookie = magic_cookie; … … 323 323 TPRINTF("\n[out-of-mem]\n"); 324 324 } 325 325 326 326 thread_sleep(1); 327 327 328 328 rcu_read_unlock(); 329 329 330 330 TPRINTF("Exit one-cb-reader\n"); 331 331 } … … 334 334 { 335 335 one_cb_is_done = 0; 336 336 337 337 TPRINTF("\nRun a single reader that posts one callback.\n"); 338 338 run_one(one_cb_reader, NULL); 339 339 join_one(); 340 340 341 341 TPRINTF("\nJoined one-cb reader, wait for callback.\n"); 342 342 size_t loop_cnt = 0; 343 343 size_t max_loops = 4; /* 200 ms total */ 344 344 345 345 while (!one_cb_is_done && loop_cnt < max_loops) { 346 346 thread_usleep(50 * 1000); 347 347 ++loop_cnt; 348 348 } 349 349 350 350 return one_cb_is_done; 351 351 } … … 373 373 { 374 374 seq_item_t *item = member_to_inst(rcu_item, seq_item_t, rcu); 375 375 376 376 /* Racy but errs to the conservative side, so it is ok. */ 377 377 if (max_upd_done_time < item->start_time) { 378 378 max_upd_done_time = item->start_time; 379 379 380 380 /* Make updated time visible */ 381 381 memory_barrier(); … … 393 393 #ifndef KARCH_riscv64 394 394 seq_work_t *work = (seq_work_t*)arg; 395 395 396 396 /* Alternate between reader and updater roles. */ 397 397 for (size_t k = 0; k < work->iters; ++k) { … … 400 400 rcu_read_lock(); 401 401 atomic_count_t start_time = atomic_postinc(&cur_time); 402 402 403 403 for (volatile size_t d = 0; d < 10 * i; ++d ){ 404 404 /* no-op */ 405 405 } 406 406 407 407 /* Get most recent max_upd_done_time. */ 408 408 memory_barrier(); 409 409 410 410 if (start_time < max_upd_done_time) { 411 411 seq_test_result = ERACE; 412 412 } 413 413 414 414 rcu_read_unlock(); 415 415 416 416 if (seq_test_result != EOK) 417 417 return; 418 418 } 419 419 420 420 /* Updater */ 421 421 for (size_t i = 0; i < work->update_cnt; ++i) { 422 422 seq_item_t *a = malloc(sizeof(seq_item_t), FRAME_ATOMIC); 423 423 seq_item_t *b = malloc(sizeof(seq_item_t), FRAME_ATOMIC); 424 424 425 425 if (a && b) { 426 426 a->start_time = atomic_postinc(&cur_time); 427 427 rcu_call(&a->rcu, seq_cb); 428 428 429 429 b->start_time = atomic_postinc(&cur_time); 430 430 rcu_call(&b->rcu, seq_cb); … … 437 437 } 438 438 } 439 439 440 440 } 441 441 #else … … 454 454 size_t read_cnt[MAX_THREADS] = {0}; 455 455 seq_work_t item[MAX_THREADS]; 456 456 457 457 size_t total_cbs = 0; 458 458 size_t max_used_mem = 0; 459 459 460 460 get_seq(0, total_cnt, get_thread_cnt(), read_cnt); 461 461 462 462 463 463 for (size_t i = 0; i < get_thread_cnt(); ++i) { … … 465 465 item[i].read_cnt = read_cnt[i]; 466 466 item[i].iters = iters; 467 467 468 468 total_cbs += 2 * iters * item[i].update_cnt; 469 469 } 470 470 471 471 max_used_mem = total_cbs * sizeof(seq_item_t); 472 472 … … 474 474 uint64_t mem_units; 475 475 bin_order_suffix(max_used_mem, &mem_units, &mem_suffix, false); 476 476 477 477 TPRINTF("\nRun %zu th: check callback completion time in readers. " 478 478 "%zu callbacks total (max %" PRIu64 " %s used). Be patient.\n", 479 479 get_thread_cnt(), total_cbs, mem_units, mem_suffix); 480 480 481 481 for (size_t i = 0; i < get_thread_cnt(); ++i) { 482 482 run_one(seq_func, &item[i]); 483 483 } 484 484 485 485 TPRINTF("\nJoining %zu seq-threads\n", get_thread_cnt()); 486 486 join_all(); 487 487 488 488 if (seq_test_result == ENOMEM) { 489 489 TPRINTF("\nErr: out-of mem\n"); … … 491 491 TPRINTF("\nERROR: race detected!!\n"); 492 492 } 493 493 494 494 return seq_test_result == EOK; 495 495 } … … 510 510 rcu_read_lock(); 511 511 rcu_read_unlock(); 512 512 513 513 rcu_call((rcu_item_t*)arg, reader_unlocked); 514 515 rcu_read_lock(); 516 rcu_read_lock(); 517 514 515 rcu_read_lock(); 516 rcu_read_lock(); 517 518 518 /* Exit without unlocking the rcu reader section. */ 519 519 } … … 522 522 { 523 523 TPRINTF("\nReader exits thread with rcu_lock\n"); 524 524 525 525 exited_t *p = malloc(sizeof(exited_t), FRAME_ATOMIC); 526 526 if (!p) { … … 528 528 return false; 529 529 } 530 530 531 531 p->exited = false; 532 532 533 533 run_one(reader_exit, p); 534 534 join_one(); 535 535 536 536 errno_t result = EOK; 537 537 wait_for_cb_exit(2 /* secs */, p, &result); 538 538 539 539 if (result != EOK) { 540 540 TPRINTF("Err: RCU locked up after exiting from within a reader\n"); … … 543 543 free(p); 544 544 } 545 545 546 546 return result == EOK; 547 547 } … … 570 570 571 571 TPRINTF("reader_prev{ "); 572 572 573 573 rcu_read_lock(); 574 574 scheduler(); … … 588 588 preempt_t *p = (preempt_t*)arg; 589 589 assert(!p->e.exited); 590 590 591 591 TPRINTF("reader_inside_cur{ "); 592 592 /* … … 613 613 preempt_t *p = (preempt_t*)arg; 614 614 assert(!p->e.exited); 615 615 616 616 TPRINTF("reader_cur{ "); 617 617 rcu_read_lock(); … … 622 622 /* Preempt while cur GP detection is running */ 623 623 thread_sleep(1); 624 624 625 625 /* Err: exited before this reader completed. */ 626 626 if (p->e.exited) … … 635 635 preempt_t *p = (preempt_t*)arg; 636 636 assert(!p->e.exited); 637 637 638 638 TPRINTF("reader_next1{ "); 639 639 rcu_read_lock(); … … 641 641 /* Preempt before cur GP detection starts. */ 642 642 scheduler(); 643 643 644 644 /* Start GP. */ 645 645 rcu_call(&p->e.rcu, preempted_unlocked); … … 657 657 preempt_t *p = (preempt_t*)arg; 658 658 assert(!p->e.exited); 659 659 660 660 TPRINTF("reader_next2{ "); 661 661 rcu_read_lock(); … … 663 663 /* Preempt before cur GP detection starts. */ 664 664 scheduler(); 665 665 666 666 /* Start GP. */ 667 667 rcu_call(&p->e.rcu, preempted_unlocked); … … 691 691 return false; 692 692 } 693 693 694 694 p->e.exited = false; 695 695 p->result = EOK; 696 696 697 697 run_one(f, p); 698 698 join_one(); 699 699 700 700 /* Wait at most 4 secs. */ 701 701 wait_for_cb_exit(4, &p->e, &p->result); 702 702 703 703 if (p->result == EOK) { 704 704 free(p); … … 714 714 { 715 715 TPRINTF("\nReaders will be preempted.\n"); 716 716 717 717 bool success = true; 718 718 bool ok = true; 719 719 720 720 ok = do_one_reader_preempt(preempted_reader_prev, 721 721 "Err: preempted_reader_prev()\n"); 722 722 success = success && ok; 723 723 724 724 ok = do_one_reader_preempt(preempted_reader_inside_cur, 725 725 "Err: preempted_reader_inside_cur()\n"); 726 726 success = success && ok; 727 727 728 728 ok = do_one_reader_preempt(preempted_reader_cur, 729 729 "Err: preempted_reader_cur()\n"); 730 730 success = success && ok; 731 731 732 732 ok = do_one_reader_preempt(preempted_reader_next1, 733 733 "Err: preempted_reader_next1()\n"); … … 737 737 "Err: preempted_reader_next2()\n"); 738 738 success = success && ok; 739 739 740 740 return success; 741 741 } … … 751 751 { 752 752 synch_t *synch = (synch_t *) arg; 753 753 754 754 rcu_read_lock(); 755 755 756 756 /* Order accesses of synch after the reader section begins. */ 757 757 memory_barrier(); 758 758 759 759 synch->reader_running = true; 760 760 761 761 while (!synch->synch_running) { 762 762 /* 0.5 sec */ 763 763 delay(500 * 1000); 764 764 } 765 765 766 766 /* Run for 1 sec */ 767 767 delay(1000 * 1000); 768 768 /* thread_join() propagates done to do_synch() */ 769 769 synch->reader_done = true; 770 770 771 771 rcu_read_unlock(); 772 772 } … … 776 776 { 777 777 TPRINTF("\nSynchronize with long reader\n"); 778 778 779 779 synch_t *synch = malloc(sizeof(synch_t), FRAME_ATOMIC); 780 780 781 781 if (!synch) { 782 782 TPRINTF("[out-of-mem]\n"); 783 783 return false; 784 784 } 785 785 786 786 synch->reader_done = false; 787 787 synch->reader_running = false; 788 788 synch->synch_running = false; 789 789 790 790 run_one(synch_reader, synch); 791 791 792 792 /* Wait for the reader to enter its critical section. */ 793 793 scheduler(); … … 795 795 thread_usleep(500 * 1000); 796 796 } 797 797 798 798 synch->synch_running = true; 799 799 800 800 rcu_synchronize(); 801 801 join_one(); 802 803 802 803 804 804 if (synch->reader_done) { 805 805 free(synch); … … 827 827 { 828 828 TPRINTF("\nrcu_barrier: Wait for outstanding rcu callbacks to complete\n"); 829 829 830 830 barrier_t *barrier = malloc(sizeof(barrier_t), FRAME_ATOMIC); 831 831 832 832 if (!barrier) { 833 833 TPRINTF("[out-of-mem]\n"); 834 834 return false; 835 835 } 836 836 837 837 atomic_set(&barrier->done, 0); 838 838 839 839 rcu_call(&barrier->rcu_item, barrier_callback); 840 840 rcu_barrier(); 841 841 842 842 if (1 == atomic_get(&barrier->done)) { 843 843 free(barrier); … … 861 861 { 862 862 bool *done = (bool*) arg; 863 863 864 864 while (!*done) { 865 865 rcu_read_lock(); 866 866 rcu_read_unlock(); 867 867 868 868 /* 869 869 * Do some work outside of the reader section so we are not always … … 884 884 { 885 885 stress_t *s = (stress_t *)arg; 886 886 887 887 for (size_t i = 0; i < s->iters; ++i) { 888 888 rcu_item_t *item = malloc(sizeof(rcu_item_t), FRAME_ATOMIC); 889 889 890 890 if (item) { 891 891 rcu_call(item, stress_cb); … … 894 894 return; 895 895 } 896 896 897 897 /* Print a dot if we make a progress of 1% */ 898 898 if (s->master && 0 == (i % (s->iters/100))) … … 907 907 stress_t master = { .iters = cb_per_thread, .master = true }; 908 908 stress_t worker = { .iters = cb_per_thread, .master = false }; 909 909 910 910 size_t thread_cnt = min(MAX_THREADS / 2, config.cpu_active); 911 911 /* Each cpu has one reader and one updater. */ 912 912 size_t reader_cnt = thread_cnt; 913 913 size_t updater_cnt = thread_cnt; 914 914 915 915 size_t exp_upd_calls = updater_cnt * cb_per_thread; 916 916 size_t max_used_mem = exp_upd_calls * sizeof(rcu_item_t); 917 917 918 918 const char *mem_suffix; 919 919 uint64_t mem_units; … … 923 923 " total (max %" PRIu64 " %s used). Be very patient.\n", 924 924 reader_cnt, updater_cnt, exp_upd_calls, mem_units, mem_suffix); 925 925 926 926 for (size_t k = 0; k < reader_cnt; ++k) { 927 927 run_one(stress_reader, &done); … … 931 931 run_one(stress_updater, k > 0 ? &worker : &master); 932 932 } 933 933 934 934 TPRINTF("\nJoining %zu stress updaters.\n", updater_cnt); 935 935 936 936 for (size_t k = 0; k < updater_cnt; ++k) { 937 937 join_one(); 938 938 } 939 939 940 940 done = true; 941 941 942 942 TPRINTF("\nJoining %zu stress nop-readers.\n", reader_cnt); 943 943 944 944 join_all(); 945 945 return true; … … 957 957 { 958 958 expedite_t *e = (expedite_t *)arg; 959 959 960 960 if (1 < e->count_down) { 961 961 --e->count_down; 962 962 963 963 if (0 == (e->count_down % (e->total_cnt/100))) { 964 964 TPRINTF("*"); 965 965 } 966 966 967 967 _rcu_call(e->expedite, &e->r, expedite_cb); 968 968 } else { … … 979 979 e.count_down = cnt; 980 980 e.expedite = exp; 981 981 982 982 _rcu_call(e.expedite, &e.r, expedite_cb); 983 983 984 984 while (0 < e.count_down) { 985 985 thread_sleep(1); … … 992 992 size_t exp_cnt = 1000 * 1000; 993 993 size_t normal_cnt = 1 * 1000; 994 994 995 995 TPRINTF("Expedited: sequence of %zu rcu_calls\n", exp_cnt); 996 996 run_expedite(true, exp_cnt); … … 1024 1024 { 0, NULL, NULL } 1025 1025 }; 1026 1026 1027 1027 bool success = true; 1028 1028 bool ok = true; 1029 1029 uint64_t completed_gps = rcu_completed_gps(); 1030 1030 uint64_t delta_gps = 0; 1031 1031 1032 1032 for (int i = 0; test_func[i].func; ++i) { 1033 1033 if (!test_func[i].include) { … … 1037 1037 TPRINTF("\nRunning subtest %s.\n", test_func[i].desc); 1038 1038 } 1039 1039 1040 1040 ok = test_func[i].func(); 1041 1041 success = success && ok; 1042 1042 1043 1043 delta_gps = rcu_completed_gps() - completed_gps; 1044 1044 completed_gps += delta_gps; -
kernel/test/synch/semaphore1.c
r3061bc1 ra35b458 49 49 { 50 50 thread_detach(THREAD); 51 51 52 52 waitq_sleep(&can_start); 53 53 54 54 semaphore_down(&sem); 55 55 atomic_inc(&items_produced); … … 61 61 { 62 62 thread_detach(THREAD); 63 63 64 64 waitq_sleep(&can_start); 65 65 66 66 semaphore_down(&sem); 67 67 atomic_inc(&items_consumed); … … 75 75 atomic_count_t consumers; 76 76 atomic_count_t producers; 77 77 78 78 waitq_initialize(&can_start); 79 79 semaphore_initialize(&sem, AT_ONCE); 80 80 81 81 for (i = 1; i <= 3; i++) { 82 82 thread_t *thrd; 83 83 84 84 atomic_set(&items_produced, 0); 85 85 atomic_set(&items_consumed, 0); 86 86 87 87 consumers = i * CONSUMERS; 88 88 producers = (4 - i) * PRODUCERS; 89 89 90 90 TPRINTF("Creating %" PRIua " consumers and %" PRIua " producers...", 91 91 consumers, producers); 92 92 93 93 for (j = 0; j < (CONSUMERS + PRODUCERS) / 2; j++) { 94 94 for (k = 0; k < i; k++) { … … 109 109 } 110 110 } 111 111 112 112 TPRINTF("ok\n"); 113 113 114 114 thread_sleep(1); 115 115 waitq_wakeup(&can_start, WAKEUP_ALL); 116 116 117 117 while ((items_consumed.count != consumers) || (items_produced.count != producers)) { 118 118 TPRINTF("%" PRIua " consumers remaining, %" PRIua " producers remaining\n", … … 121 121 } 122 122 } 123 123 124 124 return NULL; 125 125 } -
kernel/test/synch/semaphore2.c
r3061bc1 ra35b458 50 50 { 51 51 uint32_t rc; 52 52 53 53 spinlock_lock(&sem_lock); 54 54 rc = seed % max; … … 62 62 errno_t rc; 63 63 int to; 64 64 65 65 thread_detach(THREAD); 66 66 67 67 waitq_sleep(&can_start); 68 68 69 69 to = random(20000); 70 70 TPRINTF("cpu%u, tid %" PRIu64 " down+ (%d)\n", CPU->id, THREAD->tid, to); … … 74 74 return; 75 75 } 76 76 77 77 TPRINTF("cpu%u, tid %" PRIu64 " down=\n", CPU->id, THREAD->tid); 78 78 thread_usleep(random(30000)); 79 79 80 80 semaphore_up(&sem); 81 81 TPRINTF("cpu%u, tid %" PRIu64 " up\n", CPU->id, THREAD->tid); … … 85 85 { 86 86 uint32_t i, k; 87 87 88 88 waitq_initialize(&can_start); 89 89 semaphore_initialize(&sem, 5); 90 90 91 91 thread_t *thrd; 92 92 93 93 k = random(7) + 1; 94 94 TPRINTF("Creating %" PRIu32 " consumers\n", k); … … 101 101 TPRINTF("Error creating thread\n"); 102 102 } 103 103 104 104 thread_usleep(20000); 105 105 waitq_wakeup(&can_start, WAKEUP_ALL); 106 106 107 107 return NULL; 108 108 } -
kernel/test/synch/workq-test-core.h
r3061bc1 ra35b458 54 54 { 55 55 ++work->wave; 56 56 57 57 if (work->wave < WAVES) { 58 58 work->count_down = COUNT; … … 79 79 child->count_down = work->count_down; 80 80 } 81 81 82 82 return child; 83 83 } … … 93 93 /* Ensure work_item is ours for the taking. */ 94 94 memsetb(work_item, sizeof(work_t), 0xec); 95 95 96 96 test_work_t *work = (test_work_t *)work_item; 97 97 98 98 atomic_inc(&call_cnt[work->wave]); 99 99 100 100 if (0 < work->count_down) { 101 101 /* Sleep right before creating the last generation. */ … … 108 108 } 109 109 } 110 110 111 111 --work->count_down; 112 112 … … 122 122 } 123 123 } 124 124 125 125 if (!core_workq_enqueue(work_item, reproduce)) { 126 126 if (work->master) … … 131 131 } else { 132 132 /* We're done with this wave - only the master survives. */ 133 133 134 134 if (work->master && new_wave(work)) { 135 135 if (!core_workq_enqueue(work_item, reproduce)) { … … 140 140 if (work->master) 141 141 TPRINTF("\nMaster work item done.\n"); 142 142 143 143 free_work(work); 144 144 } … … 157 157 work->wave = 0; 158 158 work->count_down = COUNT; 159 159 160 160 /* 161 161 * k == COUNT_POW … … 166 166 */ 167 167 size_t exp_call_cnt = (COUNT_POW + 2) * (1 << (COUNT_POW - 1)); 168 168 169 169 TPRINTF("waves: %d, count_down: %d, total expected calls: %zu\n", 170 170 WAVES, COUNT, exp_call_cnt * WAVES); 171 171 172 172 173 173 core_workq_enqueue(&work->work_item, reproduce); 174 174 175 175 size_t sleep_cnt = 0; 176 176 /* At least 40 seconds total (or 2 sec to end while there's work). */ 177 177 size_t max_sleep_secs = end_prematurely ? 2 : MAIN_MAX_SLEEP_SEC; 178 178 size_t max_sleep_cnt = (max_sleep_secs * 1000) / MAIN_POLL_SLEEP_MS; 179 179 180 180 for (int i = 0; i < WAVES; ++i) { 181 181 while (atomic_get(&call_cnt[i]) < exp_call_cnt … … 186 186 } 187 187 } 188 188 189 189 bool success = true; 190 190 191 191 for (int i = 0; i < WAVES; ++i) { 192 192 if (atomic_get(&call_cnt[i]) == exp_call_cnt) { … … 199 199 } 200 200 } 201 202 201 202 203 203 if (success) 204 204 return NULL; -
kernel/test/synch/workqueue2.c
r3061bc1 ra35b458 63 63 basic_done = 0; 64 64 workq_global_enqueue(&basic_work, basic_test_work); 65 65 66 66 while (!basic_done) { 67 67 TPRINTF("."); … … 87 87 { 88 88 workq = workq_create(qname); 89 89 90 90 if (!workq) { 91 91 return "Failed to create a work queue.\n"; 92 92 } 93 93 94 94 const char *ret = run_workq_core(stop); 95 95 96 96 TPRINTF("Stopping work queue...\n"); 97 97 workq_stop(workq); 98 98 99 99 TPRINTF("Destroying work queue...\n"); 100 100 workq_destroy(workq); … … 123 123 const char *err = NULL; 124 124 const char *res; 125 125 126 126 basic_test(); 127 127 128 128 res = test_custom_workq(); 129 129 if (res) { … … 131 131 err = res; 132 132 } 133 133 134 134 res = test_custom_workq_stop(); 135 135 if (res) { … … 137 137 err = res; 138 138 } 139 139 140 140 res = test_workqueue3(); 141 141 if (res) { -
kernel/test/synch/workqueue3.c
r3061bc1 ra35b458 66 66 67 67 TPRINTF("Done.\n"); 68 68 69 69 return err; 70 70 } -
kernel/test/test.c
r3061bc1 ra35b458 75 75 size_t len = str_length(input); 76 76 test_t **test = (test_t **) ctx; 77 77 78 78 if (*test == NULL) 79 79 *test = tests; 80 80 81 81 for (; (*test)->name; (*test)++) { 82 82 const char *curname = (*test)->name; 83 83 84 84 if (str_length(curname) < len) 85 85 continue; 86 86 87 87 if (str_lcmp(input, curname, len) == 0) { 88 88 (*test)++; … … 92 92 } 93 93 } 94 94 95 95 return NULL; 96 96 } -
kernel/test/thread/thread1.c
r3061bc1 ra35b458 45 45 { 46 46 thread_detach(THREAD); 47 47 48 48 while (atomic_get(&finish)) { 49 49 TPRINTF("%" PRIu64 " ", THREAD->tid); … … 57 57 unsigned int i; 58 58 atomic_count_t total = 0; 59 59 60 60 atomic_set(&finish, 1); 61 61 atomic_set(&threads_finished, 0); 62 62 63 63 for (i = 0; i < THREADS; i++) { 64 64 thread_t *t; … … 71 71 total++; 72 72 } 73 73 74 74 TPRINTF("Running threads for 10 seconds...\n"); 75 75 thread_sleep(10); 76 76 77 77 atomic_set(&finish, 0); 78 78 while (atomic_get(&threads_finished) < total) { … … 80 80 thread_sleep(1); 81 81 } 82 82 83 83 return NULL; 84 84 }
Note:
See TracChangeset
for help on using the changeset viewer.