Changeset 8565a42 in mainline for kernel/test/cht/cht1.c


Ignore:
Timestamp:
2018-03-02T20:34:50Z (8 years ago)
Author:
GitHub <noreply@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a1a81f69, d5e5fd1
Parents:
3061bc1 (diff), 34e1206 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:34:50)
git-committer:
GitHub <noreply@…> (2018-03-02 20:34:50)
Message:

Remove all trailing whitespace, everywhere.

See individual commit messages for details.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/test/cht/cht1.c

    r3061bc1 r8565a42  
    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.";
Note: See TracChangeset for help on using the changeset viewer.