Changeset cb01e1e in mainline


Ignore:
Timestamp:
2009-04-04T00:26:27Z (15 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a85aebd
Parents:
171f9a1
Message:

use global variable and a macro for silencing tests

Location:
kernel
Files:
36 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/console/cmd.c

    r171f9a1 rcb01e1e  
    3232
    3333/**
    34  * @file        cmd.c
    35  * @brief       Kernel console command wrappers.
     34 * @file  cmd.c
     35 * @brief Kernel console command wrappers.
    3636 *
    3737 * This file is meant to contain all wrapper functions for
     
    997997       
    998998        /* Execute the test */
    999         char * ret = test->entry(false);
     999        test_quiet = false;
     1000        char *ret = test->entry();
    10001001       
    10011002        /* Update and read thread accounting */
     
    10491050               
    10501051                /* Execute the test */
    1051                 char * ret = test->entry(true);
     1052                test_quiet = true;
     1053                char * ret = test->entry();
    10521054               
    10531055                /* Update and read thread accounting */
     
    11511153        if (!fnd)
    11521154                printf("Unknown test\n");
    1153 
     1155       
    11541156        return 1;
    11551157}
  • kernel/test/atomic/atomic1.c

    r171f9a1 rcb01e1e  
    3232#include <debug.h>
    3333
    34 char * test_atomic1(bool quiet)
     34char *test_atomic1(void)
    3535{
    3636        atomic_t a;
  • kernel/test/avltree/avltree1.c

    r171f9a1 rcb01e1e  
    4242static avltree_node_t avltree_nodes[NODE_COUNT];
    4343
    44 /* 
     44/*
    4545 * head of free nodes' list:
    4646 */
     
    5959        if (!node)
    6060                return NULL;
    61 
     61       
    6262        if (node->lft) {
    6363                tmp = test_tree_parents(node->lft);
    6464                if (tmp != node) {
    65                         printf("Bad parent pointer key: %" PRIu64
     65                        TPRINTF("Bad parent pointer key: %" PRIu64
    6666                            ", address: %p\n", tmp->key, node->lft);
    6767                }
     
    7070                tmp = test_tree_parents(node->rgt);
    7171                if (tmp != node) {
    72                         printf("Bad parent pointer key: %" PRIu64
     72                        TPRINTF("Bad parent pointer key: %" PRIu64
    7373                            ", address: %p\n",
    7474                            tmp->key,node->rgt);
     
    8181{
    8282        int h1, h2, diff;
    83 
     83       
    8484        if (!node)
    8585                return 0;
     86       
    8687        h1 = test_tree_balance(node->lft);
    8788        h2 = test_tree_balance(node->rgt);
    8889        diff = h2 - h1;
    89         if (diff != node->balance || (diff != -1 && diff != 0 && diff != 1)) {
    90                 printf("Bad balance\n");
    91         }
    92         return h1 > h2 ? h1 + 1 : h2 + 1;
     90       
     91        if ((diff != node->balance) || ((diff != -1) && (diff != 0) && (diff != 1)))
     92                TPRINTF("Bad balance\n");
     93       
     94        return ((h1 > h2) ? (h1 + 1) : (h2 + 1));
    9395}
    9496
    9597/**
    9698 * Prints the structure of the node, which is level levels from the top of the
    97  * tree.
    98  */
    99 static void
    100 print_tree_structure_flat(avltree_node_t *node, int level)
     99 * tree.
     100 */
     101static void print_tree_structure_flat(avltree_node_t *node, int level)
    101102{
    102103        /*
    103104         * You can set the maximum level as high as you like.
    104          * Most of the time, you'll want to debug code using small trees,
    105          * so that a large level indicates a loop, which is a bug.
     105         * Most of the time, you'll want to debug code using small trees,
     106         * so that a large level indicates a loop, which is a bug.
    106107         */
    107108        if (level > 16) {
    108                 printf("[...]");
     109                TPRINTF("[...]");
    109110                return;
    110111        }
    111 
     112       
    112113        if (node == NULL)
    113114                return;
    114 
    115         printf("%" PRIu64 "[%" PRIu8 "]", node->key, node->balance);
     115       
     116        TPRINTF("%" PRIu64 "[%" PRIu8 "]", node->key, node->balance);
    116117        if (node->lft != NULL || node->rgt != NULL) {
    117                 printf("(");
    118 
     118                TPRINTF("(");
     119               
    119120                print_tree_structure_flat(node->lft, level + 1);
    120121                if (node->rgt != NULL) {
    121                         printf(",");
     122                        TPRINTF(",");
    122123                        print_tree_structure_flat(node->rgt, level + 1);
    123124                }
    124 
    125                 printf(")");
     125               
     126                TPRINTF(")");
    126127        }
    127128}
     
    130131{
    131132        int i;
    132 
    133         for (i = 0; i < NODE_COUNT - 1; i++) {
     133       
     134        for (i = 0; i < NODE_COUNT - 1; i++)
    134135                avltree_nodes[i].par = &avltree_nodes[i + 1];
    135         }
     136       
    136137        avltree_nodes[i].par = NULL;
    137138       
     
    140141         * array.
    141142         */
    142 
     143       
    143144        /* First tree node and same key */
    144145        avltree_nodes[0].key = 60;
    145146        avltree_nodes[1].key = 60;
    146147        avltree_nodes[2].key = 60;
     148       
    147149        /* LL rotation */
    148150        avltree_nodes[3].key = 50;
    149151        avltree_nodes[4].key = 40;
    150152        avltree_nodes[5].key = 30;
     153       
    151154        /* LR rotation */
    152155        avltree_nodes[6].key = 20;
     
    154157        avltree_nodes[8].key = 25;
    155158        avltree_nodes[9].key = 25;
     159       
    156160        /* LL rotation in lower floor */
    157161        avltree_nodes[10].key = 35;
     162       
    158163        /* RR rotation */
    159164        avltree_nodes[11].key = 70;
    160165        avltree_nodes[12].key = 80;
     166       
    161167        /* RL rotation */
    162168        avltree_nodes[13].key = 90;
    163169        avltree_nodes[14].key = 85;
     170       
    164171        /* Insert 0 key */
    165172        avltree_nodes[15].key = 0;
    166173        avltree_nodes[16].key = 0;
     174       
    167175        /* Insert reverse */
    168176        avltree_nodes[17].key = 600;
     
    170178        avltree_nodes[19].key = 400;
    171179        avltree_nodes[20].key = 300;
    172 
     180       
    173181        for (i = 21; i < NODE_COUNT; i++)
    174182                avltree_nodes[i].key = i * 3;
     
    180188{
    181189        avltree_node_t *node;
    182 
     190       
    183191        node = first_free_node;
    184192        first_free_node = first_free_node->par;
    185 
     193       
    186194        return node;
    187195}
    188196
    189 static void test_tree_insert(avltree_t *tree, count_t node_count, bool quiet)
     197static void test_tree_insert(avltree_t *tree, count_t node_count)
    190198{
    191199        unsigned int i;
    192200        avltree_node_t *newnode;
    193 
     201       
    194202        avltree_create(tree);
    195203       
    196         if (!quiet)
    197                 printf("Inserting %" PRIc " nodes...", node_count);
    198 
     204        TPRINTF("Inserting %" PRIc " nodes...", node_count);
     205       
    199206        for (i = 0; i < node_count; i++) {
    200207                newnode = alloc_avltree_node();
    201208               
    202209                avltree_insert(tree, newnode);
    203                 if (!quiet) {
    204                         test_tree_parents(tree->root);
    205                         test_tree_balance(tree->root);
    206                 }
    207         }
    208                
    209         if (!quiet)
    210                 printf("done.\n");
    211 }
    212 
     210                test_tree_parents(tree->root);
     211                test_tree_balance(tree->root);
     212        }
     213       
     214        TPRINTF("done.\n");
     215}
    213216
    214217static void test_tree_delete(avltree_t *tree, count_t node_count,
    215     int node_position, bool quiet)
     218    int node_position)
    216219{
    217220        avltree_node_t *delnode;
     
    220223        switch (node_position) {
    221224        case 0:
    222                 if (!quiet)
    223                         printf("Deleting root nodes...");
     225                TPRINTF("Deleting root nodes...");
     226               
    224227                while (tree->root != NULL) {
    225228                        delnode = tree->root;
    226229                        avltree_delete(tree, delnode);
    227                         if (!quiet) {
    228                                 test_tree_parents(tree->root);
    229                                 test_tree_balance(tree->root);
    230                         }
    231                 }
     230                        test_tree_parents(tree->root);
     231                        test_tree_balance(tree->root);
     232                }
    232233                break;
    233234        case 1:
    234                 if (!quiet)
    235                         printf("Deleting nodes according to creation time...");
     235                TPRINTF("Deleting nodes according to creation time...");
     236               
    236237                for (i = 0; i < node_count; i++) {
    237238                        avltree_delete(tree, &avltree_nodes[i]);
    238                         if (!quiet) {
    239                                 test_tree_parents(tree->root);
    240                                 test_tree_balance(tree->root);
    241                         }
    242                 }
    243                 break; 
    244         }
    245        
    246         if (!quiet)
    247                 printf("done.\n");
    248 }
    249 
    250 static void test_tree_delmin(avltree_t *tree, count_t node_count, bool quiet)
     239                        test_tree_parents(tree->root);
     240                        test_tree_balance(tree->root);
     241                }
     242                break;
     243        }
     244       
     245        TPRINTF("done.\n");
     246}
     247
     248static void test_tree_delmin(avltree_t *tree, count_t node_count)
    251249{
    252250        unsigned int i = 0;
    253251       
    254         if (!quiet)
    255                 printf("Deleting minimum nodes...");
     252        TPRINTF("Deleting minimum nodes...");
    256253       
    257254        while (tree->root != NULL) {
    258255                i++;
    259256                avltree_delete_min(tree);
    260                 if (!quiet) {
    261                         test_tree_parents(tree->root);
    262                         test_tree_balance(tree->root);
    263                 }
    264         }
    265 
    266         if (!quiet && (i != node_count))
    267                 printf("Bad node count. Some nodes have been lost!\n");
    268 
    269         if (!quiet)
    270                 printf("done.\n");
    271 }
    272 
    273 char *test_avltree1(bool quiet)
     257                test_tree_parents(tree->root);
     258                test_tree_balance(tree->root);
     259        }
     260       
     261        if (i != node_count)
     262                TPRINTF("Bad node count. Some nodes have been lost!\n");
     263       
     264        TPRINTF("done.\n");
     265}
     266
     267char *test_avltree1(void)
    274268{
    275269        alloc_avltree_node_prepare();
    276         test_tree_insert(&avltree, NODE_COUNT, quiet);
    277         test_tree_delete(&avltree, NODE_COUNT, 0, quiet);
    278 
     270        test_tree_insert(&avltree, NODE_COUNT);
     271        test_tree_delete(&avltree, NODE_COUNT, 0);
     272       
    279273        alloc_avltree_node_prepare();
    280         test_tree_insert(&avltree, NODE_COUNT, quiet);
    281         test_tree_delete(&avltree, NODE_COUNT, 1, quiet);
    282 
     274        test_tree_insert(&avltree, NODE_COUNT);
     275        test_tree_delete(&avltree, NODE_COUNT, 1);
     276       
    283277        alloc_avltree_node_prepare();
    284         test_tree_insert(&avltree, NODE_COUNT, quiet);
    285         test_tree_delmin(&avltree, NODE_COUNT, quiet);
    286 
     278        test_tree_insert(&avltree, NODE_COUNT);
     279        test_tree_delmin(&avltree, NODE_COUNT);
     280       
    287281        return NULL;
    288282}
    289 
  • kernel/test/btree/btree1.c

    r171f9a1 rcb01e1e  
    3434static void *data = (void *) 0xdeadbeef;
    3535
    36 char * test_btree1(bool quiet)
     36char *test_btree1(void)
    3737{
    3838        btree_t t;
    3939        int i;
    40 
     40       
    4141        btree_create(&t);
    4242       
    43         if (!quiet)
    44                 printf("Inserting keys.\n");
     43        TPRINTF("Inserting keys.\n");
    4544        btree_insert(&t, 19, data, NULL);
    4645        btree_insert(&t, 20, data, NULL);
     
    7978                btree_insert(&t, i, data, NULL);
    8079       
    81         if (!quiet)
     80        if (!test_quiet)
    8281                btree_print(&t);
    8382       
    84         if (!quiet)
    85                 printf("Removing keys.\n");
     83        TPRINTF("Removing keys.\n");
    8684        btree_remove(&t, 50, NULL);
    8785        btree_remove(&t, 49, NULL);
     
    159157        btree_remove(&t, 36, NULL);
    160158       
    161         if (!quiet)
     159        if (!test_quiet)
    162160                btree_print(&t);
    163161       
  • kernel/test/debug/mips1.c

    r171f9a1 rcb01e1e  
    3737#include <arch.h>
    3838
    39 char *test_mips1(bool quiet)
     39char *test_mips1(void)
    4040{
    41         if (!quiet)
    42                 printf("If kconsole is compiled in, you should enter debug mode now.\n");
     41        TPRINTF("If kconsole is compiled in, you should enter debug mode now.\n");
    4342       
    4443        asm volatile (
  • kernel/test/debug/mips1_skip.c

    r171f9a1 rcb01e1e  
    2929#include <test.h>
    3030
    31 char *test_mips1(bool quiet)
     31char *test_mips1(void)
    3232{
    3333        return NULL;
  • kernel/test/fault/fault1.c

    r171f9a1 rcb01e1e  
    3737#include <arch.h>
    3838
    39 
    40 char * test_fault1(bool quiet)
     39char *test_fault1(void)
    4140{
    4241        ((int *)(0))[1] = 0;
  • kernel/test/fpu/fpu1_ia64.c

    r171f9a1 rcb01e1e  
    6464static atomic_t threads_fault;
    6565static waitq_t can_start;
    66 static bool sh_quiet;
    6766
    6867static void e(void *data)
     
    8685               
    8786                if ((int) (100000000 * e) != E_10e8) {
    88                         if (!sh_quiet)
    89                                 printf("tid%" PRIu64 ": e*10e8=%zd should be %" PRIun "\n", THREAD->tid, (unative_t) (100000000 * e), (unative_t) E_10e8);
     87                        TPRINTF("tid%" PRIu64 ": e*10e8=%zd should be %" PRIun "\n", THREAD->tid, (unative_t) (100000000 * e), (unative_t) E_10e8);
    9088                        atomic_inc(&threads_fault);
    9189                        break;
     
    120118               
    121119                if ((int) (1000000 * pi) != PI_10e8) {
    122                         if (!sh_quiet)
    123                                 printf("tid%" PRIu64 ": pi*10e8=%zd should be %" PRIun "\n", THREAD->tid, (unative_t) (1000000 * pi), (unative_t) (PI_10e8 / 100));
     120                        TPRINTF("tid%" PRIu64 ": pi*10e8=%zd should be %" PRIun "\n", THREAD->tid, (unative_t) (1000000 * pi), (unative_t) (PI_10e8 / 100));
    124121                        atomic_inc(&threads_fault);
    125122                        break;
     
    129126}
    130127
    131 char * test_fpu1(bool quiet)
     128char *test_fpu1(void)
    132129{
    133130        unsigned int i, total = 0;
    134         sh_quiet = quiet;
    135131       
    136132        waitq_initialize(&can_start);
     
    138134        atomic_set(&threads_fault, 0);
    139135       
    140         if (!quiet)
    141                 printf("Creating %u threads... ", 2 * THREADS);
     136        TPRINTF("Creating %u threads... ", 2 * THREADS);
    142137       
    143         for (i = 0; i < THREADS; i++) { 
     138        for (i = 0; i < THREADS; i++) {
    144139                thread_t *t;
    145140               
    146141                if (!(t = thread_create(e, NULL, TASK, 0, "e", false))) {
    147                         if (!quiet)
    148                                 printf("could not create thread %u\n", 2 * i);
     142                        TPRINTF("could not create thread %u\n", 2 * i);
    149143                        break;
    150144                }
     
    153147               
    154148                if (!(t = thread_create(pi, NULL, TASK, 0, "pi", false))) {
    155                         if (!quiet)
    156                                 printf("could not create thread %u\n", 2 * i + 1);
     149                        TPRINTF("could not create thread %u\n", 2 * i + 1);
    157150                        break;
    158151                }
     
    161154        }
    162155       
    163         if (!quiet)
    164                 printf("ok\n");
     156        TPRINTF("ok\n");
    165157       
    166158        thread_sleep(1);
     
    168160       
    169161        while (atomic_get(&threads_ok) != (long) total) {
    170                 if (!quiet)
    171                         printf("Threads left: %d\n", total - atomic_get(&threads_ok));
     162                TPRINTF("Threads left: %d\n", total - atomic_get(&threads_ok));
    172163                thread_sleep(1);
    173164        }
  • kernel/test/fpu/fpu1_skip.c

    r171f9a1 rcb01e1e  
    2929#include <test.h>
    3030
    31 char * test_fpu1(bool quiet)
     31char *test_fpu1(void)
    3232{
    3333        return NULL;
  • kernel/test/fpu/fpu1_x86.c

    r171f9a1 rcb01e1e  
    6161static atomic_t threads_fault;
    6262static waitq_t can_start;
    63 static bool sh_quiet;
    6463
    6564static void e(void *data)
     
    8382               
    8483                if ((int) (100000000 * e) != E_10e8) {
    85                         if (!sh_quiet)
    86                                 printf("tid%" PRIu64 ": e*10e8=%zd should be %" PRIun "\n", THREAD->tid, (unative_t) (100000000 * e), (unative_t) E_10e8);
     84                        TPRINTF("tid%" PRIu64 ": e*10e8=%zd should be %" PRIun "\n", THREAD->tid, (unative_t) (100000000 * e), (unative_t) E_10e8);
    8785                        atomic_inc(&threads_fault);
    8886                        break;
     
    117115               
    118116                if ((int) (100000000 * pi) != PI_10e8) {
    119                         if (!sh_quiet)
    120                                 printf("tid%" PRIu64 ": pi*10e8=%zd should be %" PRIun "\n", THREAD->tid, (unative_t) (100000000 * pi), (unative_t) PI_10e8);
     117                        TPRINTF("tid%" PRIu64 ": pi*10e8=%zd should be %" PRIun "\n", THREAD->tid, (unative_t) (100000000 * pi), (unative_t) PI_10e8);
    121118                        atomic_inc(&threads_fault);
    122119                        break;
     
    126123}
    127124
    128 char * test_fpu1(bool quiet)
     125char *test_fpu1(void)
    129126{
    130127        unsigned int i, total = 0;
    131         sh_quiet = quiet;
    132128       
    133129        waitq_initialize(&can_start);
     
    135131        atomic_set(&threads_fault, 0);
    136132       
    137         if (!quiet)
    138                 printf("Creating %u threads... ", 2 * THREADS);
     133        TPRINTF("Creating %u threads... ", 2 * THREADS);
    139134       
    140         for (i = 0; i < THREADS; i++) { 
     135        for (i = 0; i < THREADS; i++) {
    141136                thread_t *t;
    142137               
    143138                if (!(t = thread_create(e, NULL, TASK, 0, "e", false))) {
    144                         if (!quiet)
    145                                 printf("could not create thread %u\n", 2 * i);
     139                        TPRINTF("could not create thread %u\n", 2 * i);
    146140                        break;
    147141                }
     
    150144               
    151145                if (!(t = thread_create(pi, NULL, TASK, 0, "pi", false))) {
    152                         if (!quiet)
    153                                 printf("could not create thread %u\n", 2 * i + 1);
     146                        TPRINTF("could not create thread %u\n", 2 * i + 1);
    154147                        break;
    155148                }
     
    158151        }
    159152       
    160         if (!quiet)
    161                 printf("ok\n");
     153        TPRINTF("ok\n");
    162154       
    163155        thread_sleep(1);
     
    165157       
    166158        while (atomic_get(&threads_ok) != (long) total) {
    167                 if (!quiet)
    168                         printf("Threads left: %d\n", total - atomic_get(&threads_ok));
     159                TPRINTF("Threads left: %d\n", total - atomic_get(&threads_ok));
    169160                thread_sleep(1);
    170161        }
  • kernel/test/fpu/mips2.c

    r171f9a1 rcb01e1e  
    4444static atomic_t threads_fault;
    4545static waitq_t can_start;
    46 static bool sh_quiet;
    4746
    4847static void testit1(void *data)
     
    7069               
    7170                if (arg != after_arg) {
    72                         if (!sh_quiet)
    73                                 printf("General reg tid%" PRIu64 ": arg(%d) != %d\n", THREAD->tid, arg, after_arg);
     71                        TPRINTF("General reg tid%" PRIu64 ": arg(%d) != %d\n", THREAD->tid, arg, after_arg);
    7472                        atomic_inc(&threads_fault);
    7573                        break;
     
    102100               
    103101                if (arg != after_arg) {
    104                         if (!sh_quiet)
    105                                 printf("General reg tid%" PRIu64 ": arg(%d) != %d\n", THREAD->tid, arg, after_arg);
     102                        TPRINTF("General reg tid%" PRIu64 ": arg(%d) != %d\n", THREAD->tid, arg, after_arg);
    106103                        atomic_inc(&threads_fault);
    107104                        break;
     
    112109
    113110
    114 char * test_mips2(bool quiet)
     111char *test_mips2(void)
    115112{
    116113        unsigned int i, total = 0;
    117         sh_quiet = quiet;
    118114       
    119115        waitq_initialize(&can_start);
     
    121117        atomic_set(&threads_fault, 0);
    122118       
    123         if (!quiet)
    124                 printf("Creating %u threads... ", 2 * THREADS);
     119        TPRINTF("Creating %u threads... ", 2 * THREADS);
    125120       
    126121        for (i = 0; i < THREADS; i++) {
     
    128123               
    129124                if (!(t = thread_create(testit1, (void *) ((unative_t) 2 * i), TASK, 0, "testit1", false))) {
    130                         if (!quiet)
    131                                 printf("could not create thread %u\n", 2 * i);
     125                        TPRINTF("could not create thread %u\n", 2 * i);
    132126                        break;
    133127                }
     
    136130               
    137131                if (!(t = thread_create(testit2, (void *) ((unative_t) 2 * i + 1), TASK, 0, "testit2", false))) {
    138                         if (!quiet)
    139                                 printf("could not create thread %u\n", 2 * i + 1);
     132                        TPRINTF("could not create thread %u\n", 2 * i + 1);
    140133                        break;
    141134                }
     
    144137        }
    145138       
    146         if (!quiet)
    147                 printf("ok\n");
     139        TPRINTF("ok\n");
    148140               
    149141        thread_sleep(1);
     
    151143       
    152144        while (atomic_get(&threads_ok) != (long) total) {
    153                 if (!quiet)
    154                         printf("Threads left: %d\n", total - atomic_get(&threads_ok));
     145                TPRINTF("Threads left: %d\n", total - atomic_get(&threads_ok));
    155146                thread_sleep(1);
    156147        }
  • kernel/test/fpu/mips2_skip.c

    r171f9a1 rcb01e1e  
    2929#include <test.h>
    3030
    31 char * test_mips2(bool quiet)
     31char *test_mips2(void)
    3232{
    3333        return NULL;
  • kernel/test/fpu/sse1.c

    r171f9a1 rcb01e1e  
    4444static atomic_t threads_fault;
    4545static waitq_t can_start;
    46 static bool sh_quiet;
    47 
    4846
    4947static void testit1(void *data)
     
    5250        int arg __attribute__((aligned(16))) = (int) ((unative_t) data);
    5351        int after_arg __attribute__((aligned(16)));
    54 
     52       
    5553        thread_detach(THREAD);
    5654       
    5755        waitq_sleep(&can_start);
    58 
     56       
    5957        for (i = 0; i < ATTEMPTS; i++) {
    6058                asm volatile (
     
    6260                        : [arg] "=m" (arg)
    6361                );
    64 
     62               
    6563                delay(DELAY);
    6664                asm volatile (
     
    7068               
    7169                if (arg != after_arg) {
    72                         if (!sh_quiet)
    73                                 printf("tid%" PRIu64 ": arg(%d) != %d\n", THREAD->tid, arg, after_arg);
     70                        TPRINTF("tid%" PRIu64 ": arg(%d) != %d\n", THREAD->tid, arg, after_arg);
    7471                        atomic_inc(&threads_fault);
    7572                        break;
     
    8885       
    8986        waitq_sleep(&can_start);
    90 
     87       
    9188        for (i = 0; i < ATTEMPTS; i++) {
    9289                asm volatile (
     
    9491                        : [arg] "=m" (arg)
    9592                );
    96 
     93               
    9794                scheduler();
    9895                asm volatile (
     
    10299               
    103100                if (arg != after_arg) {
    104                         if (!sh_quiet)
    105                                 printf("tid%" PRIu64 ": arg(%d) != %d\n", THREAD->tid, arg, after_arg);
     101                        TPRINTF("tid%" PRIu64 ": arg(%d) != %d\n", THREAD->tid, arg, after_arg);
    106102                        atomic_inc(&threads_fault);
    107103                        break;
     
    111107}
    112108
    113 
    114 char * test_sse1(bool quiet)
     109char *test_sse1(void)
    115110{
    116111        unsigned int i, total = 0;
    117         sh_quiet = quiet;
    118112       
    119113        waitq_initialize(&can_start);
     
    121115        atomic_set(&threads_fault, 0);
    122116       
    123         if (!quiet)
    124                 printf("Creating %u threads... ", 2 * THREADS);
    125 
     117        TPRINTF("Creating %u threads... ", 2 * THREADS);
     118       
    126119        for (i = 0; i < THREADS; i++) {
    127120                thread_t *t;
    128121               
    129122                if (!(t = thread_create(testit1, (void *) ((unative_t) 2 * i), TASK, 0, "testit1", false))) {
    130                         if (!quiet)
    131                                 printf("could not create thread %u\n", 2 * i);
     123                        TPRINTF("could not create thread %u\n", 2 * i);
    132124                        break;
    133125                }
     
    136128               
    137129                if (!(t = thread_create(testit2, (void *) ((unative_t) 2 * i + 1), TASK, 0, "testit2", false))) {
    138                         if (!quiet)
    139                                 printf("could not create thread %u\n", 2 * i + 1);
     130                        TPRINTF("could not create thread %u\n", 2 * i + 1);
    140131                        break;
    141132                }
     
    144135        }
    145136       
    146         if (!quiet)
    147                 printf("ok\n");
    148                
     137        TPRINTF("ok\n");
     138       
    149139        thread_sleep(1);
    150140        waitq_wakeup(&can_start, WAKEUP_ALL);
    151141       
    152142        while (atomic_get(&threads_ok) != (long) total) {
    153                 if (!quiet)
    154                         printf("Threads left: %d\n", total - atomic_get(&threads_ok));
     143                TPRINTF("Threads left: %d\n", total - atomic_get(&threads_ok));
    155144                thread_sleep(1);
    156145        }
  • kernel/test/fpu/sse1_skip.c

    r171f9a1 rcb01e1e  
    2929#include <test.h>
    3030
    31 char * test_sse1(bool quiet)
     31char *test_sse1(void)
    3232{
    3333        return NULL;
  • kernel/test/mm/falloc1.c

    r171f9a1 rcb01e1e  
    3737#include <align.h>
    3838
    39 #define MAX_FRAMES 1024
    40 #define MAX_ORDER 8
    41 #define TEST_RUNS 2
     39#define MAX_FRAMES  1024
     40#define MAX_ORDER   8
     41#define TEST_RUNS   2
    4242
    43 char * test_falloc1(bool quiet) {
    44         uintptr_t * frames = (uintptr_t *) malloc(MAX_FRAMES * sizeof(uintptr_t), 0);
     43char *test_falloc1(void) {
     44        uintptr_t *frames
     45            = (uintptr_t *) malloc(MAX_FRAMES * sizeof(uintptr_t), 0);
    4546        int results[MAX_ORDER + 1];
    4647       
     
    5354        if (frames == NULL)
    5455                return "Unable to allocate frames";
    55 
     56       
    5657        for (run = 0; run < TEST_RUNS; run++) {
    5758                for (order = 0; order <= MAX_ORDER; order++) {
    58                         if (!quiet)
    59                                 printf("Allocating %d frames blocks ... ", 1 << order);
     59                        TPRINTF("Allocating %d frames blocks ... ", 1 << order);
    6060                       
    6161                        allocated = 0;
     
    6464                               
    6565                                if (ALIGN_UP(frames[allocated], FRAME_SIZE << order) != frames[allocated]) {
    66                                         if (!quiet)
    67                                                 printf("Block at address %p (size %dK) is not aligned\n", frames[allocated], (FRAME_SIZE << order) >> 10);
     66                                        TPRINTF("Block at address %p (size %dK) is not aligned\n", frames[allocated], (FRAME_SIZE << order) >> 10);
    6867                                        return "Test failed";
    6968                                }
     
    7271                                        allocated++;
    7372                                else {
    74                                         if (!quiet)
    75                                                 printf("done. ");
     73                                        TPRINTF("done. ");
    7674                                        break;
    7775                                }
    7876                        }
    7977                       
    80                         if (!quiet)
    81                                 printf("%d blocks allocated.\n", allocated);
    82                
     78                        TPRINTF("%d blocks allocated.\n", allocated);
     79                       
    8380                        if (run) {
    8481                                if (results[order] != allocated)
     
    8784                                results[order] = allocated;
    8885                       
    89                         if (!quiet)
    90                                 printf("Deallocating ... ");
     86                        TPRINTF("Deallocating ... ");
    9187                       
    9288                        for (i = 0; i < allocated; i++)
    9389                                frame_free(KA2PA(frames[i]));
    9490                       
    95                         if (!quiet)
    96                                 printf("done.\n");
     91                        TPRINTF("done.\n");
    9792                }
    9893        }
    99 
     94       
    10095        free(frames);
    10196       
  • kernel/test/mm/falloc2.c

    r171f9a1 rcb01e1e  
    4040#include <arch.h>
    4141
    42 #define MAX_FRAMES 256
    43 #define MAX_ORDER 8
     42#define MAX_FRAMES  256
     43#define MAX_ORDER   8
    4444
    45 #define THREAD_RUNS 1
    46 #define THREADS 8
     45#define THREAD_RUNS  1
     46#define THREADS      8
    4747
    4848static atomic_t thread_count;
    4949static atomic_t thread_fail;
    50 static bool sh_quiet;
    5150
    52 static void falloc(void * arg)
     51static void falloc(void *arg)
    5352{
    5453        int order, run, allocated, i;
     
    5857        void **frames =  (void **) malloc(MAX_FRAMES * sizeof(void *), FRAME_ATOMIC);
    5958        if (frames == NULL) {
    60                 if (!sh_quiet)
    61                         printf("Thread #%" PRIu64 " (cpu%u): Unable to allocate frames\n", THREAD->tid, CPU->id);
     59                TPRINTF("Thread #%" PRIu64 " (cpu%u): Unable to allocate frames\n", THREAD->tid, CPU->id);
    6260                atomic_inc(&thread_fail);
    6361                atomic_dec(&thread_count);
     
    6664       
    6765        thread_detach(THREAD);
    68 
     66       
    6967        for (run = 0; run < THREAD_RUNS; run++) {
    7068                for (order = 0; order <= MAX_ORDER; order++) {
    71                         if (!sh_quiet)
    72                                 printf("Thread #%" PRIu64 " (cpu%u): Allocating %d frames blocks ... \n", THREAD->tid, CPU->id, 1 << order);
     69                        TPRINTF("Thread #%" PRIu64 " (cpu%u): Allocating %d frames blocks ... \n", THREAD->tid, CPU->id, 1 << order);
    7370                       
    7471                        allocated = 0;
     
    8279                        }
    8380                       
    84                         if (!sh_quiet)
    85                                 printf("Thread #%" PRIu64 " (cpu%u): %d blocks allocated.\n", THREAD->tid, CPU->id, allocated);
    86                        
    87                         if (!sh_quiet)
    88                                 printf("Thread #%" PRIu64 " (cpu%u): Deallocating ... \n", THREAD->tid, CPU->id);
     81                        TPRINTF("Thread #%" PRIu64 " (cpu%u): %d blocks allocated.\n", THREAD->tid, CPU->id, allocated);
     82                        TPRINTF("Thread #%" PRIu64 " (cpu%u): Deallocating ... \n", THREAD->tid, CPU->id);
    8983                       
    9084                        for (i = 0; i < allocated; i++) {
    9185                                for (k = 0; k <= (((index_t) FRAME_SIZE << order) - 1); k++) {
    9286                                        if (((uint8_t *) frames[i])[k] != val) {
    93                                                 if (!sh_quiet)
    94                                                         printf("Thread #%" PRIu64 " (cpu%u): Unexpected data (%c) in block %p offset %#" PRIi "\n", THREAD->tid, CPU->id, ((char *) frames[i])[k], frames[i], k);
     87                                                TPRINTF("Thread #%" PRIu64 " (cpu%u): Unexpected data (%c) in block %p offset %#" PRIi "\n", THREAD->tid, CPU->id, ((char *) frames[i])[k], frames[i], k);
    9588                                                atomic_inc(&thread_fail);
    9689                                                goto cleanup;
     
    10093                        }
    10194                       
    102                         if (!sh_quiet)
    103                                 printf("Thread #%" PRIu64 " (cpu%u): Finished run.\n", THREAD->tid, CPU->id);
     95                        TPRINTF("Thread #%" PRIu64 " (cpu%u): Finished run.\n", THREAD->tid, CPU->id);
    10496                }
    10597        }
    106 
    107 cleanup:       
     98       
     99cleanup:
    108100        free(frames);
    109101       
    110         if (!sh_quiet)
    111                 printf("Thread #%" PRIu64 " (cpu%u): Exiting\n", THREAD->tid, CPU->id);
     102        TPRINTF("Thread #%" PRIu64 " (cpu%u): Exiting\n", THREAD->tid, CPU->id);
    112103        atomic_dec(&thread_count);
    113104}
    114105
    115 char * test_falloc2(bool quiet)
     106char *test_falloc2(void)
    116107{
    117108        unsigned int i;
    118         sh_quiet = quiet;
    119 
     109       
    120110        atomic_set(&thread_count, THREADS);
    121111        atomic_set(&thread_fail, 0);
    122                
     112       
    123113        for (i = 0; i < THREADS; i++) {
    124114                thread_t * thrd = thread_create(falloc, NULL, TASK, 0, "falloc", false);
    125115                if (!thrd) {
    126                         if (!quiet)
    127                                 printf("Could not create thread %u\n", i);
     116                        TPRINTF("Could not create thread %u\n", i);
    128117                        break;
    129118                }
     
    132121       
    133122        while (atomic_get(&thread_count) > 0) {
    134                 if (!quiet)
    135                         printf("Threads left: %ld\n", atomic_get(&thread_count));
     123                TPRINTF("Threads left: %ld\n", atomic_get(&thread_count));
    136124                thread_sleep(1);
    137125        }
  • kernel/test/mm/mapping1.c

    r171f9a1 rcb01e1e  
    3636#include <debug.h>
    3737
    38 #define PAGE0   0x10000000
    39 #define PAGE1   (PAGE0+PAGE_SIZE)
     38#define PAGE0  0x10000000
     39#define PAGE1  (PAGE0 + PAGE_SIZE)
    4040
    41 #define VALUE0  0x01234567
    42 #define VALUE1  0x89abcdef
     41#define VALUE0  0x01234567
     42#define VALUE1  0x89abcdef
    4343
    44 char * test_mapping1(bool quiet)
     44char *test_mapping1(void)
    4545{
    4646        uintptr_t frame0, frame1;
    4747        uint32_t v0, v1;
    48 
     48       
    4949        frame0 = (uintptr_t) frame_alloc(ONE_FRAME, FRAME_KA);
    5050        frame1 = (uintptr_t) frame_alloc(ONE_FRAME, FRAME_KA);
    5151       
    52         if (!quiet)
    53                 printf("Writing %#x to physical address %p.\n", VALUE0, KA2PA(frame0));
     52        TPRINTF("Writing %#x to physical address %p.\n", VALUE0, KA2PA(frame0));
    5453        *((uint32_t *) frame0) = VALUE0;
    55         if (!quiet)
    56                 printf("Writing %#x to physical address %p.\n", VALUE1, KA2PA(frame1));
     54       
     55        TPRINTF("Writing %#x to physical address %p.\n", VALUE1, KA2PA(frame1));
    5756        *((uint32_t *) frame1) = VALUE1;
    5857       
    59         if (!quiet)
    60                 printf("Mapping virtual address %p to physical address %p.\n", PAGE0, KA2PA(frame0));
     58        TPRINTF("Mapping virtual address %p to physical address %p.\n", PAGE0, KA2PA(frame0));
    6159        page_mapping_insert(AS_KERNEL, PAGE0, KA2PA(frame0), PAGE_PRESENT | PAGE_WRITE);
    62         if (!quiet)
    63                 printf("Mapping virtual address %p to physical address %p.\n", PAGE1, KA2PA(frame1));   
     60       
     61        TPRINTF("Mapping virtual address %p to physical address %p.\n", PAGE1, KA2PA(frame1));
    6462        page_mapping_insert(AS_KERNEL, PAGE1, KA2PA(frame1), PAGE_PRESENT | PAGE_WRITE);
    6563       
    6664        v0 = *((uint32_t *) PAGE0);
    6765        v1 = *((uint32_t *) PAGE1);
    68         if (!quiet) {
    69                 printf("Value at virtual address %p is %#x.\n", PAGE0, v0);
    70                 printf("Value at virtual address %p is %#x.\n", PAGE1, v1);
    71         }
     66        TPRINTF("Value at virtual address %p is %#x.\n", PAGE0, v0);
     67        TPRINTF("Value at virtual address %p is %#x.\n", PAGE1, v1);
    7268       
    7369        if (v0 != VALUE0)
     
    7672                return "Value at v1 not equal to VALUE1";
    7773       
    78         if (!quiet)
    79                 printf("Writing %#x to virtual address %p.\n", 0, PAGE0);
     74        TPRINTF("Writing %#x to virtual address %p.\n", 0, PAGE0);
    8075        *((uint32_t *) PAGE0) = 0;
    81         if (!quiet)
    82                 printf("Writing %#x to virtual address %p.\n", 0, PAGE1);
    83         *((uint32_t *) PAGE1) = 0;     
    84 
     76       
     77        TPRINTF("Writing %#x to virtual address %p.\n", 0, PAGE1);
     78        *((uint32_t *) PAGE1) = 0;
     79       
    8580        v0 = *((uint32_t *) PAGE0);
    8681        v1 = *((uint32_t *) PAGE1);
    8782       
    88         if (!quiet) {
    89                 printf("Value at virtual address %p is %#x.\n", PAGE0, *((uint32_t *) PAGE0)); 
    90                 printf("Value at virtual address %p is %#x.\n", PAGE1, *((uint32_t *) PAGE1));
    91         }
    92 
     83        TPRINTF("Value at virtual address %p is %#x.\n", PAGE0, *((uint32_t *) PAGE0));
     84        TPRINTF("Value at virtual address %p is %#x.\n", PAGE1, *((uint32_t *) PAGE1));
     85       
    9386        if (v0 != 0)
    9487                return "Value at v0 not equal to 0";
     
    9689                return "Value at v1 not equal to 0";
    9790       
    98         return NULL;   
     91        return NULL;
    9992}
  • kernel/test/mm/purge1.c

    r171f9a1 rcb01e1e  
    4040extern void tlb_invalidate_pages(asid_t asid, uintptr_t va, count_t cnt);
    4141
    42 char * test_purge1(bool quiet)
     42char *test_purge1(void)
    4343{
    4444        tlb_entry_t entryi;
  • kernel/test/mm/purge1_skip.c

    r171f9a1 rcb01e1e  
    2929#include <test.h>
    3030
    31 char *test_purge1(bool quiet)
     31char *test_purge1(void)
    3232{
    3333        return NULL;
  • kernel/test/mm/slab1.c

    r171f9a1 rcb01e1e  
    3434#include <memstr.h>
    3535
    36 #define VAL_COUNT   1024
     36#define VAL_COUNT  1024
    3737
    38 static void * data[VAL_COUNT];
     38static void *data[VAL_COUNT];
    3939
    40 static void testit(int size, int count, bool quiet)
     40static void testit(int size, int count)
    4141{
    4242        slab_cache_t *cache;
    4343        int i;
    4444       
    45         if (!quiet)
    46                 printf("Creating cache, object size: %d.\n", size);
     45        TPRINTF("Creating cache, object size: %d.\n", size);
    4746       
    4847        cache = slab_cache_create("test_cache", size, 0, NULL, NULL,
    49                                 SLAB_CACHE_NOMAGAZINE);
     48            SLAB_CACHE_NOMAGAZINE);
    5049       
    51         if (!quiet)
    52                 printf("Allocating %d items...", count);
     50        TPRINTF("Allocating %d items...", count);
    5351       
    5452        for (i = 0; i < count; i++) {
     
    5755        }
    5856       
    59         if (!quiet) {
    60                 printf("done.\n");
    61                 printf("Freeing %d items...", count);
    62         }
     57        TPRINTF("done.\n");
     58       
     59        TPRINTF("Freeing %d items...", count);
    6360       
    6461        for (i = 0; i < count; i++)
    6562                slab_free(cache, data[i]);
    6663       
    67         if (!quiet) {
    68                 printf("done.\n");
    69                 printf("Allocating %d items...", count);
    70         }
     64        TPRINTF("done.\n");
     65       
     66        TPRINTF("Allocating %d items...", count);
    7167       
    7268        for (i = 0; i < count; i++) {
     
    7571        }
    7672       
    77         if (!quiet) {
    78                 printf("done.\n");
    79                 printf("Freeing %d items...", count / 2);
    80         }
     73        TPRINTF("done.\n");
     74       
     75        TPRINTF("Freeing %d items...", count / 2);
    8176       
    8277        for (i = count - 1; i >= count / 2; i--)
    8378                slab_free(cache, data[i]);
    8479       
    85         if (!quiet) {
    86                 printf("done.\n");     
    87                 printf("Allocating %d items...", count / 2);
    88         }
     80        TPRINTF("done.\n");
     81       
     82        TPRINTF("Allocating %d items...", count / 2);
    8983       
    9084        for (i = count / 2; i < count; i++) {
     
    9387        }
    9488       
    95         if (!quiet) {
    96                 printf("done.\n");
    97                 printf("Freeing %d items...", count);
    98         }
     89        TPRINTF("done.\n");
     90       
     91        TPRINTF("Freeing %d items...", count);
    9992       
    10093        for (i = 0; i < count; i++)
    10194                slab_free(cache, data[i]);
    10295       
    103         if (!quiet)
    104                 printf("done.\n");     
     96        TPRINTF("done.\n");
     97       
    10598        slab_cache_destroy(cache);
    10699       
    107         if (!quiet)
    108                 printf("Test complete.\n");
     100        TPRINTF("Test complete.\n");
    109101}
    110102
    111 static void testsimple(bool quiet)
     103static void testsimple(void)
    112104{
    113         testit(100, VAL_COUNT, quiet);
    114         testit(200, VAL_COUNT, quiet);
    115         testit(1024, VAL_COUNT, quiet);
    116         testit(2048, 512, quiet);
    117         testit(4000, 128, quiet);
    118         testit(8192, 128, quiet);
    119         testit(16384, 128, quiet);
    120         testit(16385, 128, quiet);
     105        testit(100, VAL_COUNT);
     106        testit(200, VAL_COUNT);
     107        testit(1024, VAL_COUNT);
     108        testit(2048, 512);
     109        testit(4000, 128);
     110        testit(8192, 128);
     111        testit(16384, 128);
     112        testit(16385, 128);
    121113}
    122114
    123 #define THREADS     6
    124 #define THR_MEM_COUNT   1024
    125 #define THR_MEM_SIZE    128
     115#define THREADS        6
     116#define THR_MEM_COUNT  1024
     117#define THR_MEM_SIZE   128
    126118
    127 static void * thr_data[THREADS][THR_MEM_COUNT];
     119static void *thr_data[THREADS][THR_MEM_COUNT];
    128120static slab_cache_t *thr_cache;
    129121static semaphore_t thr_sem;
    130 static bool sh_quiet;
    131122
    132123static void slabtest(void *data)
     
    137128        thread_detach(THREAD);
    138129       
    139         if (!sh_quiet)
    140                 printf("Starting thread #%" PRIu64 "...\n", THREAD->tid);
     130        TPRINTF("Starting thread #%" PRIu64 "...\n", THREAD->tid);
    141131       
    142132        for (j = 0; j < 10; j++) {
     
    151141        }
    152142       
    153         if (!sh_quiet)
    154                 printf("Thread #%" PRIu64 " finished\n", THREAD->tid);
     143        TPRINTF("Thread #%" PRIu64 " finished\n", THREAD->tid);
    155144       
    156145        semaphore_up(&thr_sem);
    157146}
    158147
    159 static void testthreads(bool quiet)
     148static void testthreads(void)
    160149{
    161150        thread_t *t;
    162151        int i;
    163 
     152       
    164153        thr_cache = slab_cache_create("thread_cache", THR_MEM_SIZE, 0, NULL, NULL,
    165                                         SLAB_CACHE_NOMAGAZINE);
     154            SLAB_CACHE_NOMAGAZINE);
     155       
    166156        semaphore_initialize(&thr_sem, 0);
    167157        for (i = 0; i < THREADS; i++) { 
    168158                if (!(t = thread_create(slabtest, (void *) (unative_t) i, TASK, 0, "slabtest", false))) {
    169                         if (!quiet)
    170                                 printf("Could not create thread %d\n", i);
     159                        TPRINTF("Could not create thread %d\n", i);
    171160                } else
    172161                        thread_ready(t);
     
    178167        slab_cache_destroy(thr_cache);
    179168       
    180         if (!quiet)
    181                 printf("Test complete.\n");
     169        TPRINTF("Test complete.\n");
    182170}
    183171
    184 char * test_slab1(bool quiet)
     172char *test_slab1(void)
    185173{
    186         sh_quiet = quiet;
    187        
    188         testsimple(quiet);
    189         testthreads(quiet);
     174        testsimple();
     175        testthreads();
    190176       
    191177        return NULL;
  • kernel/test/mm/slab2.c

    r171f9a1 rcb01e1e  
    3737#include <synch/mutex.h>
    3838
    39 #define ITEM_SIZE 256
     39#define ITEM_SIZE  256
    4040
    4141/** Fill memory with 2 caches, when allocation fails,
     
    4343 *  now allocation should clean magazines and allow for full allocation.
    4444 */
    45 static void totalmemtest(bool quiet)
     45static void totalmemtest(void)
    4646{
    4747        slab_cache_t *cache1;
    4848        slab_cache_t *cache2;
    4949        int i;
    50 
     50       
    5151        void *data1, *data2;
    5252        void *olddata1 = NULL, *olddata2 = NULL;
     
    5555        cache2 = slab_cache_create("cache2_tst", ITEM_SIZE, 0, NULL, NULL, 0);
    5656       
    57         if (!quiet)
    58                 printf("Allocating...");
     57        TPRINTF("Allocating...");
    5958       
    6059        /* Use atomic alloc, so that we find end of memory */
     
    7574                olddata1 = data1;
    7675                olddata2 = data2;
    77         } while (1);
    78        
    79         if (!quiet) {
    80                 printf("done.\n");
    81                 printf("Deallocating cache2...");
    82         }
     76        } while (true);
     77       
     78        TPRINTF("done.\n");
     79       
     80        TPRINTF("Deallocating cache2...");
    8381       
    8482        /* We do not have memory - now deallocate cache2 */
     
    8987        }
    9088       
    91         if (!quiet) {
    92                 printf("done.\n");
    93                 printf("Allocating to cache1...\n");
    94         }
     89        TPRINTF("done.\n");
     90       
     91        TPRINTF("Allocating to cache1...\n");
    9592       
    9693        for (i = 0; i < 30; i++) {
    9794                data1 = slab_alloc(cache1, FRAME_ATOMIC);
    9895                if (!data1) {
    99                         if (!quiet)
    100                                 printf("Incorrect memory size - use another test.");
     96                        TPRINTF("Incorrect memory size - use another test.");
    10197                        return;
    10298                }
     
    105101                olddata1 = data1;
    106102        }
    107         while (1) {
     103        while (true) {
    108104                data1 = slab_alloc(cache1, FRAME_ATOMIC);
    109105                if (!data1)
     
    114110        }
    115111       
    116         if (!quiet)
    117                 printf("Deallocating cache1...");
     112        TPRINTF("Deallocating cache1...");
    118113       
    119114        while (olddata1) {
     
    123118        }
    124119       
    125         if (!quiet) {
    126                 printf("done.\n");
    127                 slab_print_list();
    128         }
     120        TPRINTF("done.\n");
     121       
     122        slab_print_list();
    129123       
    130124        slab_cache_destroy(cache1);
     
    136130static condvar_t thread_starter;
    137131static mutex_t starter_mutex;
    138 static bool sh_quiet;
    139 
    140 #define THREADS 8
     132
     133#define THREADS  8
    141134
    142135static void slabtest(void *priv)
     
    150143        mutex_unlock(&starter_mutex);
    151144       
    152         if (!sh_quiet)
    153                 printf("Starting thread #%" PRIu64 "...\n", THREAD->tid);
     145        TPRINTF("Starting thread #%" PRIu64 "...\n", THREAD->tid);
    154146
    155147        /* Alloc all */
    156         if (!sh_quiet)
    157                 printf("Thread #%" PRIu64 " allocating...\n", THREAD->tid);
    158        
    159         while (1) {
     148        TPRINTF("Thread #%" PRIu64 " allocating...\n", THREAD->tid);
     149       
     150        while (true) {
    160151                /* Call with atomic to detect end of memory */
    161152                new = slab_alloc(thr_cache, FRAME_ATOMIC);
     
    166157        }
    167158       
    168         if (!sh_quiet)
    169                 printf("Thread #%" PRIu64 " releasing...\n", THREAD->tid);
     159        TPRINTF("Thread #%" PRIu64 " releasing...\n", THREAD->tid);
    170160       
    171161        while (data) {
     
    176166        }
    177167       
    178         if (!sh_quiet)
    179                 printf("Thread #%" PRIu64 " allocating...\n", THREAD->tid);
    180        
    181         while (1) {
     168        TPRINTF("Thread #%" PRIu64 " allocating...\n", THREAD->tid);
     169       
     170        while (true) {
    182171                /* Call with atomic to detect end of memory */
    183172                new = slab_alloc(thr_cache, FRAME_ATOMIC);
     
    188177        }
    189178       
    190         if (!sh_quiet)
    191                 printf("Thread #%" PRIu64 " releasing...\n", THREAD->tid);
     179        TPRINTF("Thread #%" PRIu64 " releasing...\n", THREAD->tid);
    192180       
    193181        while (data) {
     
    198186        }
    199187       
    200         if (!sh_quiet)
    201                 printf("Thread #%" PRIu64 " finished\n", THREAD->tid);
     188        TPRINTF("Thread #%" PRIu64 " finished\n", THREAD->tid);
    202189       
    203190        slab_print_list();
     
    205192}
    206193
    207 static void multitest(int size, bool quiet)
     194static void multitest(int size)
    208195{
    209196        /* Start 8 threads that just allocate as much as possible,
     
    213200        int i;
    214201       
    215         if (!quiet)
    216                 printf("Running stress test with size %d\n", size);
     202        TPRINTF("Running stress test with size %d\n", size);
    217203       
    218204        condvar_initialize(&thread_starter);
    219205        mutex_initialize(&starter_mutex, MUTEX_PASSIVE);
    220 
     206       
    221207        thr_cache = slab_cache_create("thread_cache", size, 0, NULL, NULL, 0);
    222208        semaphore_initialize(&thr_sem,0);
    223209        for (i = 0; i < THREADS; i++) { 
    224210                if (!(t = thread_create(slabtest, NULL, TASK, 0, "slabtest", false))) {
    225                         if (!quiet)
    226                                 printf("Could not create thread %d\n", i);
     211                        TPRINTF("Could not create thread %d\n", i);
    227212                } else
    228213                        thread_ready(t);
     
    230215        thread_sleep(1);
    231216        condvar_broadcast(&thread_starter);
    232 
     217       
    233218        for (i = 0; i < THREADS; i++)
    234219                semaphore_down(&thr_sem);
    235220       
    236221        slab_cache_destroy(thr_cache);
    237         if (!quiet)
    238                 printf("Stress test complete.\n");
    239 }
    240 
    241 char * test_slab2(bool quiet)
    242 {
    243         sh_quiet = quiet;
    244        
    245         if (!quiet)
    246                 printf("Running reclaim single-thread test .. pass 1\n");
    247         totalmemtest(quiet);
    248         if (!quiet)
    249                 printf("Running reclaim single-thread test .. pass 2\n");
    250         totalmemtest(quiet);
    251         if (!quiet)
    252                 printf("Reclaim test OK.\n");
    253        
    254         multitest(128, quiet);
    255         multitest(2048, quiet);
    256         multitest(8192, quiet);
     222        TPRINTF("Stress test complete.\n");
     223}
     224
     225char *test_slab2(void)
     226{
     227        TPRINTF("Running reclaim single-thread test .. pass 1\n");
     228        totalmemtest();
     229       
     230        TPRINTF("Running reclaim single-thread test .. pass 2\n");
     231        totalmemtest();
     232       
     233        TPRINTF("Reclaim test OK.\n");
     234       
     235        multitest(128);
     236        multitest(2048);
     237        multitest(8192);
    257238       
    258239        return NULL;
  • kernel/test/print/print1.c

    r171f9a1 rcb01e1e  
    3030#include <test.h>
    3131
    32 char *test_print1(bool quiet)
     32char *test_print1(void)
    3333{
    34         if (!quiet) {
    35                 printf("Testing printf(\"%%*.*s\", 5, 3, \"text\"):\n");
    36                 printf("Expected output: \"  tex\"\n");
    37                 printf("Real output:     \"%*.*s\"\n\n", 5, 3, "text");
    38                
    39                 printf("Testing printf(\"%%10.8s\", \"very long text\"):\n");
    40                 printf("Expected output: \"  very lon\"\n");
    41                 printf("Real output:     \"%10.8s\"\n\n", "very long text");
    42                
    43                 printf("Testing printf(\"%%8.10s\", \"text\"):\n");
    44                 printf("Expected output: \"text\"\n");
    45                 printf("Real output:     \"%8.10s\"\n\n", "text");
    46                
    47                 printf("Testing printf(\"%%8.10s\", \"very long text\"):\n");
    48                 printf("Expected output: \"very long \"\n");
    49                 printf("Real output:     \"%8.10s\"\n\n", "very long text");
    50                
    51                 printf("Testing printf(\"%%s\", NULL):\n");
    52                 printf("Expected output: \"(NULL)\"\n");
    53                 printf("Real output:     \"%s\"\n\n", NULL);
    54         }
     34        TPRINTF("Testing printf(\"%%*.*s\", 5, 3, \"text\"):\n");
     35        TPRINTF("Expected output: \"  tex\"\n");
     36        TPRINTF("Real output:     \"%*.*s\"\n\n", 5, 3, "text");
     37       
     38        TPRINTF("Testing printf(\"%%10.8s\", \"very long text\"):\n");
     39        TPRINTF("Expected output: \"  very lon\"\n");
     40        TPRINTF("Real output:     \"%10.8s\"\n\n", "very long text");
     41       
     42        TPRINTF("Testing printf(\"%%8.10s\", \"text\"):\n");
     43        TPRINTF("Expected output: \"text\"\n");
     44        TPRINTF("Real output:     \"%8.10s\"\n\n", "text");
     45       
     46        TPRINTF("Testing printf(\"%%8.10s\", \"very long text\"):\n");
     47        TPRINTF("Expected output: \"very long \"\n");
     48        TPRINTF("Real output:     \"%8.10s\"\n\n", "very long text");
     49       
     50        TPRINTF("Testing printf(\"%%s\", NULL):\n");
     51        TPRINTF("Expected output: \"(NULL)\"\n");
     52        TPRINTF("Real output:     \"%s\"\n\n", NULL);
    5553       
    5654        return NULL;
  • kernel/test/print/print2.c

    r171f9a1 rcb01e1e  
    3030#include <test.h>
    3131
    32 char *test_print2(bool quiet)
     32char *test_print2(void)
    3333{
    34         if (!quiet) {
    35                 printf("Testing printf(\"%%c %%3.2c %%-3.2c %%2.3c %%-2.3c\", 'a', 'b', 'c', 'd', 'e'):\n");
    36                 printf("Expected output: [a] [  b] [c  ] [ d] [e ]\n");
    37                 printf("Real output:     [%c] [%3.2c] [%-3.2c] [%2.3c] [%-2.3c]\n\n", 'a', 'b', 'c', 'd', 'e');
    38                
    39                 printf("Testing printf(\"%%d %%3.2d %%-3.2d %%2.3d %%-2.3d\", 1, 2, 3, 4, 5):\n");
    40                 printf("Expected output: [1] [ 02] [03 ] [004] [005]\n");
    41                 printf("Real output:     [%d] [%3.2d] [%-3.2d] [%2.3d] [%-2.3d]\n\n", 1, 2, 3, 4, 5);
    42                
    43                 printf("Testing printf(\"%%d %%3.2d %%-3.2d %%2.3d %%-2.3d\", -1, -2, -3, -4, -5):\n");
    44                 printf("Expected output: [-1] [-02] [-03] [-004] [-005]\n");
    45                 printf("Real output:     [%d] [%3.2d] [%-3.2d] [%2.3d] [%-2.3d]\n\n", -1, -2, -3, -4, -5);
    46                
    47                 printf("Testing printf(\"%%#x %%5.3#x %%-5.3#x %%3.5#x %%-3.5#x\", 17, 18, 19, 20, 21):\n");
    48                 printf("Expected output: [0x11] [0x012] [0x013] [0x00014] [0x00015]\n");
    49                 printf("Real output:     [%#x] [%#5.3x] [%#-5.3x] [%#3.5x] [%#-3.5x]\n\n", 17, 18, 19, 20, 21);
    50                
    51                 unative_t nat = 0x12345678u;
    52                
    53                 printf("Testing printf(\"%%#" PRIx64 " %%#" PRIx32 " %%#" PRIx16 " %%#" PRIx8 " %%#" PRIxn " %%#" PRIx64 " %%s\", 0x1234567887654321ll, 0x12345678, 0x1234, 0x12, nat, 0x1234567887654321ull, \"Lovely string\"):\n");
    54                 printf("Expected output: [0x1234567887654321] [0x12345678] [0x1234] [0x12] [0x12345678] [0x1234567887654321] \"Lovely string\"\n");
    55                 printf("Real output:     [%#" PRIx64 "] [%#" PRIx32 "] [%#" PRIx16 "] [%#" PRIx8 "] [%#" PRIxn "] [%#" PRIx64 "] \"%s\"\n\n", 0x1234567887654321ll, 0x12345678, 0x1234, 0x12, nat, 0x1234567887654321ull, "Lovely string");
    56         }
     34        TPRINTF("Testing printf(\"%%c %%3.2c %%-3.2c %%2.3c %%-2.3c\", 'a', 'b', 'c', 'd', 'e'):\n");
     35        TPRINTF("Expected output: [a] [  b] [c  ] [ d] [e ]\n");
     36        TPRINTF("Real output:     [%c] [%3.2c] [%-3.2c] [%2.3c] [%-2.3c]\n\n", 'a', 'b', 'c', 'd', 'e');
     37       
     38        TPRINTF("Testing printf(\"%%d %%3.2d %%-3.2d %%2.3d %%-2.3d\", 1, 2, 3, 4, 5):\n");
     39        TPRINTF("Expected output: [1] [ 02] [03 ] [004] [005]\n");
     40        TPRINTF("Real output:     [%d] [%3.2d] [%-3.2d] [%2.3d] [%-2.3d]\n\n", 1, 2, 3, 4, 5);
     41       
     42        TPRINTF("Testing printf(\"%%d %%3.2d %%-3.2d %%2.3d %%-2.3d\", -1, -2, -3, -4, -5):\n");
     43        TPRINTF("Expected output: [-1] [-02] [-03] [-004] [-005]\n");
     44        TPRINTF("Real output:     [%d] [%3.2d] [%-3.2d] [%2.3d] [%-2.3d]\n\n", -1, -2, -3, -4, -5);
     45       
     46        TPRINTF("Testing printf(\"%%#x %%5.3#x %%-5.3#x %%3.5#x %%-3.5#x\", 17, 18, 19, 20, 21):\n");
     47        TPRINTF("Expected output: [0x11] [0x012] [0x013] [0x00014] [0x00015]\n");
     48        TPRINTF("Real output:     [%#x] [%#5.3x] [%#-5.3x] [%#3.5x] [%#-3.5x]\n\n", 17, 18, 19, 20, 21);
     49       
     50        unative_t nat = 0x12345678u;
     51       
     52        TPRINTF("Testing printf(\"%%#" PRIx64 " %%#" PRIx32 " %%#" PRIx16 " %%#" PRIx8 " %%#" PRIxn " %%#" PRIx64 " %%s\", 0x1234567887654321ll, 0x12345678, 0x1234, 0x12, nat, 0x1234567887654321ull, \"Lovely string\"):\n");
     53        TPRINTF("Expected output: [0x1234567887654321] [0x12345678] [0x1234] [0x12] [0x12345678] [0x1234567887654321] \"Lovely string\"\n");
     54        TPRINTF("Real output:     [%#" PRIx64 "] [%#" PRIx32 "] [%#" PRIx16 "] [%#" PRIx8 "] [%#" PRIxn "] [%#" PRIx64 "] \"%s\"\n\n", 0x1234567887654321ll, 0x12345678, 0x1234, 0x12, nat, 0x1234567887654321ull, "Lovely string");
    5755       
    5856        return NULL;
  • kernel/test/print/print3.c

    r171f9a1 rcb01e1e  
    3333#define BUFFER_SIZE  32
    3434
    35 char *test_print3(bool quiet)
     35char *test_print3(void)
    3636{
    37         if (!quiet) {
    38                 char buffer[BUFFER_SIZE];
    39                 int retval;
    40                
    41                 printf("Testing snprintf(buffer, " STRING(BUFFER_SIZE) ", \"Short text without parameters.\"):\n");
    42                 printf("Expected result: retval=30 buffer=\"Short text without parameters.\"\n");
    43                 retval = snprintf(buffer, BUFFER_SIZE, "Short text without parameters.");
    44                 printf("Real result:     retval=%d buffer=\"%s\"\n\n", retval, buffer);
    45                
    46                 printf("Testing snprintf(buffer, " STRING(BUFFER_SIZE) ", \"Very very very long text without parameters.\"):\n");
    47                 printf("Expected result: retval=44 buffer=\"Very very very long text withou\"\n");
    48                 retval = snprintf(buffer, BUFFER_SIZE, "Very very very long text without parameters.");
    49                 printf("Real result:     retval=%d buffer=\"%s\"\n\n", retval, buffer);
    50                
    51                 printf("Testing snprintf(buffer, " STRING(BUFFER_SIZE) ", \"Short %%s.\", \"text\"):\n");
    52                 printf("Expected result: retval=11 buffer=\"Short text.\"\n");
    53                 retval = snprintf(buffer, BUFFER_SIZE, "Short %s.", "text");
    54                 printf("Real result:     retval=%d buffer=\"%s\"\n\n", retval, buffer);
    55                
    56                 printf("Testing snprintf(buffer, " STRING(BUFFER_SIZE) ", \"Very long %%s. This text's length is more than %%d. We are interested in the result.\", \"text\", " STRING(BUFFER_SIZE) "):\n");
    57                 printf("Expected result: retval=84 buffer=\"Very long text. This text's len\"\n");
    58                 retval = snprintf(buffer, BUFFER_SIZE, "Very long %s. This text's length is more than %d. We are interested in the result.", "text", BUFFER_SIZE);
    59                 printf("Real result:     retval=%d buffer=\"%s\"\n\n", retval, buffer);
    60         }
     37        char buffer[BUFFER_SIZE];
     38        int retval;
     39       
     40        TPRINTF("Testing snprintf(buffer, " STRING(BUFFER_SIZE) ", \"Short text without parameters.\"):\n");
     41        TPRINTF("Expected result: retval=30 buffer=\"Short text without parameters.\"\n");
     42        retval = snprintf(buffer, BUFFER_SIZE, "Short text without parameters.");
     43        TPRINTF("Real result:     retval=%d buffer=\"%s\"\n\n", retval, buffer);
     44       
     45        TPRINTF("Testing snprintf(buffer, " STRING(BUFFER_SIZE) ", \"Very very very long text without parameters.\"):\n");
     46        TPRINTF("Expected result: retval=44 buffer=\"Very very very long text withou\"\n");
     47        retval = snprintf(buffer, BUFFER_SIZE, "Very very very long text without parameters.");
     48        TPRINTF("Real result:     retval=%d buffer=\"%s\"\n\n", retval, buffer);
     49       
     50        TPRINTF("Testing snprintf(buffer, " STRING(BUFFER_SIZE) ", \"Short %%s.\", \"text\"):\n");
     51        TPRINTF("Expected result: retval=11 buffer=\"Short text.\"\n");
     52        retval = snprintf(buffer, BUFFER_SIZE, "Short %s.", "text");
     53        TPRINTF("Real result:     retval=%d buffer=\"%s\"\n\n", retval, buffer);
     54       
     55        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");
     56        TPRINTF("Expected result: retval=84 buffer=\"Very long text. This text's len\"\n");
     57        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);
     58        TPRINTF("Real result:     retval=%d buffer=\"%s\"\n\n", retval, buffer);
    6159       
    6260        return NULL;
  • kernel/test/print/print4.c

    r171f9a1 rcb01e1e  
    3030#include <test.h>
    3131
    32 char *test_print4(bool quiet)
     32char *test_print4(void)
    3333{
    34         if (!quiet) {
    35                 printf("ASCII printable characters (32 - 127) using printf(\"%%c\") and printf(\"%%lc\"):\n");
     34        TPRINTF("ASCII printable characters (32 - 127) using printf(\"%%c\") and printf(\"%%lc\"):\n");
     35       
     36        uint8_t group;
     37        for (group = 1; group < 4; group++) {
     38                TPRINTF("%#" PRIx8 ": ", group << 5);
    3639               
    37                 uint8_t group;
    38                 for (group = 1; group < 4; group++) {
    39                         printf("%#" PRIx8 ": ", group << 5);
    40                        
    41                         uint8_t index;
    42                         for (index = 0; index < 32; index++)
    43                                 printf("%c", (char) ((group << 5) + index));
    44                        
    45                         printf("  ");
    46                         for (index = 0; index < 32; index++)
    47                                 printf("%lc", (wchar_t) ((group << 5) + index));
    48                        
    49                         printf("\n");
    50                 }
     40                uint8_t index;
     41                for (index = 0; index < 32; index++)
     42                        TPRINTF("%c", (char) ((group << 5) + index));
    5143               
    52                 printf("\nExtended ASCII characters (128 - 255) using printf(\"%%lc\"):\n");
     44                TPRINTF("  ");
     45                for (index = 0; index < 32; index++)
     46                        TPRINTF("%lc", (wchar_t) ((group << 5) + index));
    5347               
    54                 for (group = 4; group < 8; group++) {
    55                         printf("%#" PRIx8 ": ", group << 5);
    56                        
    57                         uint8_t index;
    58                         for (index = 0; index < 32; index++)
    59                                 printf("%lc", (wchar_t) ((group << 5) + index));
    60                        
    61                         printf("\n");
    62                 }
     48                TPRINTF("\n");
     49        }
     50       
     51        TPRINTF("\nExtended ASCII characters (128 - 255) using printf(\"%%lc\"):\n");
     52       
     53        for (group = 4; group < 8; group++) {
     54                TPRINTF("%#" PRIx8 ": ", group << 5);
    6355               
    64                 printf("\nUTF-8 strings using printf(\"%%s\"):\n");
    65                 printf("English:  %s\n", "Quick brown fox jumps over the lazy dog");
    66                 printf("Czech:    %s\n", "Příliš žluťoučký kůň úpěl ďábelské ódy");
    67                 printf("Greek:    %s\n", "Ὦ ξεῖν’, ἀγγέλλειν Λακεδαιμονίοις ὅτι τῇδε");
    68                 printf("Hebrew:   %s\n", "משוואת ברנולי היא משוואה בהידרודינמיקה");
    69                 printf("Arabic:   %s\n", "التوزيع الجغرافي للحمل العنقودي");
    70                 printf("Russian:  %s\n", "Леннон познакомился с художницей-авангардисткой");
    71                 printf("Armenian: %s\n", "Սկսեց հրատարակվել Երուսաղեմի հայկական");
     56                uint8_t index;
     57                for (index = 0; index < 32; index++)
     58                        TPRINTF("%lc", (wchar_t) ((group << 5) + index));
    7259               
    73                 printf("\nUTF-32 strings using printf(\"%%ls\"):\n");
    74                 printf("English:  %ls\n", L"Quick brown fox jumps over the lazy dog");
    75                 printf("Czech:    %ls\n", L"Příliš žluťoučký kůň úpěl ďábelské ódy");
    76                 printf("Greek:    %ls\n", L"Ὦ ξεῖν’, ἀγγέλλειν Λακεδαιμονίοις ὅτι τῇδε");
    77                 printf("Hebrew:   %ls\n", L"משוואת ברנולי היא משוואה בהידרודינמיקה");
    78                 printf("Arabic:   %ls\n", L"التوزيع الجغرافي للحمل العنقودي");
    79                 printf("Russian:  %ls\n", L"Леннон познакомился с художницей-авангардисткой");
    80                 printf("Armenian: %ls\n", L"Սկսեց հրատարակվել Երուսաղեմի հայկական");
     60                TPRINTF("\n");
    8161        }
     62       
     63        TPRINTF("\nUTF-8 strings using printf(\"%%s\"):\n");
     64        TPRINTF("English:  %s\n", "Quick brown fox jumps over the lazy dog");
     65        TPRINTF("Czech:    %s\n", "Příliš žluťoučký kůň úpěl ďábelské ódy");
     66        TPRINTF("Greek:    %s\n", "Ὦ ξεῖν’, ἀγγέλλειν Λακεδαιμονίοις ὅτι τῇδε");
     67        TPRINTF("Hebrew:   %s\n", "משוואת ברנולי היא משוואה בהידרודינמיקה");
     68        TPRINTF("Arabic:   %s\n", "التوزيع الجغرافي للحمل العنقودي");
     69        TPRINTF("Russian:  %s\n", "Леннон познакомился с художницей-авангардисткой");
     70        TPRINTF("Armenian: %s\n", "Սկսեց հրատարակվել Երուսաղեմի հայկական");
     71       
     72        TPRINTF("\nUTF-32 strings using printf(\"%%ls\"):\n");
     73        TPRINTF("English:  %ls\n", L"Quick brown fox jumps over the lazy dog");
     74        TPRINTF("Czech:    %ls\n", L"Příliš žluťoučký kůň úpěl ďábelské ódy");
     75        TPRINTF("Greek:    %ls\n", L"Ὦ ξεῖν’, ἀγγέλλειν Λακεδαιμονίοις ὅτι τῇδε");
     76        TPRINTF("Hebrew:   %ls\n", L"משוואת ברנולי היא משוואה בהידרודינמיקה");
     77        TPRINTF("Arabic:   %ls\n", L"التوزيع الجغرافي للحمل العنقودي");
     78        TPRINTF("Russian:  %ls\n", L"Леннон познакомился с художницей-авангардисткой");
     79        TPRINTF("Armenian: %ls\n", L"Սկսեց հրատարակվել Երուսաղեմի հայկական");
    8280       
    8381        return NULL;
  • kernel/test/synch/rwlock1.c

    r171f9a1 rcb01e1e  
    3636#include <synch/rwlock.h>
    3737
    38 #define READERS         50
    39 #define WRITERS         50
     38#define READERS  50
     39#define WRITERS  50
    4040
    4141static rwlock_t rwlock;
    4242
    43 char * test_rwlock1(bool quiet)
     43char *test_rwlock1(void)
    4444{
    4545        rwlock_initialize(&rwlock);
    46 
     46       
    4747        rwlock_write_lock(&rwlock);
    48         rwlock_write_unlock(&rwlock);   
    49 
    50         rwlock_read_lock(&rwlock);
    51         rwlock_read_lock(&rwlock);     
     48        rwlock_write_unlock(&rwlock);
     49       
    5250        rwlock_read_lock(&rwlock);
    5351        rwlock_read_lock(&rwlock);
    5452        rwlock_read_lock(&rwlock);
    55 
     53        rwlock_read_lock(&rwlock);
     54        rwlock_read_lock(&rwlock);
     55       
    5656        rwlock_read_unlock(&rwlock);
    57         rwlock_read_unlock(&rwlock);   
     57        rwlock_read_unlock(&rwlock);
    5858        rwlock_read_unlock(&rwlock);
    5959        rwlock_read_unlock(&rwlock);
     
    6161       
    6262        rwlock_write_lock(&rwlock);
    63         rwlock_write_unlock(&rwlock);   
    64 
     63        rwlock_write_unlock(&rwlock);
     64       
    6565        rwlock_read_lock(&rwlock);
    6666        rwlock_read_unlock(&rwlock);
    67 
     67       
    6868        rwlock_write_lock(&rwlock);
    69         rwlock_write_unlock(&rwlock);   
    70 
     69        rwlock_write_unlock(&rwlock);
     70       
    7171        rwlock_read_lock(&rwlock);
    7272        rwlock_read_unlock(&rwlock);
  • kernel/test/synch/rwlock2.c

    r171f9a1 rcb01e1e  
    3535#include <synch/rwlock.h>
    3636
    37 #define READERS         50
    38 #define WRITERS         50
     37#define READERS  50
     38#define WRITERS  50
    3939
    4040static rwlock_t rwlock;
    41 static bool sh_quiet;
    4241
    4342static void writer(void *arg)
    4443{
    45         if (!sh_quiet)
    46                 printf("Trying to lock rwlock for writing....\n");
     44        TPRINTF("Trying to lock rwlock for writing....\n");
    4745       
    4846        rwlock_write_lock(&rwlock);
    4947        rwlock_write_unlock(&rwlock);
    5048       
    51         if (!sh_quiet)
    52                 printf("Trying to lock rwlock for reading....\n");
     49        TPRINTF("Trying to lock rwlock for reading....\n");
    5350       
    5451        rwlock_read_lock(&rwlock);
    55         rwlock_read_unlock(&rwlock);   
     52        rwlock_read_unlock(&rwlock);
    5653}
    5754
    58 char * test_rwlock2(bool quiet)
     55char *test_rwlock2(void)
    5956{
    6057        thread_t *thrd;
    61         sh_quiet = quiet;
    6258       
    6359        rwlock_initialize(&rwlock);
    64 
     60       
    6561        rwlock_read_lock(&rwlock);
    6662        rwlock_read_lock(&rwlock);
    6763        rwlock_read_lock(&rwlock);
    68         rwlock_read_lock(&rwlock);     
     64        rwlock_read_lock(&rwlock);
    6965       
    7066        thrd = thread_create(writer, NULL, TASK, 0, "writer", false);
     
    7369        else
    7470                return "Could not create thread";
    75 
     71       
    7672        thread_sleep(1);
    7773       
  • kernel/test/synch/rwlock3.c

    r171f9a1 rcb01e1e  
    3535#include <synch/rwlock.h>
    3636
    37 #define THREADS 4
     37#define THREADS  4
    3838
    3939static atomic_t thread_count;
    4040static rwlock_t rwlock;
    41 static bool sh_quiet;
    4241
    4342static void reader(void *arg)
     
    4544        thread_detach(THREAD);
    4645       
    47         if (!sh_quiet)
    48                 printf("cpu%u, tid %" PRIu64 ": trying to lock rwlock for reading....\n", CPU->id, THREAD->tid);
     46        TPRINTF("cpu%u, tid %" PRIu64 ": trying to lock rwlock for reading....\n", CPU->id, THREAD->tid);
    4947       
    5048        rwlock_read_lock(&rwlock);
    5149        rwlock_read_unlock(&rwlock);
    5250       
    53         if (!sh_quiet) {
    54                 printf("cpu%u, tid %" PRIu64 ": success\n", CPU->id, THREAD->tid);             
    55                 printf("cpu%u, tid %" PRIu64 ": trying to lock rwlock for writing....\n", CPU->id, THREAD->tid);       
    56         }
    57 
     51        TPRINTF("cpu%u, tid %" PRIu64 ": success\n", CPU->id, THREAD->tid);
     52        TPRINTF("cpu%u, tid %" PRIu64 ": trying to lock rwlock for writing....\n", CPU->id, THREAD->tid);
     53       
    5854        rwlock_write_lock(&rwlock);
    5955        rwlock_write_unlock(&rwlock);
    6056       
    61         if (!sh_quiet)
    62                 printf("cpu%u, tid %" PRIu64 ": success\n", CPU->id, THREAD->tid);
     57        TPRINTF("cpu%u, tid %" PRIu64 ": success\n", CPU->id, THREAD->tid);
    6358       
    6459        atomic_dec(&thread_count);
    6560}
    6661
    67 char * test_rwlock3(bool quiet)
     62char *test_rwlock3(void)
    6863{
    6964        int i;
    7065        thread_t *thrd;
    71         sh_quiet = quiet;
    7266       
    7367        atomic_set(&thread_count, THREADS);
     
    8074                if (thrd)
    8175                        thread_ready(thrd);
    82                 else if (!quiet)
    83                         printf("Could not create reader %d\n", i);
     76                else
     77                        TPRINTF("Could not create reader %d\n", i);
    8478        }
    85 
     79       
    8680        thread_sleep(1);
    8781        rwlock_write_unlock(&rwlock);
    8882       
    8983        while (atomic_get(&thread_count) > 0) {
    90                 if (!quiet)
    91                         printf("Threads left: %ld\n", atomic_get(&thread_count));
     84                TPRINTF("Threads left: %ld\n", atomic_get(&thread_count));
    9285                thread_sleep(1);
    9386        }
  • kernel/test/synch/rwlock4.c

    r171f9a1 rcb01e1e  
    4141#include <synch/spinlock.h>
    4242
    43 #define READERS         50
    44 #define WRITERS         50
     43#define READERS  50
     44#define WRITERS  50
    4545
    4646static atomic_t thread_count;
    4747static rwlock_t rwlock;
    4848static atomic_t threads_fault;
    49 static bool sh_quiet;
    5049
    5150SPINLOCK_INITIALIZE(rw_lock);
     
    5857{
    5958        uint32_t rc;
    60 
    61         spinlock_lock(&rw_lock);       
     59       
     60        spinlock_lock(&rw_lock);
    6261        rc = seed % max;
    6362        seed = (((seed << 2) ^ (seed >> 2)) * 487) + rc;
     
    7170        thread_detach(THREAD);
    7271        waitq_sleep(&can_start);
    73 
     72       
    7473        to = random(40000);
    7574       
    76         if (!sh_quiet)
    77                 printf("cpu%u, tid %" PRIu64 " w+ (%d)\n", CPU->id, THREAD->tid, to);
     75        TPRINTF("cpu%u, tid %" PRIu64 " w+ (%d)\n", CPU->id, THREAD->tid, to);
    7876       
    7977        rc = rwlock_write_lock_timeout(&rwlock, to);
    8078        if (SYNCH_FAILED(rc)) {
    81                 if (!sh_quiet)
    82                         printf("cpu%u, tid %" PRIu64 " w!\n", CPU->id, THREAD->tid);
     79                TPRINTF("cpu%u, tid %" PRIu64 " w!\n", CPU->id, THREAD->tid);
    8380                atomic_dec(&thread_count);
    8481                return;
    8582        }
    8683       
    87         if (!sh_quiet)
    88                 printf("cpu%u, tid %" PRIu64 " w=\n", CPU->id, THREAD->tid);
    89 
     84        TPRINTF("cpu%u, tid %" PRIu64 " w=\n", CPU->id, THREAD->tid);
     85       
    9086        if (rwlock.readers_in) {
    91                 if (!sh_quiet)
    92                         printf("Oops.");
     87                TPRINTF("Oops.\n");
    9388                atomic_inc(&threads_fault);
    9489                atomic_dec(&thread_count);
    9590                return;
    9691        }
     92       
    9793        thread_usleep(random(1000000));
     94       
    9895        if (rwlock.readers_in) {
    99                 if (!sh_quiet)
    100                         printf("Oops.");       
     96                TPRINTF("Oops.\n");
    10197                atomic_inc(&threads_fault);
    10298                atomic_dec(&thread_count);
    10399                return;
    104100        }
    105 
     101       
    106102        rwlock_write_unlock(&rwlock);
    107103       
    108         if (!sh_quiet)
    109                 printf("cpu%u, tid %" PRIu64 " w-\n", CPU->id, THREAD->tid);
     104        TPRINTF("cpu%u, tid %" PRIu64 " w-\n", CPU->id, THREAD->tid);
    110105        atomic_dec(&thread_count);
    111106}
     
    119114        to = random(2000);
    120115       
    121         if (!sh_quiet)
    122                 printf("cpu%u, tid %" PRIu64 " r+ (%d)\n", CPU->id, THREAD->tid, to);
     116        TPRINTF("cpu%u, tid %" PRIu64 " r+ (%d)\n", CPU->id, THREAD->tid, to);
    123117       
    124118        rc = rwlock_read_lock_timeout(&rwlock, to);
    125119        if (SYNCH_FAILED(rc)) {
    126                 if (!sh_quiet)
    127                         printf("cpu%u, tid %" PRIu64 " r!\n", CPU->id, THREAD->tid);
     120                TPRINTF("cpu%u, tid %" PRIu64 " r!\n", CPU->id, THREAD->tid);
    128121                atomic_dec(&thread_count);
    129122                return;
    130123        }
    131124       
    132         if (!sh_quiet)
    133                 printf("cpu%u, tid %" PRIu64 " r=\n", CPU->id, THREAD->tid);
     125        TPRINTF("cpu%u, tid %" PRIu64 " r=\n", CPU->id, THREAD->tid);
    134126       
    135127        thread_usleep(30000);
    136128        rwlock_read_unlock(&rwlock);
    137129       
    138         if (!sh_quiet)
    139                 printf("cpu%u, tid %" PRIu64 " r-\n", CPU->id, THREAD->tid);
     130        TPRINTF("cpu%u, tid %" PRIu64 " r-\n", CPU->id, THREAD->tid);
    140131        atomic_dec(&thread_count);
    141132}
    142133
    143 char * test_rwlock4(bool quiet)
     134char *test_rwlock4(void)
    144135{
    145136        context_t ctx;
    146137        uint32_t i;
    147         sh_quiet = quiet;
    148138       
    149139        waitq_initialize(&can_start);
     
    159149       
    160150        context_save(&ctx);
    161         if (!quiet) {
    162                 printf("sp=%#x, readers_in=%" PRIc "\n", ctx.sp, rwlock.readers_in);
    163                 printf("Creating %" PRIu32 " readers\n", rd);
    164         }
     151        TPRINTF("sp=%#x, readers_in=%" PRIc "\n", ctx.sp, rwlock.readers_in);
     152        TPRINTF("Creating %" PRIu32 " readers\n", rd);
    165153       
    166154        for (i = 0; i < rd; i++) {
     
    168156                if (thrd)
    169157                        thread_ready(thrd);
    170                 else if (!quiet)
    171                         printf("Could not create reader %" PRIu32 "\n", i);
     158                else
     159                        TPRINTF("Could not create reader %" PRIu32 "\n", i);
    172160        }
    173 
    174         if (!quiet)
    175                 printf("Creating %" PRIu32 " writers\n", wr);
     161       
     162        TPRINTF("Creating %" PRIu32 " writers\n", wr);
    176163       
    177164        for (i = 0; i < wr; i++) {
     
    179166                if (thrd)
    180167                        thread_ready(thrd);
    181                 else if (!quiet)
    182                         printf("Could not create writer %" PRIu32 "\n", i);
     168                else
     169                        TPRINTF("Could not create writer %" PRIu32 "\n", i);
    183170        }
    184171       
     
    187174       
    188175        while (atomic_get(&thread_count) > 0) {
    189                 if (!quiet)
    190                         printf("Threads left: %ld\n", atomic_get(&thread_count));
     176                TPRINTF("Threads left: %ld\n", atomic_get(&thread_count));
    191177                thread_sleep(1);
    192178        }
  • kernel/test/synch/rwlock5.c

    r171f9a1 rcb01e1e  
    3636#include <synch/rwlock.h>
    3737
    38 #define READERS         50
    39 #define WRITERS         50
     38#define READERS  50
     39#define WRITERS  50
    4040
    4141static rwlock_t rwlock;
     
    4848{
    4949        thread_detach(THREAD);
    50 
     50       
    5151        waitq_sleep(&can_start);
    52 
     52       
    5353        rwlock_write_lock(&rwlock);
    5454        atomic_inc(&items_written);
     
    5959{
    6060        thread_detach(THREAD);
    61 
     61       
    6262        waitq_sleep(&can_start);
    6363       
     
    6767}
    6868
    69 char * test_rwlock5(bool quiet)
     69char *test_rwlock5(void)
    7070{
    7171        int i, j, k;
     
    7777        for (i = 1; i <= 3; i++) {
    7878                thread_t *thrd;
    79 
     79               
    8080                atomic_set(&items_read, 0);
    8181                atomic_set(&items_written, 0);
    82 
     82               
    8383                readers = i * READERS;
    8484                writers = (4 - i) * WRITERS;
    85 
    86                 printf("Creating %ld readers and %ld writers...", readers, writers);
     85               
     86                TPRINTF("Creating %ld readers and %ld writers...", readers, writers);
    8787               
    8888                for (j = 0; j < (READERS + WRITERS) / 2; j++) {
     
    9292                                        thread_ready(thrd);
    9393                                else
    94                                         printf("Could not create reader %d\n", k);
     94                                        TPRINTF("Could not create reader %d\n", k);
    9595                        }
    9696                        for (k = 0; k < (4 - i); k++) {
     
    9999                                        thread_ready(thrd);
    100100                                else
    101                                         printf("Could not create writer %d\n", k);
     101                                        TPRINTF("Could not create writer %d\n", k);
    102102                        }
    103103                }
    104 
    105                 printf("ok\n");
    106 
     104               
     105                TPRINTF("ok\n");
     106               
    107107                thread_sleep(1);
    108108                waitq_wakeup(&can_start, WAKEUP_ALL);
    109        
     109               
    110110                while ((items_read.count != readers) || (items_written.count != writers)) {
    111                         printf("%d readers remaining, %d writers remaining, readers_in=%d\n", readers - items_read.count, writers - items_written.count, rwlock.readers_in);
     111                        TPRINTF("%d readers remaining, %d writers remaining, readers_in=%d\n", readers - items_read.count, writers - items_written.count, rwlock.readers_in);
    112112                        thread_usleep(100000);
    113113                }
  • kernel/test/synch/semaphore1.c

    r171f9a1 rcb01e1e  
    3636#include <synch/semaphore.h>
    3737
    38 #define AT_ONCE                 3
    39 #define PRODUCERS               50
    40 #define CONSUMERS               50
     38#define AT_ONCE    3
     39#define PRODUCERS  50
     40#define CONSUMERS  50
    4141
    4242static semaphore_t sem;
     
    4848static void producer(void *arg)
    4949{
    50         thread_detach(THREAD); 
    51 
     50        thread_detach(THREAD);
     51       
    5252        waitq_sleep(&can_start);
    53            
     53       
    5454        semaphore_down(&sem);
    5555        atomic_inc(&items_produced);
     
    6060static void consumer(void *arg)
    6161{
    62         thread_detach(THREAD); 
     62        thread_detach(THREAD);
    6363       
    6464        waitq_sleep(&can_start);
     
    7070}
    7171
    72 char * test_semaphore1(bool quiet)
     72char *test_semaphore1(void)
    7373{
    7474        int i, j, k;
     
    7777        waitq_initialize(&can_start);
    7878        semaphore_initialize(&sem, AT_ONCE);
    79 
     79       
    8080        for (i = 1; i <= 3; i++) {
    8181                thread_t *thrd;
    82 
     82               
    8383                atomic_set(&items_produced, 0);
    8484                atomic_set(&items_consumed, 0);
     
    8787                producers = (4 - i) * PRODUCERS;
    8888               
    89                 printf("Creating %d consumers and %d producers...", consumers, producers);
    90        
     89                TPRINTF("Creating %d consumers and %d producers...", consumers, producers);
     90               
    9191                for (j = 0; j < (CONSUMERS + PRODUCERS) / 2; j++) {
    9292                        for (k = 0; k < i; k++) {
     
    9595                                        thread_ready(thrd);
    9696                                else
    97                                         printf("could not create consumer %d\n", i);
     97                                        TPRINTF("could not create consumer %d\n", i);
    9898                        }
    9999                        for (k = 0; k < (4 - i); k++) {
     
    102102                                        thread_ready(thrd);
    103103                                else
    104                                         printf("could not create producer %d\n", i);
     104                                        TPRINTF("could not create producer %d\n", i);
    105105                        }
    106106                }
    107 
    108                 printf("ok\n");
    109 
     107               
     108                TPRINTF("ok\n");
     109               
    110110                thread_sleep(1);
    111111                waitq_wakeup(&can_start, WAKEUP_ALL);
    112        
     112               
    113113                while ((items_consumed.count != consumers) || (items_produced.count != producers)) {
    114                         printf("%d consumers remaining, %d producers remaining\n", consumers - items_consumed.count, producers - items_produced.count);
     114                        TPRINTF("%d consumers remaining, %d producers remaining\n", consumers - items_consumed.count, producers - items_produced.count);
    115115                        thread_sleep(1);
    116116                }
  • kernel/test/synch/semaphore2.c

    r171f9a1 rcb01e1e  
    5151{
    5252        uint32_t rc;
    53 
    54         spinlock_lock(&sem_lock);       
     53       
     54        spinlock_lock(&sem_lock);
    5555        rc = seed % max;
    5656        seed = (((seed << 2) ^ (seed >> 2)) * 487) + rc;
     
    6868       
    6969        to = random(20000);
    70         printf("cpu%u, tid %" PRIu64 " down+ (%d)\n", CPU->id, THREAD->tid, to);
     70        TPRINTF("cpu%u, tid %" PRIu64 " down+ (%d)\n", CPU->id, THREAD->tid, to);
    7171        rc = semaphore_down_timeout(&sem, to);
    7272        if (SYNCH_FAILED(rc)) {
    73                 printf("cpu%u, tid %" PRIu64 " down!\n", CPU->id, THREAD->tid);
     73                TPRINTF("cpu%u, tid %" PRIu64 " down!\n", CPU->id, THREAD->tid);
    7474                return;
    7575        }
    7676       
    77         printf("cpu%u, tid %" PRIu64 " down=\n", CPU->id, THREAD->tid);
     77        TPRINTF("cpu%u, tid %" PRIu64 " down=\n", CPU->id, THREAD->tid);       
    7878        thread_usleep(random(30000));
    7979       
    8080        semaphore_up(&sem);
    81         printf("cpu%u, tid %" PRIu64 " up\n", CPU->id, THREAD->tid);
     81        TPRINTF("cpu%u, tid %" PRIu64 " up\n", CPU->id, THREAD->tid);
    8282}
    8383
    84 char * test_semaphore2(bool quiet)
     84char *test_semaphore2(void)
    8585{
    8686        uint32_t i, k;
     
    9292       
    9393        k = random(7) + 1;
    94         printf("Creating %" PRIu32 " consumers\n", k);
     94        TPRINTF("Creating %" PRIu32 " consumers\n", k);
    9595        for (i = 0; i < k; i++) {
    9696                thrd = thread_create(consumer, NULL, TASK, 0, "consumer", false);
     
    9898                        thread_ready(thrd);
    9999                else
    100                         printf("Error creating thread\n");
     100                        TPRINTF("Error creating thread\n");
    101101        }
    102102       
  • kernel/test/sysinfo/sysinfo1.c

    r171f9a1 rcb01e1e  
    3333#include <sysinfo/sysinfo.h>
    3434
    35 char * test_sysinfo1(bool quiet)
     35char *test_sysinfo1(void)
    3636{
    37         if (!quiet)
     37        if (!test_quiet)
    3838                sysinfo_dump(NULL, 0);
    3939        return NULL;
  • kernel/test/test.c

    r171f9a1 rcb01e1e  
    3434
    3535#include <test.h>
     36
     37bool test_quiet;
    3638
    3739test_t tests[] = {
  • kernel/test/test.h

    r171f9a1 rcb01e1e  
    3939#include <typedefs.h>
    4040
    41 typedef char *(*test_entry_t)(bool);
     41extern bool test_quiet;
     42
     43#define TPRINTF(format, ...) \
     44        { \
     45                if (!test_quiet) { \
     46                        printf(format, ##__VA_ARGS__); \
     47                } \
     48        }
     49
     50typedef char *(*test_entry_t)(void);
    4251
    4352typedef struct {
     
    4857} test_t;
    4958
    50 extern char *test_atomic1(bool quiet);
    51 extern char *test_avltree1(bool quiet);
    52 extern char *test_btree1(bool quiet);
    53 extern char *test_mips1(bool quiet);
    54 extern char *test_fault1(bool quiet);
    55 extern char *test_fpu1(bool quiet);
    56 extern char *test_sse1(bool quiet);
    57 extern char *test_mips2(bool quiet);
    58 extern char *test_falloc1(bool quiet);
    59 extern char *test_falloc2(bool quiet);
    60 extern char *test_mapping1(bool quiet);
    61 extern char *test_purge1(bool quiet);
    62 extern char *test_slab1(bool quiet);
    63 extern char *test_slab2(bool quiet);
    64 extern char *test_rwlock1(bool quiet);
    65 extern char *test_rwlock2(bool quiet);
    66 extern char *test_rwlock3(bool quiet);
    67 extern char *test_rwlock4(bool quiet);
    68 extern char *test_rwlock5(bool quiet);
    69 extern char *test_semaphore1(bool quiet);
    70 extern char *test_semaphore2(bool quiet);
    71 extern char *test_print1(bool quiet);
    72 extern char *test_print2(bool quiet);
    73 extern char *test_print3(bool quiet);
    74 extern char *test_print4(bool quiet);
    75 extern char *test_thread1(bool quiet);
    76 extern char *test_sysinfo1(bool quiet);
     59extern char *test_atomic1(void);
     60extern char *test_avltree1(void);
     61extern char *test_btree1(void);
     62extern char *test_mips1(void);
     63extern char *test_fault1(void);
     64extern char *test_fpu1(void);
     65extern char *test_sse1(void);
     66extern char *test_mips2(void);
     67extern char *test_falloc1(void);
     68extern char *test_falloc2(void);
     69extern char *test_mapping1(void);
     70extern char *test_purge1(void);
     71extern char *test_slab1(void);
     72extern char *test_slab2(void);
     73extern char *test_rwlock1(void);
     74extern char *test_rwlock2(void);
     75extern char *test_rwlock3(void);
     76extern char *test_rwlock4(void);
     77extern char *test_rwlock5(void);
     78extern char *test_semaphore1(void);
     79extern char *test_semaphore2(void);
     80extern char *test_print1(void);
     81extern char *test_print2(void);
     82extern char *test_print3(void);
     83extern char *test_print4(void);
     84extern char *test_thread1(void);
     85extern char *test_sysinfo1(void);
    7786
    7887extern test_t tests[];
  • kernel/test/thread/thread1.c

    r171f9a1 rcb01e1e  
    3737#include <arch.h>
    3838
    39 #define THREADS 5
     39#define THREADS  5
    4040
    4141static atomic_t finish;
    4242static atomic_t threads_finished;
    43 static bool sh_quiet;
    4443
    4544static void threadtest(void *data)
    4645{
    47         thread_detach(THREAD); 
    48 
     46        thread_detach(THREAD);
     47       
    4948        while (atomic_get(&finish)) {
    50                 if (!sh_quiet)
    51                         printf("%" PRIu64 " ", THREAD->tid);
     49                TPRINTF("%" PRIu64 " ", THREAD->tid);
    5250                thread_usleep(100000);
    5351        }
     
    5553}
    5654
    57 char * test_thread1(bool quiet)
     55char *test_thread1(void)
    5856{
    5957        unsigned int i, total = 0;
    60         sh_quiet = quiet;
    6158       
    6259        atomic_set(&finish, 1);
    6360        atomic_set(&threads_finished, 0);
    64 
     61       
    6562        for (i = 0; i < THREADS; i++) { 
    6663                thread_t *t;
    6764                if (!(t = thread_create(threadtest, NULL, TASK, 0, "threadtest", false))) {
    68                         if (!quiet)
    69                                 printf("Could not create thread %d\n", i);
     65                        TPRINTF("Could not create thread %d\n", i);
    7066                        break;
    7167                }
     
    7470        }
    7571       
    76         if (!quiet)
    77                 printf("Running threads for 10 seconds...\n");
     72        TPRINTF("Running threads for 10 seconds...\n");
    7873        thread_sleep(10);
    7974       
    8075        atomic_set(&finish, 0);
    8176        while (atomic_get(&threads_finished) < ((long) total)) {
    82                 if (!quiet)
    83                         printf("Threads left: %d\n", total - atomic_get(&threads_finished));
     77                TPRINTF("Threads left: %d\n", total - atomic_get(&threads_finished));
    8478                thread_sleep(1);
    8579        }
Note: See TracChangeset for help on using the changeset viewer.