Changeset a35b458 in mainline for kernel/test


Ignore:
Timestamp:
2018-03-02T20:10:49Z (7 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
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)
Message:

style: Remove trailing whitespace on _all_ lines, including empty ones, for particular file types.

Command used: tools/srepl '\s\+$' '' -- *.c *.h *.py *.sh *.s *.S *.ag

Currently, whitespace on empty lines is very inconsistent.
There are two basic choices: Either remove the whitespace, or keep empty lines
indented to the level of surrounding code. The former is AFAICT more common,
and also much easier to do automatically.

Alternatively, we could write script for automatic indentation, and use that
instead. However, if such a script exists, it's possible to use the indented
style locally, by having the editor apply relevant conversions on load/save,
without affecting remote repository. IMO, it makes more sense to adopt
the simpler rule.

Location:
kernel/test
Files:
26 edited

Legend:

Unmodified
Added
Removed
  • kernel/test/atomic/atomic1.c

    r3061bc1 ra35b458  
    3535{
    3636        atomic_t a;
    37        
     37
    3838        atomic_set(&a, 10);
    3939        if (atomic_get(&a) != 10)
    4040                return "Failed atomic_set()/atomic_get()";
    41        
     41
    4242        if (atomic_postinc(&a) != 10)
    4343                return "Failed atomic_postinc()";
    4444        if (atomic_get(&a) != 11)
    4545                return "Failed atomic_get() after atomic_postinc()";
    46        
     46
    4747        if (atomic_postdec(&a) != 11)
    4848                return "Failed atomic_postdec()";
    4949        if (atomic_get(&a) != 10)
    5050                return "Failed atomic_get() after atomic_postdec()";
    51        
     51
    5252        if (atomic_preinc(&a) != 11)
    5353                return "Failed atomic_preinc()";
    5454        if (atomic_get(&a) != 11)
    5555                return "Failed atomic_get() after atomic_preinc()";
    56        
     56
    5757        if (atomic_predec(&a) != 10)
    5858                return "Failed atomic_predec()";
    5959        if (atomic_get(&a) != 10)
    6060                return "Failed atomic_get() after atomic_predec()";
    61        
     61
    6262        return NULL;
    6363}
  • kernel/test/avltree/avltree1.c

    r3061bc1 ra35b458  
    5656{
    5757        avltree_node_t *tmp;
    58        
     58
    5959        if (!node)
    6060                return NULL;
    61        
     61
    6262        if (node->lft) {
    6363                tmp = test_tree_parents(node->lft);
     
    8181{
    8282        int h1, h2, diff;
    83        
     83
    8484        if (!node)
    8585                return 0;
    86        
     86
    8787        h1 = test_tree_balance(node->lft);
    8888        h2 = test_tree_balance(node->rgt);
    8989        diff = h2 - h1;
    90        
     90
    9191        if ((diff != node->balance) || ((diff != -1) && (diff != 0) && (diff != 1)))
    9292                TPRINTF("Bad balance\n");
    93        
     93
    9494        return ((h1 > h2) ? (h1 + 1) : (h2 + 1));
    9595}
     
    110110                return;
    111111        }
    112        
     112
    113113        if (node == NULL)
    114114                return;
    115        
     115
    116116        TPRINTF("%" PRIu64 "[%" PRIu8 "]", node->key, node->balance);
    117117        if (node->lft != NULL || node->rgt != NULL) {
    118118                TPRINTF("(");
    119                
     119
    120120                print_tree_structure_flat(node->lft, level + 1);
    121121                if (node->rgt != NULL) {
     
    123123                        print_tree_structure_flat(node->rgt, level + 1);
    124124                }
    125                
     125
    126126                TPRINTF(")");
    127127        }
     
    131131{
    132132        int i;
    133        
     133
    134134        for (i = 0; i < NODE_COUNT - 1; i++)
    135135                avltree_nodes[i].par = &avltree_nodes[i + 1];
    136        
     136
    137137        avltree_nodes[i].par = NULL;
    138        
     138
    139139        /*
    140140         * Node keys which will be used for insertion. Up to NODE_COUNT size of
    141141         * array.
    142142         */
    143        
     143
    144144        /* First tree node and same key */
    145145        avltree_nodes[0].key = 60;
    146146        avltree_nodes[1].key = 60;
    147147        avltree_nodes[2].key = 60;
    148        
     148
    149149        /* LL rotation */
    150150        avltree_nodes[3].key = 50;
    151151        avltree_nodes[4].key = 40;
    152152        avltree_nodes[5].key = 30;
    153        
     153
    154154        /* LR rotation */
    155155        avltree_nodes[6].key = 20;
     
    157157        avltree_nodes[8].key = 25;
    158158        avltree_nodes[9].key = 25;
    159        
     159
    160160        /* LL rotation in lower floor */
    161161        avltree_nodes[10].key = 35;
    162        
     162
    163163        /* RR rotation */
    164164        avltree_nodes[11].key = 70;
    165165        avltree_nodes[12].key = 80;
    166        
     166
    167167        /* RL rotation */
    168168        avltree_nodes[13].key = 90;
    169169        avltree_nodes[14].key = 85;
    170        
     170
    171171        /* Insert 0 key */
    172172        avltree_nodes[15].key = 0;
    173173        avltree_nodes[16].key = 0;
    174        
     174
    175175        /* Insert reverse */
    176176        avltree_nodes[17].key = 600;
     
    178178        avltree_nodes[19].key = 400;
    179179        avltree_nodes[20].key = 300;
    180        
     180
    181181        for (i = 21; i < NODE_COUNT; i++)
    182182                avltree_nodes[i].key = i * 3;
    183        
     183
    184184        first_free_node = &avltree_nodes[0];
    185185}
     
    188188{
    189189        avltree_node_t *node;
    190        
     190
    191191        node = first_free_node;
    192192        first_free_node = first_free_node->par;
    193        
     193
    194194        return node;
    195195}
     
    199199        unsigned int i;
    200200        avltree_node_t *newnode;
    201        
     201
    202202        avltree_create(tree);
    203        
     203
    204204        TPRINTF("Inserting %zu nodes...", node_count);
    205        
     205
    206206        for (i = 0; i < node_count; i++) {
    207207                newnode = alloc_avltree_node();
    208                
     208
    209209                avltree_insert(tree, newnode);
    210210                test_tree_parents(tree->root);
    211211                test_tree_balance(tree->root);
    212212        }
    213        
     213
    214214        TPRINTF("done.\n");
    215215}
     
    220220        avltree_node_t *delnode;
    221221        unsigned int i;
    222        
     222
    223223        switch (node_position) {
    224224        case 0:
    225225                TPRINTF("Deleting root nodes...");
    226                
     226
    227227                while (tree->root != NULL) {
    228228                        delnode = tree->root;
     
    234234        case 1:
    235235                TPRINTF("Deleting nodes according to creation time...");
    236                
     236
    237237                for (i = 0; i < node_count; i++) {
    238238                        avltree_delete(tree, &avltree_nodes[i]);
     
    242242                break;
    243243        }
    244        
     244
    245245        TPRINTF("done.\n");
    246246}
     
    249249{
    250250        unsigned int i = 0;
    251        
     251
    252252        TPRINTF("Deleting minimum nodes...");
    253        
     253
    254254        while (tree->root != NULL) {
    255255                i++;
     
    258258                test_tree_balance(tree->root);
    259259        }
    260        
     260
    261261        if (i != node_count)
    262262                TPRINTF("Bad node count. Some nodes have been lost!\n");
    263        
     263
    264264        TPRINTF("done.\n");
    265265}
     
    270270        test_tree_insert(&avltree, NODE_COUNT);
    271271        test_tree_delete(&avltree, NODE_COUNT, 0);
    272        
     272
    273273        alloc_avltree_node_prepare();
    274274        test_tree_insert(&avltree, NODE_COUNT);
    275275        test_tree_delete(&avltree, NODE_COUNT, 1);
    276        
     276
    277277        alloc_avltree_node_prepare();
    278278        test_tree_insert(&avltree, NODE_COUNT);
    279279        test_tree_delmin(&avltree, NODE_COUNT);
    280        
     280
    281281        return NULL;
    282282}
  • kernel/test/btree/btree1.c

    r3061bc1 ra35b458  
    3838        btree_t t;
    3939        int i;
    40        
     40
    4141        btree_create(&t);
    42        
     42
    4343        TPRINTF("Inserting keys.\n");
    4444        btree_insert(&t, 19, data, NULL);
     
    7777        for (i = 100; i >= 50; i--)
    7878                btree_insert(&t, i, data, NULL);
    79        
     79
    8080        if (!test_quiet)
    8181                btree_print(&t);
    82        
     82
    8383        TPRINTF("Removing keys.\n");
    8484        btree_remove(&t, 50, NULL);
     
    156156        btree_remove(&t, 35, NULL);
    157157        btree_remove(&t, 36, NULL);
    158        
     158
    159159        if (!test_quiet)
    160160                btree_print(&t);
    161        
     161
    162162        return NULL;
    163163}
  • kernel/test/cht/cht1.c

    r3061bc1 ra35b458  
    9999        if (cht_find_lazy(h, (void*)0))
    100100                return "Found lazy in empty table.";
    101        
     101
    102102        if (cht_find(h, (void*)0))
    103103                return "Found in empty table.";
    104        
     104
    105105        if (cht_remove_key(h, (void*)0))
    106106                return "Removed from empty table.";
    107        
     107
    108108        const int val_cnt = 6;
    109109        val_t *v[6] = { NULL };
    110        
     110
    111111        for (int i = 0; i < val_cnt; ++i)
    112112                v[i] = malloc(sizeof(val_t), 0);
    113        
     113
    114114        size_t key[] = { 1, 1, 1, 11, 12, 13 };
    115        
     115
    116116        /* First three are identical */
    117117        for (int i = 0; i < 3; ++i)
    118118                set_val(v[i], 1, key[i]);
    119        
     119
    120120        /* Same hash, different key.*/
    121121        set_val(v[3], 1, key[3]);
    122        
     122
    123123        /* Different hashes and keys. */
    124124        set_val(v[4], 2, key[4]);
    125125        set_val(v[5], 3, key[5]);
    126        
     126
    127127        cht_link_t *dup;
    128                        
     128
    129129        if (!cht_insert_unique(h, &v[0]->link, &dup))
    130130                return "Duplicates in empty";
     
    132132        if (cht_insert_unique(h, &v[1]->link, &dup))
    133133                return "Inserted a duplicate";
    134        
     134
    135135        if (dup != &v[0]->link)
    136136                return "Returned wrong duplicate";
     
    138138        if (!cht_insert_unique(h, &v[3]->link, &dup))
    139139                return "Refused non-equal item but with a hash in table.";
    140        
     140
    141141        cht_insert(h, &v[1]->link);
    142142        cht_insert(h, &v[2]->link);
    143        
     143
    144144        bool ok = true;
    145145        ok = ok && cht_insert_unique(h, &v[4]->link, &dup);
    146146        ok = ok && cht_insert_unique(h, &v[5]->link, &dup);
    147        
     147
    148148        if (!ok)
    149149                return "Refused unique ins 4, 5.";
    150        
     150
    151151        if (cht_find(h, (void*)0))
    152152                return "Phantom find.";
    153        
     153
    154154        cht_link_t *item = cht_find(h, (void*)v[5]->unique_id);
    155155        if (!item || item != &v[5]->link)
     
    159159        if (item)
    160160                return "Found nonexisting duplicate 5";
    161        
     161
    162162        item = cht_find(h, (void*)v[3]->unique_id);
    163163        if (!item || item != &v[3]->link)
     
    167167        if (item)
    168168                return "Found nonexisting duplicate 3, same hash as others.";
    169        
     169
    170170        item = cht_find(h, (void*)v[0]->unique_id);
    171171        ((val_t*)item)->mark = true;
    172        
     172
    173173        for (int k = 1; k < 3; ++k) {
    174174                item = cht_find_next(h, item);
    175175                if (!item)
    176176                        return "Did not find an inserted duplicate";
    177                
     177
    178178                val_t *val = ((val_t*)item);
    179                
     179
    180180                if (val->unique_id != v[0]->unique_id)
    181181                        return "Found item with a different key.";
     
    184184                val->mark = true;
    185185        }
    186        
     186
    187187        for (int i = 0; i < 3; ++i) {
    188188                if (!v[i]->mark)
    189189                        return "Did not find all duplicates";
    190                
     190
    191191                v[i]->mark = false;
    192192        }
     
    196196
    197197        item = cht_find_next(h, cht_find(h, (void*)key[0]));
    198        
     198
    199199        ((val_t*)item)->mark = true;
    200200        if (!cht_remove_item(h, item))
    201201                return "Failed to remove inserted item";
    202        
     202
    203203        item = cht_find(h, (void*)key[0]);
    204204        if (!item || ((val_t*)item)->mark)
    205205                return "Did not find proper item.";
    206        
     206
    207207        item = cht_find_next(h, item);
    208208        if (!item || ((val_t*)item)->mark)
     
    212212        if (item)
    213213                return "Found removed duplicate";
    214        
     214
    215215        if (2 != cht_remove_key(h, (void*)key[0]))
    216216                return "Failed to remove all duplicates";
    217        
     217
    218218        if (cht_find(h, (void*)key[0]))
    219219                return "Found removed key";
    220        
     220
    221221        if (!cht_find(h, (void*)key[3]))
    222222                return "Removed incorrect key";
    223        
     223
    224224        for (size_t k = 0; k < sizeof(v) / sizeof(v[0]); ++k) {
    225225                cht_remove_key(h, (void*)key[k]);
    226226        }
    227        
     227
    228228        for (size_t k = 0; k < sizeof(v) / sizeof(v[0]); ++k) {
    229229                if (cht_find(h, (void*)key[k]))
     
    239239        if (!cht_create_simple(&h, &val_ops))
    240240                return "Could not create the table.";
    241        
     241
    242242        rcu_read_lock();
    243243        const char *err = do_sanity_test(&h);
    244244        rcu_read_unlock();
    245        
     245
    246246        cht_destroy(&h);
    247247
     
    321321                                goto out_of_mem;
    322322                        }
    323                        
     323
    324324                        s->free = true;
    325325                        s->key = (i << 8) + work->id;
    326                        
     326
    327327                        cht_insert(work->h, &s->link);
    328328                }
    329329                TPRINTF("}");
    330                
     330
    331331                thread_sleep(2);
    332332
     
    334334                for (size_t i = 0; i < work->wave_elems; ++i) {
    335335                        size_t key = (i << 8) + work->id;
    336                        
     336
    337337                        if (1 != cht_remove_key(work->h, (void*)key)) {
    338338                                TPRINTF("Err: Failed to remove inserted item\n");
     
    342342                TPRINTF(">");
    343343        }
    344        
     344
    345345        /* Request that others stop. */
    346346        *work->stop = 1;
     
    365365        stress_work_t *work = (stress_work_t *)arg;
    366366        assert(0 == *work->stop);
    367        
     367
    368368        size_t loops = 0;
    369369        size_t seed = work->id;
    370                
     370
    371371        while (0 == *work->stop && !work->failed) {
    372372                seed = next_rand(seed);
     
    374374                seed = next_rand(seed);
    375375                size_t elem_idx = seed % work->elem_cnt;
    376                
     376
    377377                ++loops;
    378378                if (0 == loops % (1024 * 1024)) {
     
    381381                        TPRINTF("*");
    382382                }
    383                        
     383
    384384                if (upd) {
    385385                        seed = next_rand(seed);
    386386                        bool item_op = seed & 1;
    387                        
     387
    388388                        if (work->elem[elem_idx].inserted) {
    389389                                if (item_op) {
     
    401401                        } else if (work->elem[elem_idx].deleted) {
    402402                                work->elem[elem_idx].deleted = false;
    403                                
     403
    404404                                if (item_op) {
    405405                                        rcu_read_lock();
     
    414414                                        cht_insert(work->h, &work->elem[elem_idx].link);
    415415                                }
    416                                
     416
    417417                                work->elem[elem_idx].inserted = true;
    418418                        }
     
    452452{
    453453        cht_t h;
    454        
     454
    455455        if (!cht_create_simple(&h, &stress_ops)) {
    456456                TPRINTF("Failed to create the table\n");
     
    464464        size_t total_thr_cnt = op_thread_cnt + resize_thread_cnt;
    465465        size_t items_per_thread = 1024;
    466        
     466
    467467        size_t work_cnt = op_thread_cnt + resize_thread_cnt;
    468468        size_t item_cnt = op_thread_cnt * items_per_thread;
    469        
     469
    470470        /* Alloc hash table items. */
    471471        size_t size = item_cnt * sizeof(stress_t) + work_cnt * sizeof(stress_work_t)
    472472                + sizeof(int);
    473                
     473
    474474        TPRINTF("Alloc and init table items. \n");
    475475        void *p = malloc(size, FRAME_ATOMIC);
     
    479479                return false;
    480480        }
    481        
     481
    482482        stress_t *pitem = p + work_cnt * sizeof(stress_work_t);
    483483        stress_work_t *pwork = p;
    484484        int *pstop = (int*)(pitem + item_cnt);
    485        
     485
    486486        *pstop = 0;
    487        
     487
    488488        /* Init work items. */
    489489        for (size_t i = 0; i < op_thread_cnt; ++i) {
     
    496496                pwork[i].failed = false;
    497497        }
    498        
     498
    499499        for (size_t i = op_thread_cnt; i < op_thread_cnt + resize_thread_cnt; ++i) {
    500500                pwork[i].h = &h;
     
    505505                pwork[i].failed = false;
    506506        }
    507        
     507
    508508        /* Init table elements. */
    509509        for (size_t k = 0; k < op_thread_cnt; ++k) {
     
    515515                }
    516516        }
    517        
     517
    518518        TPRINTF("Running %zu ins/del/find stress threads + %zu resizers.\n",
    519519                op_thread_cnt, resize_thread_cnt);
    520        
     520
    521521        /* Create and run threads. */
    522522        thread_t *thr[max_thread_cnt + resize_thread_cnt];
    523        
     523
    524524        for (size_t i = 0; i < total_thr_cnt; ++i) {
    525525                if (i < op_thread_cnt)
     
    527527                else
    528528                        thr[i] = thread_create(resize_stresser, &pwork[i], TASK, 0, "cht-resize");
    529                
     529
    530530                assert(thr[i]);
    531531                thread_wire(thr[i], &cpus[i % config.cpu_active]);
    532532                thread_ready(thr[i]);
    533533        }
    534        
     534
    535535        bool failed = false;
    536        
     536
    537537        /* Wait for all threads to return. */
    538538        TPRINTF("Joining resize stressers.\n");
     
    542542                failed = pwork[i].failed || failed;
    543543        }
    544        
     544
    545545        TPRINTF("Joining op stressers.\n");
    546546        for (int i = (int)op_thread_cnt - 1; i >= 0; --i) {
     
    550550                failed = pwork[i].failed || failed;
    551551        }
    552        
     552
    553553        cht_destroy(&h);
    554554        free(p);
     
    566566                return err;
    567567        printf("Basic sanity test: ok.\n");
    568        
     568
    569569        if (!do_stress())
    570570                return "CHT stress test failed.";
  • kernel/test/debug/mips1.c

    r3061bc1 ra35b458  
    4040{
    4141        TPRINTF("If kconsole is compiled in, you should enter debug mode now.\n");
    42        
     42
    4343        asm volatile (
    4444                "break\n"
    4545        );
    46        
     46
    4747        return "Back from debug mode";
    4848}
  • kernel/test/fault/fault1.c

    r3061bc1 ra35b458  
    4040{
    4141        ((int *)(0))[1] = 0;
    42        
     42
    4343        return "Written to NULL";
    4444}
  • kernel/test/mm/falloc1.c

    r3061bc1 ra35b458  
    4545        if (TEST_RUNS < 2)
    4646                return "Test is compiled with TEST_RUNS < 2";
    47        
     47
    4848        uintptr_t *frames = (uintptr_t *)
    4949            malloc(MAX_FRAMES * sizeof(uintptr_t), 0);
    5050        if (frames == NULL)
    5151                return "Unable to allocate frames";
    52        
     52
    5353        unsigned int results[MAX_FRAMES + 1];
    54        
     54
    5555        for (unsigned int run = 0; run < TEST_RUNS; run++) {
    5656                for (size_t count = 1; count <= MAX_FRAMES; count++) {
    5757                        size_t bytes = FRAMES2SIZE(count);
    58                        
     58
    5959                        TPRINTF("Allocating %zu frames blocks (%zu bytes) ... ",
    6060                            count, bytes);
    61                        
     61
    6262                        unsigned int allocated = 0;
    6363                        for (unsigned int i = 0; i < (MAX_FRAMES / count); i++) {
     
    7070                                }
    7171                        }
    72                        
     72
    7373                        TPRINTF("%d blocks allocated.\n", allocated);
    74                        
     74
    7575                        if (run > 0) {
    7676                                if (results[count] != allocated)
     
    7878                        } else
    7979                                results[count] = allocated;
    80                        
     80
    8181                        TPRINTF("Deallocating ... ");
    82                        
     82
    8383                        for (unsigned int i = 0; i < allocated; i++)
    8484                                frame_free(frames[i], count);
    85                        
     85
    8686                        TPRINTF("done.\n");
    8787                }
    8888        }
    89        
     89
    9090        free(frames);
    91        
     91
    9292        return NULL;
    9393}
  • kernel/test/mm/falloc2.c

    r3061bc1 ra35b458  
    5151{
    5252        uint8_t val = THREAD->tid % THREADS;
    53        
     53
    5454        uintptr_t *frames = (uintptr_t *)
    5555            malloc(MAX_FRAMES * sizeof(uintptr_t), FRAME_ATOMIC);
     
    6161                return;
    6262        }
    63        
     63
    6464        thread_detach(THREAD);
    65        
     65
    6666        for (unsigned int run = 0; run < THREAD_RUNS; run++) {
    6767                for (size_t count = 1; count <= MAX_FRAMES; count++) {
    6868                        size_t bytes = FRAMES2SIZE(count);
    69                        
     69
    7070                        TPRINTF("Thread #%" PRIu64 " (cpu%u): "
    7171                            "Allocating %zu frames blocks (%zu bytes) ... \n", THREAD->tid,
    7272                            CPU->id, count, bytes);
    73                        
     73
    7474                        unsigned int allocated = 0;
    7575                        for (unsigned int i = 0; i < (MAX_FRAMES / count); i++) {
     
    8181                                        break;
    8282                        }
    83                        
     83
    8484                        TPRINTF("Thread #%" PRIu64 " (cpu%u): "
    8585                            "%u blocks allocated.\n", THREAD->tid, CPU->id,
     
    8787                        TPRINTF("Thread #%" PRIu64 " (cpu%u): "
    8888                            "Deallocating ... \n", THREAD->tid, CPU->id);
    89                        
     89
    9090                        for (unsigned int i = 0; i < allocated; i++) {
    9191                                for (size_t k = 0; k < bytes; k++) {
     
    101101                                frame_free(frames[i], count);
    102102                        }
    103                        
     103
    104104                        TPRINTF("Thread #%" PRIu64 " (cpu%u): "
    105105                            "Finished run.\n", THREAD->tid, CPU->id);
    106106                }
    107107        }
    108        
     108
    109109cleanup:
    110110        free(frames);
    111        
     111
    112112        TPRINTF("Thread #%" PRIu64 " (cpu%u): Exiting\n",
    113113            THREAD->tid, CPU->id);
     
    119119        atomic_set(&thread_count, THREADS);
    120120        atomic_set(&thread_fail, 0);
    121        
     121
    122122        for (unsigned int i = 0; i < THREADS; i++) {
    123123                thread_t *thrd = thread_create(falloc, NULL, TASK,
     
    129129                thread_ready(thrd);
    130130        }
    131        
     131
    132132        while (atomic_get(&thread_count) > 0) {
    133133                TPRINTF("Threads left: %" PRIua "\n",
     
    135135                thread_sleep(1);
    136136        }
    137        
     137
    138138        if (atomic_get(&thread_fail) == 0)
    139139                return NULL;
    140        
     140
    141141        return "Test failed";
    142142}
  • kernel/test/mm/mapping1.c

    r3061bc1 ra35b458  
    4242{
    4343        uintptr_t frame = frame_alloc(1, FRAME_NONE, 0);
    44        
     44
    4545        uintptr_t page0 = km_map(frame, FRAME_SIZE,
    4646            PAGE_READ | PAGE_WRITE | PAGE_CACHEABLE);
    4747        TPRINTF("Virtual address %p mapped to physical address %p.\n",
    4848            (void *) page0, (void *) frame);
    49        
     49
    5050        uintptr_t page1 = km_map(frame, FRAME_SIZE,
    5151            PAGE_READ | PAGE_WRITE | PAGE_CACHEABLE);
    5252        TPRINTF("Virtual address %p mapped to physical address %p.\n",
    5353            (void *) page1, (void *) frame);
    54        
     54
    5555        for (unsigned int i = 0; i < 2; i++) {
    5656                TPRINTF("Writing magic using the first virtual address.\n");
    57                
     57
    5858                *((uint32_t *) page0) = TEST_MAGIC;
    59                
     59
    6060                TPRINTF("Reading magic using the second virtual address.\n");
    61                
     61
    6262                uint32_t v = *((uint32_t *) page1);
    63                
     63
    6464                if (v != TEST_MAGIC) {
    6565                        km_unmap(page0, PAGE_SIZE);
     
    6868                        return "Criss-cross read does not match the value written.";
    6969                }
    70                
     70
    7171                TPRINTF("Writing zero using the second virtual address.\n");
    72                
     72
    7373                *((uint32_t *) page1) = 0;
    74                
     74
    7575                TPRINTF("Reading zero using the first virtual address.\n");
    76                
     76
    7777                v = *((uint32_t *) page0);
    78                
     78
    7979                if (v != 0) {
    8080                        km_unmap(page0, PAGE_SIZE);
     
    8484                }
    8585        }
    86        
     86
    8787        km_unmap(page0, PAGE_SIZE);
    8888        km_unmap(page1, PAGE_SIZE);
    8989        frame_free(frame, 1);
    90        
     90
    9191        return NULL;
    9292}
  • kernel/test/mm/purge1.c

    r3061bc1 ra35b458  
    4444        tlb_entry_t entryi;
    4545        tlb_entry_t entryd;
    46        
     46
    4747        int i;
    48        
     48
    4949        entryd.word[0] = 0;
    5050        entryd.word[1] = 0;
    51        
     51
    5252        entryd.p = true;                 /* present */
    5353        entryd.ma = MA_WRITEBACK;
     
    5858        entryd.ppn = 0;
    5959        entryd.ps = PAGE_WIDTH;
    60        
     60
    6161        entryi.word[0] = 0;
    6262        entryi.word[1] = 0;
    63        
     63
    6464        entryi.p = true;                 /* present */
    6565        entryi.ma = MA_WRITEBACK;
     
    7070        entryi.ppn = 0;
    7171        entryi.ps = PAGE_WIDTH;
    72        
     72
    7373        for (i = 0; i < 100; i++) {
    7474                itc_mapping_insert(0 + i * (1 << PAGE_WIDTH), 8, entryi);
    7575                dtc_mapping_insert(0 + i * (1 << PAGE_WIDTH), 9, entryd);
    7676        }
    77        
     77
    7878        tlb_invalidate_pages(8, 0x0c000, 14);
    79        
     79
    8080        /* tlb_invalidate_all(); */
    81        
     81
    8282        return NULL;
    8383}
  • kernel/test/mm/slab1.c

    r3061bc1 ra35b458  
    4242        slab_cache_t *cache;
    4343        int i;
    44        
     44
    4545        TPRINTF("Creating cache, object size: %d.\n", size);
    46        
     46
    4747        cache = slab_cache_create("test_cache", size, 0, NULL, NULL,
    4848            SLAB_CACHE_NOMAGAZINE);
    49        
     49
    5050        TPRINTF("Allocating %d items...", count);
    51        
     51
    5252        for (i = 0; i < count; i++) {
    5353                data[i] = slab_alloc(cache, 0);
    5454                memsetb(data[i], size, 0);
    5555        }
    56        
     56
    5757        TPRINTF("done.\n");
    58        
     58
    5959        TPRINTF("Freeing %d items...", count);
    60        
     60
    6161        for (i = 0; i < count; i++)
    6262                slab_free(cache, data[i]);
    63        
     63
    6464        TPRINTF("done.\n");
    65        
     65
    6666        TPRINTF("Allocating %d items...", count);
    67        
     67
    6868        for (i = 0; i < count; i++) {
    6969                data[i] = slab_alloc(cache, 0);
    7070                memsetb(data[i], size, 0);
    7171        }
    72        
     72
    7373        TPRINTF("done.\n");
    74        
     74
    7575        TPRINTF("Freeing %d items...", count / 2);
    76        
     76
    7777        for (i = count - 1; i >= count / 2; i--)
    7878                slab_free(cache, data[i]);
    79        
     79
    8080        TPRINTF("done.\n");
    81        
     81
    8282        TPRINTF("Allocating %d items...", count / 2);
    83        
     83
    8484        for (i = count / 2; i < count; i++) {
    8585                data[i] = slab_alloc(cache, 0);
    8686                memsetb(data[i], size, 0);
    8787        }
    88        
     88
    8989        TPRINTF("done.\n");
    90        
     90
    9191        TPRINTF("Freeing %d items...", count);
    92        
     92
    9393        for (i = 0; i < count; i++)
    9494                slab_free(cache, data[i]);
    95        
     95
    9696        TPRINTF("done.\n");
    97        
     97
    9898        slab_cache_destroy(cache);
    99        
     99
    100100        TPRINTF("Test complete.\n");
    101101}
     
    125125        int offs = (int) (sysarg_t) data;
    126126        int i, j;
    127        
     127
    128128        thread_detach(THREAD);
    129        
     129
    130130        TPRINTF("Starting thread #%" PRIu64 "...\n", THREAD->tid);
    131        
     131
    132132        for (j = 0; j < 10; j++) {
    133133                for (i = 0; i < THR_MEM_COUNT; i++)
     
    140140                        slab_free(thr_cache, thr_data[offs][i]);
    141141        }
    142        
     142
    143143        TPRINTF("Thread #%" PRIu64 " finished\n", THREAD->tid);
    144        
     144
    145145        semaphore_up(&thr_sem);
    146146}
     
    150150        thread_t *t;
    151151        int i;
    152        
     152
    153153        thr_cache = slab_cache_create("thread_cache", THR_MEM_SIZE, 0, NULL, NULL,
    154154            SLAB_CACHE_NOMAGAZINE);
    155        
     155
    156156        semaphore_initialize(&thr_sem, 0);
    157157        for (i = 0; i < THREADS; i++) {
     
    164164        for (i = 0; i < THREADS; i++)
    165165                semaphore_down(&thr_sem);
    166        
     166
    167167        slab_cache_destroy(thr_cache);
    168        
     168
    169169        TPRINTF("Test complete.\n");
    170170}
     
    174174        testsimple();
    175175        testthreads();
    176        
     176
    177177        return NULL;
    178178}
  • kernel/test/mm/slab2.c

    r3061bc1 ra35b458  
    4848        slab_cache_t *cache2;
    4949        int i;
    50        
     50
    5151        void *data1, *data2;
    5252        void *olddata1 = NULL, *olddata2 = NULL;
    53        
     53
    5454        cache1 = slab_cache_create("test_cache1", ITEM_SIZE, 0, NULL, NULL, 0);
    5555        cache2 = slab_cache_create("test_cache2", ITEM_SIZE, 0, NULL, NULL, 0);
    56        
     56
    5757        TPRINTF("Allocating...");
    58        
     58
    5959        /* Use atomic alloc, so that we find end of memory */
    6060        do {
     
    7575                olddata2 = data2;
    7676        } while (true);
    77        
     77
    7878        TPRINTF("done.\n");
    79        
     79
    8080        TPRINTF("Deallocating cache2...");
    81        
     81
    8282        /* We do not have memory - now deallocate cache2 */
    8383        while (olddata2) {
     
    8686                olddata2 = data2;
    8787        }
    88        
     88
    8989        TPRINTF("done.\n");
    90        
     90
    9191        TPRINTF("Allocating to cache1...\n");
    92        
     92
    9393        for (i = 0; i < 30; i++) {
    9494                data1 = slab_alloc(cache1, FRAME_ATOMIC);
     
    109109                olddata1 = data1;
    110110        }
    111        
     111
    112112        TPRINTF("Deallocating cache1...");
    113        
     113
    114114        while (olddata1) {
    115115                data1 = *((void **) olddata1);
     
    117117                olddata1 = data1;
    118118        }
    119        
     119
    120120        TPRINTF("done.\n");
    121        
     121
    122122        if (!test_quiet)
    123123                slab_print_list();
    124        
     124
    125125        slab_cache_destroy(cache1);
    126126        slab_cache_destroy(cache2);
     
    137137{
    138138        void *data = NULL, *new;
    139        
     139
    140140        thread_detach(THREAD);
    141        
     141
    142142        mutex_lock(&starter_mutex);
    143143        condvar_wait(&thread_starter,&starter_mutex);
    144144        mutex_unlock(&starter_mutex);
    145        
     145
    146146        TPRINTF("Starting thread #%" PRIu64 "...\n", THREAD->tid);
    147147
    148148        /* Alloc all */
    149149        TPRINTF("Thread #%" PRIu64 " allocating...\n", THREAD->tid);
    150        
     150
    151151        while (true) {
    152152                /* Call with atomic to detect end of memory */
     
    157157                data = new;
    158158        }
    159        
     159
    160160        TPRINTF("Thread #%" PRIu64 " releasing...\n", THREAD->tid);
    161        
     161
    162162        while (data) {
    163163                new = *((void **)data);
     
    166166                data = new;
    167167        }
    168        
     168
    169169        TPRINTF("Thread #%" PRIu64 " allocating...\n", THREAD->tid);
    170        
     170
    171171        while (true) {
    172172                /* Call with atomic to detect end of memory */
     
    177177                data = new;
    178178        }
    179        
     179
    180180        TPRINTF("Thread #%" PRIu64 " releasing...\n", THREAD->tid);
    181        
     181
    182182        while (data) {
    183183                new = *((void **)data);
     
    186186                data = new;
    187187        }
    188        
     188
    189189        TPRINTF("Thread #%" PRIu64 " finished\n", THREAD->tid);
    190        
     190
    191191        if (!test_quiet)
    192192                slab_print_list();
    193        
     193
    194194        semaphore_up(&thr_sem);
    195195}
     
    202202        thread_t *t;
    203203        int i;
    204        
     204
    205205        TPRINTF("Running stress test with size %d\n", size);
    206        
     206
    207207        condvar_initialize(&thread_starter);
    208208        mutex_initialize(&starter_mutex, MUTEX_PASSIVE);
    209        
     209
    210210        thr_cache = slab_cache_create("thread_cache", size, 0, NULL, NULL, 0);
    211211        semaphore_initialize(&thr_sem,0);
     
    218218        thread_sleep(1);
    219219        condvar_broadcast(&thread_starter);
    220        
     220
    221221        for (i = 0; i < THREADS; i++)
    222222                semaphore_down(&thr_sem);
    223        
     223
    224224        slab_cache_destroy(thr_cache);
    225225        TPRINTF("Stress test complete.\n");
     
    230230        TPRINTF("Running reclaim single-thread test .. pass 1\n");
    231231        totalmemtest();
    232        
     232
    233233        TPRINTF("Running reclaim single-thread test .. pass 2\n");
    234234        totalmemtest();
    235        
     235
    236236        TPRINTF("Reclaim test OK.\n");
    237        
     237
    238238        multitest(128);
    239239        multitest(2048);
    240240        multitest(8192);
    241        
     241
    242242        return NULL;
    243243}
  • kernel/test/print/print1.c

    r3061bc1 ra35b458  
    3636        TPRINTF("Expected output: \"  tex\"\n");
    3737        TPRINTF("Real output:     \"%*.*s\"\n\n", 5, 3, "text");
    38        
     38
    3939        TPRINTF("Testing printf(\"%%10.8s\", \"very long text\"):\n");
    4040        TPRINTF("Expected output: \"  very lon\"\n");
    4141        TPRINTF("Real output:     \"%10.8s\"\n\n", "very long text");
    42        
     42
    4343        TPRINTF("Testing printf(\"%%8.10s\", \"text\"):\n");
    4444        TPRINTF("Expected output: \"    text\"\n");
    4545        TPRINTF("Real output:     \"%8.10s\"\n\n", "text");
    46        
     46
    4747        TPRINTF("Testing printf(\"%%8.10s\", \"very long text\"):\n");
    4848        TPRINTF("Expected output: \"very long \"\n");
    4949        TPRINTF("Real output:     \"%8.10s\"\n\n", "very long text");
    50        
     50
    5151        TPRINTF("Testing printf(\"%%-*.*s\", 7, 7, \"text\"):\n");
    5252        TPRINTF("Expected output: \"text   \"\n");
    5353        TPRINTF("Real output:     \"%-*.*s\"\n\n", 7, 7, "text");
    54        
     54
    5555        return NULL;
    5656}
  • kernel/test/print/print2.c

    r3061bc1 ra35b458  
    3636        TPRINTF("Expected output: [a]\n");
    3737        TPRINTF("Real output:     [%c]\n\n", 'a');
    38        
     38
    3939        TPRINTF("Testing printf(\"%%d %%3.2d %%-3.2d %%2.3d %%-2.3d\", 1, 2, 3, 4, 5):\n");
    4040        TPRINTF("Expected output: [1] [ 02] [03 ] [004] [005]\n");
    4141        TPRINTF("Real output:     [%d] [%3.2d] [%-3.2d] [%2.3d] [%-2.3d]\n\n", 1, 2, 3, 4, 5);
    42        
     42
    4343        TPRINTF("Testing printf(\"%%d %%3.2d %%-3.2d %%2.3d %%-2.3d\", -1, -2, -3, -4, -5):\n");
    4444        TPRINTF("Expected output: [-1] [-02] [-03] [-004] [-005]\n");
    4545        TPRINTF("Real output:     [%d] [%3.2d] [%-3.2d] [%2.3d] [%-2.3d]\n\n", -1, -2, -3, -4, -5);
    46        
     46
    4747        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");
    4848        TPRINTF("Expected output: [-1] [-02] [-03] [-004] [-005]\n");
    4949        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
    5151        TPRINTF("Testing printf(\"%%#x %%5.3#x %%-5.3#x %%3.5#x %%-3.5#x\", 17, 18, 19, 20, 21):\n");
    5252        TPRINTF("Expected output: [0x11] [0x012] [0x013] [0x00014] [0x00015]\n");
    5353        TPRINTF("Real output:     [%#x] [%#5.3x] [%#-5.3x] [%#3.5x] [%#-3.5x]\n\n", 17, 18, 19, 20, 21);
    54        
     54
    5555        char ch[12];
    5656        ptrdiff_t d, neg_d;
    57        
     57
    5858        d = &ch[0] - &ch[12];
    5959        neg_d = (unsigned)(-d);
     
    6161        TPRINTF("Expected output: [-12] [12] [c] [-12] [14]\n");
    6262        TPRINTF("Real output:     [%td] [%tu] [%tx] [%ti] [%to]\n\n", d, neg_d, neg_d, d, neg_d);
    63        
     63
    6464        sysarg_t nat = 0x12345678;
    65        
     65
    6666        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");
    6767        TPRINTF("Expected output: [0x1234567887654321] [0x12345678] [0x1234] [0x12] [0x12345678] [0x1234567887654321] \"Lovely string\"\n");
    6868        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
    7070        return NULL;
    7171}
  • kernel/test/print/print3.c

    r3061bc1 ra35b458  
    3838        char buffer[BUFFER_SIZE];
    3939        int retval;
    40        
     40
    4141        TPRINTF("Testing snprintf(buffer, " STRING(BUFFER_SIZE) ", \"Short text without parameters.\"):\n");
    4242        TPRINTF("Expected result: retval=30 buffer=\"Short text without parameters.\"\n");
    4343        retval = snprintf(buffer, BUFFER_SIZE, "Short text without parameters.");
    4444        TPRINTF("Real result:     retval=%d buffer=\"%s\"\n\n", retval, buffer);
    45        
     45
    4646        TPRINTF("Testing snprintf(buffer, " STRING(BUFFER_SIZE) ", \"Very very very long text without parameters.\"):\n");
    4747        TPRINTF("Expected result: retval=44 buffer=\"Very very very long text withou\"\n");
    4848        retval = snprintf(buffer, BUFFER_SIZE, "Very very very long text without parameters.");
    4949        TPRINTF("Real result:     retval=%d buffer=\"%s\"\n\n", retval, buffer);
    50        
     50
    5151        TPRINTF("Testing snprintf(buffer, " STRING(BUFFER_SIZE) ", \"Short %%s.\", \"text\"):\n");
    5252        TPRINTF("Expected result: retval=11 buffer=\"Short text.\"\n");
    5353        retval = snprintf(buffer, BUFFER_SIZE, "Short %s.", "text");
    5454        TPRINTF("Real result:     retval=%d buffer=\"%s\"\n\n", retval, buffer);
    55        
     55
    5656        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");
    5757        TPRINTF("Expected result: retval=84 buffer=\"Very long text. This text's len\"\n");
    5858        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);
    5959        TPRINTF("Real result:     retval=%d buffer=\"%s\"\n\n", retval, buffer);
    60        
     60
    6161        return NULL;
    6262}
  • kernel/test/print/print4.c

    r3061bc1 ra35b458  
    3434{
    3535        TPRINTF("ASCII printable characters (32 - 127) using printf(\"%%c\") and printf(\"%%lc\"):\n");
    36        
     36
    3737        uint8_t group;
    3838        for (group = 1; group < 4; group++) {
    3939                TPRINTF("%#x: ", group << 5);
    40                
     40
    4141                uint8_t index;
    4242                for (index = 0; index < 32; index++)
    4343                        TPRINTF("%c", (char) ((group << 5) + index));
    44                
     44
    4545                TPRINTF("  ");
    4646                for (index = 0; index < 32; index++)
    4747                        TPRINTF("%lc", (wint_t) ((group << 5) + index));
    48                
     48
    4949                TPRINTF("\n");
    5050        }
    51        
     51
    5252        TPRINTF("\nExtended ASCII characters (128 - 255) using printf(\"%%lc\"):\n");
    53        
     53
    5454        for (group = 4; group < 8; group++) {
    5555                TPRINTF("%#x: ", group << 5);
    56                
     56
    5757                uint8_t index;
    5858                for (index = 0; index < 32; index++)
    5959                        TPRINTF("%lc", (wint_t) ((group << 5) + index));
    60                
     60
    6161                TPRINTF("\n");
    6262        }
    63        
     63
    6464        TPRINTF("\nUTF-8 strings using printf(\"%%s\"):\n");
    6565        TPRINTF("English:  %s\n", "Quick brown fox jumps over the lazy dog");
     
    7070        TPRINTF("Russian:  %s\n", "Леннон познакомился с художницей-авангардисткой");
    7171        TPRINTF("Armenian: %s\n", "Սկսեց հրատարակվել Երուսաղեմի հայկական");
    72        
     72
    7373        TPRINTF("\nUTF-32 strings using printf(\"%%ls\"):\n");
    7474        TPRINTF("English:  %ls\n", L"Quick brown fox jumps over the lazy dog");
     
    7979        TPRINTF("Russian:  %ls\n", L"Леннон познакомился с художницей-авангардисткой");
    8080        TPRINTF("Armenian: %ls\n", L"Սկսեց հրատարակվել Երուսաղեմի հայկական");
    81        
     81
    8282        return NULL;
    8383}
  • kernel/test/print/print5.c

    r3061bc1 ra35b458  
    4848        TPRINTF("Expected output: \"(NULL)\"\n");
    4949        TPRINTF("Real output:     \"%s\"\n\n", (char *) NULL);
    50        
     50
    5151        TPRINTF("Testing printf(\"%%c %%3.2c %%-3.2c %%2.3c %%-2.3c\", 'a', 'b', 'c', 'd', 'e'):\n");
    5252        TPRINTF("Expected output: [a] [  b] [c  ] [ d] [e ]\n");
    5353        TPRINTF("Real output:     [%c] [%3.2c] [%-3.2c] [%2.3c] [%-2.3c]\n\n", 'a', 'b', 'c', 'd', 'e');
    54        
     54
    5555        return NULL;
    5656}
  • kernel/test/smpcall/smpcall1.c

    r3061bc1 ra35b458  
    6666        size_t *pcall_cnt = (size_t*)p;
    6767        smp_call_t call_info[MAX_CPUS];
    68        
     68
    6969        unsigned int cpu_count = min(config.cpu_active, MAX_CPUS);
    70        
     70
    7171        for (int iter = 0; iter < ITERATIONS; ++iter) {
    7272                /* Synchronous version. */
     
    7979                        smp_call(cpu_id, inc, pcall_cnt);
    8080                }
    81                
     81
    8282                /*
    8383                 * Async calls run in parallel on different cpus, so passing the
     
    8585                 */
    8686                size_t local_cnt[MAX_CPUS] = {0};
    87                
     87
    8888                /* Now start asynchronous calls. */
    8989                for (unsigned cpu_id = 0; cpu_id < cpu_count; ++cpu_id) {
    9090                        smp_call_async(cpu_id, inc, &local_cnt[cpu_id], &call_info[cpu_id]);
    9191                }
    92                
     92
    9393                /* And wait for all async calls to complete. */
    9494                for (unsigned cpu_id = 0; cpu_id < cpu_count; ++cpu_id) {
     
    112112        size_t call_cnt[MAX_CPUS] = {0};
    113113        thread_t *thread[MAX_CPUS] = { NULL };
    114        
     114
    115115        unsigned int cpu_count = min(config.cpu_active, MAX_CPUS);
    116116        size_t running_thread_cnt = 0;
    117117
    118118        TPRINTF("Spawning threads on %u cpus.\n", cpu_count);
    119        
     119
    120120        /* Create a wired thread on each cpu. */
    121121        for (unsigned int id = 0; id < cpu_count; ++id) {
    122122                thread[id] = thread_create(test_thread, &call_cnt[id], TASK,
    123123                        THREAD_FLAG_NONE, "smp-call-test");
    124                
     124
    125125                if (thread[id]) {
    126126                        thread_wire(thread[id], &cpus[id]);
     
    133133        size_t exp_calls = calc_exp_calls(running_thread_cnt);
    134134        size_t exp_calls_sum = exp_calls * cpu_count;
    135        
     135
    136136        TPRINTF("Running %zu wired threads. Expecting %zu calls. Be patient.\n",
    137137                running_thread_cnt, exp_calls_sum);
     
    142142                }
    143143        }
    144        
     144
    145145        /* Wait for threads to complete. */
    146146        for (unsigned int i = 0; i < cpu_count; ++i) {
     
    152152
    153153        TPRINTF("Threads finished. Checking number of smp_call()s.\n");
    154        
     154
    155155        bool ok = true;
    156156        size_t calls_sum = 0;
    157        
     157
    158158        for (size_t i = 0; i < cpu_count; ++i) {
    159159                if (thread[i] != NULL) {
     
    164164                        }
    165165                }
    166                
     166
    167167                calls_sum += call_cnt[i];
    168168        }
    169        
     169
    170170        if (calls_sum != exp_calls_sum) {
    171171                TPRINTF("Error: total acknowledged sum: %zu instead of %zu.\n",
    172172                        calls_sum, exp_calls_sum);
    173                
     173
    174174                ok = false;
    175175        }
    176        
     176
    177177        if (ok) {
    178178                TPRINTF("Success: number of received smp_calls is as expected (%zu).\n",
     
    181181        } else
    182182                return "Failed: incorrect acknowledged smp_calls.\n";
    183        
     183
    184184}
  • kernel/test/synch/rcu1.c

    r3061bc1 ra35b458  
    6767                TPRINTF(".");
    6868        }
    69        
     69
    7070        if (!p->exited) {
    7171                *presult = ETIMEOUT;
     
    8181{
    8282        assert(thread[k] == NULL);
    83        
     83
    8484        thread[k] = thread_create(func, arg, TASK, THREAD_FLAG_NONE,
    8585                "test-rcu-thread");
    86                
     86
    8787        if(thread[k]) {
    8888                /* Distribute evenly. */
     
    9595{
    9696        size_t thread_cnt = get_thread_cnt();
    97        
     97
    9898        one_idx = 0;
    99        
     99
    100100        for (size_t i = 0; i < thread_cnt; ++i) {
    101101                run_thread(i, func, NULL);
     
    106106{
    107107        size_t thread_cnt = get_thread_cnt();
    108        
     108
    109109        one_idx = 0;
    110        
     110
    111111        for (size_t i = 0; i < thread_cnt; ++i) {
    112112                if (thread[i]) {
     
    115115                                errno_t ret = thread_join_timeout(thread[i], 5 * 1000 * 1000, 0);
    116116                                joined = (ret != ETIMEOUT);
    117                                
     117
    118118                                if (ret == EOK) {
    119119                                        TPRINTF("%zu threads remain\n", thread_cnt - i - 1);
    120120                                }
    121121                        } while (!joined);
    122                        
     122
    123123                        thread_detach(thread[i]);
    124124                        thread[i] = NULL;
     
    140140
    141141        --one_idx;
    142        
     142
    143143        if (thread[one_idx]) {
    144144                thread_join(thread[one_idx]);
     
    154154{
    155155        size_t nop_iters = (size_t)arg;
    156        
     156
    157157        TPRINTF("Enter nop-reader\n");
    158        
     158
    159159        for (size_t i = 0; i < nop_iters; ++i) {
    160160                rcu_read_lock();
    161161                rcu_read_unlock();
    162162        }
    163        
     163
    164164        TPRINTF("Exit nop-reader\n");
    165165}
     
    169169        assert(0 < steps && from <= to && 0 < to);
    170170        size_t inc = (to - from) / (steps - 1);
    171        
     171
    172172        for (size_t i = 0; i < steps - 1; ++i) {
    173173                seq[i] = i * inc + from;
    174174        }
    175        
     175
    176176        seq[steps - 1] = to;
    177177}
     
    181181        size_t seq[MAX_THREADS] = {0};
    182182        get_seq(100, 100000, get_thread_cnt(), seq);
    183        
     183
    184184        TPRINTF("\nRun %zu thr: repeat empty no-op reader sections\n", get_thread_cnt());
    185        
     185
    186186        for (size_t k = 0; k < get_thread_cnt(); ++k)
    187187                run_one(nop_reader, (void*)seq[k]);
    188        
     188
    189189        TPRINTF("\nJoining %zu no-op readers\n", get_thread_cnt());
    190190        join_all();
    191        
     191
    192192        return true;
    193193}
     
    202202        size_t nop_iters = (size_t)arg;
    203203        size_t outer_iters = iter_cnt / nop_iters;
    204        
     204
    205205        TPRINTF("Enter long-reader\n");
    206        
     206
    207207        for (size_t i = 0; i < outer_iters; ++i) {
    208208                rcu_read_lock();
    209                
     209
    210210                for (volatile size_t k = 0; k < nop_iters; ++k) {
    211211                        /* nop, but increment volatile k */
    212212                }
    213                
     213
    214214                rcu_read_unlock();
    215215        }
    216        
     216
    217217        TPRINTF("Exit long-reader\n");
    218218}
     
    222222        size_t seq[MAX_THREADS] = {0};
    223223        get_seq(10, 1000 * 1000, get_thread_cnt(), seq);
    224        
     224
    225225        TPRINTF("\nRun %zu thr: repeat long reader sections, will preempt, no cbs.\n",
    226226                get_thread_cnt());
    227        
     227
    228228        for (size_t k = 0; k < get_thread_cnt(); ++k)
    229229                run_one(long_reader, (void*)seq[k]);
    230        
     230
    231231        TPRINTF("\nJoining %zu readers with long reader sections.\n", get_thread_cnt());
    232232        join_all();
    233        
     233
    234234        return true;
    235235}
     
    253253                rcu_item_t *a = malloc(sizeof(rcu_item_t), FRAME_ATOMIC);
    254254                rcu_item_t *b = malloc(sizeof(rcu_item_t), FRAME_ATOMIC);
    255                
     255
    256256                if (a && b) {
    257257                        rcu_call(a, count_cb);
     
    272272        size_t exp_cnt = nop_updater_iters * get_thread_cnt();
    273273        size_t max_used_mem = sizeof(rcu_item_t) * exp_cnt;
    274        
     274
    275275        TPRINTF("\nRun %zu thr: post %zu no-op callbacks (%zu B used), no readers.\n",
    276276                get_thread_cnt(), exp_cnt, max_used_mem);
    277        
     277
    278278        run_all(nop_updater);
    279279        TPRINTF("\nJoining %zu no-op callback threads\n", get_thread_cnt());
    280280        join_all();
    281        
     281
    282282        size_t loop_cnt = 0, max_loops = 15;
    283283
     
    287287                thread_sleep(1);
    288288        }
    289        
     289
    290290        return loop_cnt < max_loops;
    291291}
     
    312312{
    313313        TPRINTF("Enter one-cb-reader\n");
    314        
    315         rcu_read_lock();
    316        
     314
     315        rcu_read_lock();
     316
    317317        item_w_cookie_t *item = malloc(sizeof(item_w_cookie_t), FRAME_ATOMIC);
    318        
     318
    319319        if (item) {
    320320                item->cookie = magic_cookie;
     
    323323                TPRINTF("\n[out-of-mem]\n");
    324324        }
    325        
     325
    326326        thread_sleep(1);
    327        
     327
    328328        rcu_read_unlock();
    329        
     329
    330330        TPRINTF("Exit one-cb-reader\n");
    331331}
     
    334334{
    335335        one_cb_is_done = 0;
    336        
     336
    337337        TPRINTF("\nRun a single reader that posts one callback.\n");
    338338        run_one(one_cb_reader, NULL);
    339339        join_one();
    340        
     340
    341341        TPRINTF("\nJoined one-cb reader, wait for callback.\n");
    342342        size_t loop_cnt = 0;
    343343        size_t max_loops = 4; /* 200 ms total */
    344        
     344
    345345        while (!one_cb_is_done && loop_cnt < max_loops) {
    346346                thread_usleep(50 * 1000);
    347347                ++loop_cnt;
    348348        }
    349        
     349
    350350        return one_cb_is_done;
    351351}
     
    373373{
    374374        seq_item_t *item = member_to_inst(rcu_item, seq_item_t, rcu);
    375        
     375
    376376        /* Racy but errs to the conservative side, so it is ok. */
    377377        if (max_upd_done_time < item->start_time) {
    378378                max_upd_done_time = item->start_time;
    379                
     379
    380380                /* Make updated time visible */
    381381                memory_barrier();
     
    393393#ifndef KARCH_riscv64
    394394        seq_work_t *work = (seq_work_t*)arg;
    395        
     395
    396396        /* Alternate between reader and updater roles. */
    397397        for (size_t k = 0; k < work->iters; ++k) {
     
    400400                        rcu_read_lock();
    401401                        atomic_count_t start_time = atomic_postinc(&cur_time);
    402                        
     402
    403403                        for (volatile size_t d = 0; d < 10 * i; ++d ){
    404404                                /* no-op */
    405405                        }
    406                        
     406
    407407                        /* Get most recent max_upd_done_time. */
    408408                        memory_barrier();
    409                        
     409
    410410                        if (start_time < max_upd_done_time) {
    411411                                seq_test_result = ERACE;
    412412                        }
    413                        
     413
    414414                        rcu_read_unlock();
    415                        
     415
    416416                        if (seq_test_result != EOK)
    417417                                return;
    418418                }
    419                
     419
    420420                /* Updater */
    421421                for (size_t i = 0; i < work->update_cnt; ++i) {
    422422                        seq_item_t *a = malloc(sizeof(seq_item_t), FRAME_ATOMIC);
    423423                        seq_item_t *b = malloc(sizeof(seq_item_t), FRAME_ATOMIC);
    424                        
     424
    425425                        if (a && b) {
    426426                                a->start_time = atomic_postinc(&cur_time);
    427427                                rcu_call(&a->rcu, seq_cb);
    428                                
     428
    429429                                b->start_time = atomic_postinc(&cur_time);
    430430                                rcu_call(&b->rcu, seq_cb);
     
    437437                        }
    438438                }
    439                
     439
    440440        }
    441441#else
     
    454454        size_t read_cnt[MAX_THREADS] = {0};
    455455        seq_work_t item[MAX_THREADS];
    456        
     456
    457457        size_t total_cbs = 0;
    458458        size_t max_used_mem = 0;
    459        
     459
    460460        get_seq(0, total_cnt, get_thread_cnt(), read_cnt);
    461        
     461
    462462
    463463        for (size_t i = 0; i < get_thread_cnt(); ++i) {
     
    465465                item[i].read_cnt = read_cnt[i];
    466466                item[i].iters = iters;
    467                
     467
    468468                total_cbs += 2 * iters * item[i].update_cnt;
    469469        }
    470        
     470
    471471        max_used_mem = total_cbs * sizeof(seq_item_t);
    472472
     
    474474        uint64_t mem_units;
    475475        bin_order_suffix(max_used_mem, &mem_units, &mem_suffix, false);
    476        
     476
    477477        TPRINTF("\nRun %zu th: check callback completion time in readers. "
    478478                "%zu callbacks total (max %" PRIu64 " %s used). Be patient.\n",
    479479                get_thread_cnt(), total_cbs, mem_units, mem_suffix);
    480        
     480
    481481        for (size_t i = 0; i < get_thread_cnt(); ++i) {
    482482                run_one(seq_func, &item[i]);
    483483        }
    484        
     484
    485485        TPRINTF("\nJoining %zu seq-threads\n", get_thread_cnt());
    486486        join_all();
    487        
     487
    488488        if (seq_test_result == ENOMEM) {
    489489                TPRINTF("\nErr: out-of mem\n");
     
    491491                TPRINTF("\nERROR: race detected!!\n");
    492492        }
    493        
     493
    494494        return seq_test_result == EOK;
    495495}
     
    510510        rcu_read_lock();
    511511        rcu_read_unlock();
    512        
     512
    513513        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
    518518        /* Exit without unlocking the rcu reader section. */
    519519}
     
    522522{
    523523        TPRINTF("\nReader exits thread with rcu_lock\n");
    524        
     524
    525525        exited_t *p = malloc(sizeof(exited_t), FRAME_ATOMIC);
    526526        if (!p) {
     
    528528                return false;
    529529        }
    530                
     530
    531531        p->exited = false;
    532        
     532
    533533        run_one(reader_exit, p);
    534534        join_one();
    535        
     535
    536536        errno_t result = EOK;
    537537        wait_for_cb_exit(2 /* secs */, p, &result);
    538        
     538
    539539        if (result != EOK) {
    540540                TPRINTF("Err: RCU locked up after exiting from within a reader\n");
     
    543543                free(p);
    544544        }
    545        
     545
    546546        return result == EOK;
    547547}
     
    570570
    571571        TPRINTF("reader_prev{ ");
    572        
     572
    573573        rcu_read_lock();
    574574        scheduler();
     
    588588        preempt_t *p = (preempt_t*)arg;
    589589        assert(!p->e.exited);
    590        
     590
    591591        TPRINTF("reader_inside_cur{ ");
    592592        /*
     
    613613        preempt_t *p = (preempt_t*)arg;
    614614        assert(!p->e.exited);
    615        
     615
    616616        TPRINTF("reader_cur{ ");
    617617        rcu_read_lock();
     
    622622        /* Preempt while cur GP detection is running */
    623623        thread_sleep(1);
    624        
     624
    625625        /* Err: exited before this reader completed. */
    626626        if (p->e.exited)
     
    635635        preempt_t *p = (preempt_t*)arg;
    636636        assert(!p->e.exited);
    637        
     637
    638638        TPRINTF("reader_next1{ ");
    639639        rcu_read_lock();
     
    641641        /* Preempt before cur GP detection starts. */
    642642        scheduler();
    643        
     643
    644644        /* Start GP. */
    645645        rcu_call(&p->e.rcu, preempted_unlocked);
     
    657657        preempt_t *p = (preempt_t*)arg;
    658658        assert(!p->e.exited);
    659        
     659
    660660        TPRINTF("reader_next2{ ");
    661661        rcu_read_lock();
     
    663663        /* Preempt before cur GP detection starts. */
    664664        scheduler();
    665        
     665
    666666        /* Start GP. */
    667667        rcu_call(&p->e.rcu, preempted_unlocked);
     
    691691                return false;
    692692        }
    693        
     693
    694694        p->e.exited = false;
    695695        p->result = EOK;
    696        
     696
    697697        run_one(f, p);
    698698        join_one();
    699        
     699
    700700        /* Wait at most 4 secs. */
    701701        wait_for_cb_exit(4, &p->e, &p->result);
    702        
     702
    703703        if (p->result == EOK) {
    704704                free(p);
     
    714714{
    715715        TPRINTF("\nReaders will be preempted.\n");
    716        
     716
    717717        bool success = true;
    718718        bool ok = true;
    719        
     719
    720720        ok = do_one_reader_preempt(preempted_reader_prev,
    721721                "Err: preempted_reader_prev()\n");
    722722        success = success && ok;
    723        
     723
    724724        ok = do_one_reader_preempt(preempted_reader_inside_cur,
    725725                "Err: preempted_reader_inside_cur()\n");
    726726        success = success && ok;
    727        
     727
    728728        ok = do_one_reader_preempt(preempted_reader_cur,
    729729                "Err: preempted_reader_cur()\n");
    730730        success = success && ok;
    731        
     731
    732732        ok = do_one_reader_preempt(preempted_reader_next1,
    733733                "Err: preempted_reader_next1()\n");
     
    737737                "Err: preempted_reader_next2()\n");
    738738        success = success && ok;
    739        
     739
    740740        return success;
    741741}
     
    751751{
    752752        synch_t *synch = (synch_t *) arg;
    753        
     753
    754754        rcu_read_lock();
    755755
    756756        /* Order accesses of synch after the reader section begins. */
    757757        memory_barrier();
    758        
     758
    759759        synch->reader_running = true;
    760        
     760
    761761        while (!synch->synch_running) {
    762762                /* 0.5 sec */
    763763                delay(500 * 1000);
    764764        }
    765        
     765
    766766        /* Run for 1 sec */
    767767        delay(1000 * 1000);
    768768        /* thread_join() propagates done to do_synch() */
    769769        synch->reader_done = true;
    770        
     770
    771771        rcu_read_unlock();
    772772}
     
    776776{
    777777        TPRINTF("\nSynchronize with long reader\n");
    778        
     778
    779779        synch_t *synch = malloc(sizeof(synch_t), FRAME_ATOMIC);
    780        
     780
    781781        if (!synch) {
    782782                TPRINTF("[out-of-mem]\n");
    783783                return false;
    784784        }
    785        
     785
    786786        synch->reader_done = false;
    787787        synch->reader_running = false;
    788788        synch->synch_running = false;
    789        
     789
    790790        run_one(synch_reader, synch);
    791        
     791
    792792        /* Wait for the reader to enter its critical section. */
    793793        scheduler();
     
    795795                thread_usleep(500 * 1000);
    796796        }
    797        
     797
    798798        synch->synch_running = true;
    799        
     799
    800800        rcu_synchronize();
    801801        join_one();
    802        
    803        
     802
     803
    804804        if (synch->reader_done) {
    805805                free(synch);
     
    827827{
    828828        TPRINTF("\nrcu_barrier: Wait for outstanding rcu callbacks to complete\n");
    829        
     829
    830830        barrier_t *barrier = malloc(sizeof(barrier_t), FRAME_ATOMIC);
    831        
     831
    832832        if (!barrier) {
    833833                TPRINTF("[out-of-mem]\n");
    834834                return false;
    835835        }
    836        
     836
    837837        atomic_set(&barrier->done, 0);
    838        
     838
    839839        rcu_call(&barrier->rcu_item, barrier_callback);
    840840        rcu_barrier();
    841        
     841
    842842        if (1 == atomic_get(&barrier->done)) {
    843843                free(barrier);
     
    861861{
    862862        bool *done = (bool*) arg;
    863        
     863
    864864        while (!*done) {
    865865                rcu_read_lock();
    866866                rcu_read_unlock();
    867                
     867
    868868                /*
    869869                 * Do some work outside of the reader section so we are not always
     
    884884{
    885885        stress_t *s = (stress_t *)arg;
    886        
     886
    887887        for (size_t i = 0; i < s->iters; ++i) {
    888888                rcu_item_t *item = malloc(sizeof(rcu_item_t), FRAME_ATOMIC);
    889                
     889
    890890                if (item) {
    891891                        rcu_call(item, stress_cb);
     
    894894                        return;
    895895                }
    896                
     896
    897897                /* Print a dot if we make a progress of 1% */
    898898                if (s->master && 0 == (i % (s->iters/100)))
     
    907907        stress_t master = { .iters = cb_per_thread, .master = true };
    908908        stress_t worker = { .iters = cb_per_thread, .master = false };
    909        
     909
    910910        size_t thread_cnt = min(MAX_THREADS / 2, config.cpu_active);
    911911        /* Each cpu has one reader and one updater. */
    912912        size_t reader_cnt = thread_cnt;
    913913        size_t updater_cnt = thread_cnt;
    914        
     914
    915915        size_t exp_upd_calls = updater_cnt * cb_per_thread;
    916916        size_t max_used_mem = exp_upd_calls * sizeof(rcu_item_t);
    917        
     917
    918918        const char *mem_suffix;
    919919        uint64_t mem_units;
     
    923923                " total (max %" PRIu64 " %s used). Be very patient.\n",
    924924                reader_cnt, updater_cnt, exp_upd_calls, mem_units, mem_suffix);
    925        
     925
    926926        for (size_t k = 0; k < reader_cnt; ++k) {
    927927                run_one(stress_reader, &done);
     
    931931                run_one(stress_updater, k > 0 ? &worker : &master);
    932932        }
    933        
     933
    934934        TPRINTF("\nJoining %zu stress updaters.\n", updater_cnt);
    935        
     935
    936936        for (size_t k = 0; k < updater_cnt; ++k) {
    937937                join_one();
    938938        }
    939        
     939
    940940        done = true;
    941941
    942942        TPRINTF("\nJoining %zu stress nop-readers.\n", reader_cnt);
    943        
     943
    944944        join_all();
    945945        return true;
     
    957957{
    958958        expedite_t *e = (expedite_t *)arg;
    959        
     959
    960960        if (1 < e->count_down) {
    961961                --e->count_down;
    962                
     962
    963963                if (0 == (e->count_down % (e->total_cnt/100))) {
    964964                        TPRINTF("*");
    965965                }
    966                
     966
    967967                _rcu_call(e->expedite, &e->r, expedite_cb);
    968968        } else {
     
    979979        e.count_down = cnt;
    980980        e.expedite = exp;
    981        
     981
    982982        _rcu_call(e.expedite, &e.r, expedite_cb);
    983        
     983
    984984        while (0 < e.count_down) {
    985985                thread_sleep(1);
     
    992992        size_t exp_cnt = 1000 * 1000;
    993993        size_t normal_cnt = 1 * 1000;
    994        
     994
    995995        TPRINTF("Expedited: sequence of %zu rcu_calls\n", exp_cnt);
    996996        run_expedite(true, exp_cnt);
     
    10241024                { 0, NULL, NULL }
    10251025        };
    1026        
     1026
    10271027        bool success = true;
    10281028        bool ok = true;
    10291029        uint64_t completed_gps = rcu_completed_gps();
    10301030        uint64_t delta_gps = 0;
    1031        
     1031
    10321032        for (int i = 0; test_func[i].func; ++i) {
    10331033                if (!test_func[i].include) {
     
    10371037                        TPRINTF("\nRunning subtest %s.\n", test_func[i].desc);
    10381038                }
    1039                
     1039
    10401040                ok = test_func[i].func();
    10411041                success = success && ok;
    1042                
     1042
    10431043                delta_gps = rcu_completed_gps() - completed_gps;
    10441044                completed_gps += delta_gps;
  • kernel/test/synch/semaphore1.c

    r3061bc1 ra35b458  
    4949{
    5050        thread_detach(THREAD);
    51        
     51
    5252        waitq_sleep(&can_start);
    53        
     53
    5454        semaphore_down(&sem);
    5555        atomic_inc(&items_produced);
     
    6161{
    6262        thread_detach(THREAD);
    63        
     63
    6464        waitq_sleep(&can_start);
    65        
     65
    6666        semaphore_down(&sem);
    6767        atomic_inc(&items_consumed);
     
    7575        atomic_count_t consumers;
    7676        atomic_count_t producers;
    77        
     77
    7878        waitq_initialize(&can_start);
    7979        semaphore_initialize(&sem, AT_ONCE);
    80        
     80
    8181        for (i = 1; i <= 3; i++) {
    8282                thread_t *thrd;
    83                
     83
    8484                atomic_set(&items_produced, 0);
    8585                atomic_set(&items_consumed, 0);
    86                
     86
    8787                consumers = i * CONSUMERS;
    8888                producers = (4 - i) * PRODUCERS;
    89                
     89
    9090                TPRINTF("Creating %" PRIua " consumers and %" PRIua " producers...",
    9191                    consumers, producers);
    92                
     92
    9393                for (j = 0; j < (CONSUMERS + PRODUCERS) / 2; j++) {
    9494                        for (k = 0; k < i; k++) {
     
    109109                        }
    110110                }
    111                
     111
    112112                TPRINTF("ok\n");
    113                
     113
    114114                thread_sleep(1);
    115115                waitq_wakeup(&can_start, WAKEUP_ALL);
    116                
     116
    117117                while ((items_consumed.count != consumers) || (items_produced.count != producers)) {
    118118                        TPRINTF("%" PRIua " consumers remaining, %" PRIua " producers remaining\n",
     
    121121                }
    122122        }
    123        
     123
    124124        return NULL;
    125125}
  • kernel/test/synch/semaphore2.c

    r3061bc1 ra35b458  
    5050{
    5151        uint32_t rc;
    52        
     52
    5353        spinlock_lock(&sem_lock);
    5454        rc = seed % max;
     
    6262        errno_t rc;
    6363        int to;
    64        
     64
    6565        thread_detach(THREAD);
    66        
     66
    6767        waitq_sleep(&can_start);
    68        
     68
    6969        to = random(20000);
    7070        TPRINTF("cpu%u, tid %" PRIu64 " down+ (%d)\n", CPU->id, THREAD->tid, to);
     
    7474                return;
    7575        }
    76        
     76
    7777        TPRINTF("cpu%u, tid %" PRIu64 " down=\n", CPU->id, THREAD->tid);
    7878        thread_usleep(random(30000));
    79        
     79
    8080        semaphore_up(&sem);
    8181        TPRINTF("cpu%u, tid %" PRIu64 " up\n", CPU->id, THREAD->tid);
     
    8585{
    8686        uint32_t i, k;
    87        
     87
    8888        waitq_initialize(&can_start);
    8989        semaphore_initialize(&sem, 5);
    90        
     90
    9191        thread_t *thrd;
    92        
     92
    9393        k = random(7) + 1;
    9494        TPRINTF("Creating %" PRIu32 " consumers\n", k);
     
    101101                        TPRINTF("Error creating thread\n");
    102102        }
    103        
     103
    104104        thread_usleep(20000);
    105105        waitq_wakeup(&can_start, WAKEUP_ALL);
    106        
     106
    107107        return NULL;
    108108}
  • kernel/test/synch/workq-test-core.h

    r3061bc1 ra35b458  
    5454{
    5555        ++work->wave;
    56        
     56
    5757        if (work->wave < WAVES) {
    5858                work->count_down = COUNT;
     
    7979                child->count_down = work->count_down;
    8080        }
    81        
     81
    8282        return child;
    8383}
     
    9393        /* Ensure work_item is ours for the taking. */
    9494        memsetb(work_item, sizeof(work_t), 0xec);
    95        
     95
    9696        test_work_t *work = (test_work_t *)work_item;
    97        
     97
    9898        atomic_inc(&call_cnt[work->wave]);
    99        
     99
    100100        if (0 < work->count_down) {
    101101                /* Sleep right before creating the last generation. */
     
    108108                        }
    109109                }
    110                
     110
    111111                --work->count_down;
    112112
     
    122122                        }
    123123                }
    124                
     124
    125125                if (!core_workq_enqueue(work_item, reproduce)) {
    126126                        if (work->master)
     
    131131        } else {
    132132                /* We're done with this wave - only the master survives. */
    133                
     133
    134134                if (work->master && new_wave(work)) {
    135135                        if (!core_workq_enqueue(work_item, reproduce)) {
     
    140140                        if (work->master)
    141141                                TPRINTF("\nMaster work item done.\n");
    142                                
     142
    143143                        free_work(work);
    144144                }
     
    157157        work->wave = 0;
    158158        work->count_down = COUNT;
    159        
     159
    160160        /*
    161161         * k == COUNT_POW
     
    166166         */
    167167        size_t exp_call_cnt = (COUNT_POW + 2) * (1 << (COUNT_POW - 1));
    168        
     168
    169169        TPRINTF("waves: %d, count_down: %d, total expected calls: %zu\n",
    170170                WAVES, COUNT, exp_call_cnt * WAVES);
    171        
     171
    172172
    173173        core_workq_enqueue(&work->work_item, reproduce);
    174        
     174
    175175        size_t sleep_cnt = 0;
    176176        /* At least 40 seconds total (or 2 sec to end while there's work). */
    177177        size_t max_sleep_secs = end_prematurely ? 2 : MAIN_MAX_SLEEP_SEC;
    178178        size_t max_sleep_cnt = (max_sleep_secs * 1000) / MAIN_POLL_SLEEP_MS;
    179        
     179
    180180        for (int i = 0; i < WAVES; ++i) {
    181181                while (atomic_get(&call_cnt[i]) < exp_call_cnt
     
    186186                }
    187187        }
    188        
     188
    189189        bool success = true;
    190        
     190
    191191        for (int i = 0; i < WAVES; ++i) {
    192192                if (atomic_get(&call_cnt[i]) == exp_call_cnt) {
     
    199199                }
    200200        }
    201        
    202        
     201
     202
    203203        if (success)
    204204                return NULL;
  • kernel/test/synch/workqueue2.c

    r3061bc1 ra35b458  
    6363        basic_done = 0;
    6464        workq_global_enqueue(&basic_work, basic_test_work);
    65        
     65
    6666        while (!basic_done) {
    6767                TPRINTF(".");
     
    8787{
    8888        workq = workq_create(qname);
    89        
     89
    9090        if (!workq) {
    9191                return "Failed to create a work queue.\n";
    9292        }
    93        
     93
    9494        const char *ret = run_workq_core(stop);
    95        
     95
    9696        TPRINTF("Stopping work queue...\n");
    9797        workq_stop(workq);
    98        
     98
    9999        TPRINTF("Destroying work queue...\n");
    100100        workq_destroy(workq);
     
    123123        const char *err = NULL;
    124124        const char *res;
    125        
     125
    126126        basic_test();
    127        
     127
    128128        res = test_custom_workq();
    129129        if (res) {
     
    131131                err = res;
    132132        }
    133        
     133
    134134        res = test_custom_workq_stop();
    135135        if (res) {
     
    137137                err = res;
    138138        }
    139        
     139
    140140        res = test_workqueue3();
    141141        if (res) {
  • kernel/test/synch/workqueue3.c

    r3061bc1 ra35b458  
    6666
    6767        TPRINTF("Done.\n");
    68        
     68
    6969        return err;
    7070}
  • kernel/test/test.c

    r3061bc1 ra35b458  
    7575        size_t len = str_length(input);
    7676        test_t **test = (test_t **) ctx;
    77        
     77
    7878        if (*test == NULL)
    7979                *test = tests;
    80        
     80
    8181        for (; (*test)->name; (*test)++) {
    8282                const char *curname = (*test)->name;
    83                
     83
    8484                if (str_length(curname) < len)
    8585                        continue;
    86                
     86
    8787                if (str_lcmp(input, curname, len) == 0) {
    8888                        (*test)++;
     
    9292                }
    9393        }
    94        
     94
    9595        return NULL;
    9696}
  • kernel/test/thread/thread1.c

    r3061bc1 ra35b458  
    4545{
    4646        thread_detach(THREAD);
    47        
     47
    4848        while (atomic_get(&finish)) {
    4949                TPRINTF("%" PRIu64 " ", THREAD->tid);
     
    5757        unsigned int i;
    5858        atomic_count_t total = 0;
    59        
     59
    6060        atomic_set(&finish, 1);
    6161        atomic_set(&threads_finished, 0);
    62        
     62
    6363        for (i = 0; i < THREADS; i++) {
    6464                thread_t *t;
     
    7171                total++;
    7272        }
    73        
     73
    7474        TPRINTF("Running threads for 10 seconds...\n");
    7575        thread_sleep(10);
    76        
     76
    7777        atomic_set(&finish, 0);
    7878        while (atomic_get(&threads_finished) < total) {
     
    8080                thread_sleep(1);
    8181        }
    82        
     82
    8383        return NULL;
    8484}
Note: See TracChangeset for help on using the changeset viewer.