Changeset deada67 in mainline for kernel/test/mm/slab1.c


Ignore:
Timestamp:
2006-12-19T17:54:50Z (19 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
730376d
Parents:
6536a4a9
Message:

quiet variants of tests

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/test/mm/slab1.c

    r6536a4a9 rdeada67  
    3838static void * data[VAL_COUNT];
    3939
    40 static void testit(int size, int count)
     40static void testit(int size, int count, bool quiet)
    4141{
    4242        slab_cache_t *cache;
    4343        int i;
    4444       
    45         printf("Creating cache, object size: %d.\n", size);
    46         cache = slab_cache_create("test_cache", size, 0, NULL, NULL,
    47                                   SLAB_CACHE_NOMAGAZINE);       
    48         printf("Allocating %d items...", count);
     45        if (!quiet)
     46                printf("Creating cache, object size: %d.\n", size);
     47       
     48        cache = slab_cache_create("test_cache", size, 0, NULL, NULL,
     49                                SLAB_CACHE_NOMAGAZINE);
     50       
     51        if (!quiet)
     52                printf("Allocating %d items...", count);
     53       
    4954        for (i = 0; i < count; i++) {
    5055                data[i] = slab_alloc(cache, 0);
    5156                memsetb((uintptr_t) data[i], size, 0);
    5257        }
    53         printf("done.\n");
    54         printf("Freeing %d items...", count);
    55         for (i = 0; i < count; i++) {
     58       
     59        if (!quiet) {
     60                printf("done.\n");
     61                printf("Freeing %d items...", count);
     62        }
     63       
     64        for (i = 0; i < count; i++)
    5665                slab_free(cache, data[i]);
     66       
     67        if (!quiet) {
     68                printf("done.\n");
     69                printf("Allocating %d items...", count);
    5770        }
    58         printf("done.\n");
    59 
    60         printf("Allocating %d items...", count);
     71       
    6172        for (i = 0; i < count; i++) {
    6273                data[i] = slab_alloc(cache, 0);
    6374                memsetb((uintptr_t) data[i], size, 0);
    6475        }
    65         printf("done.\n");
    66 
    67         printf("Freeing %d items...", count / 2);
    68         for (i = count - 1; i >= count / 2; i--) {
     76       
     77        if (!quiet) {
     78                printf("done.\n");
     79                printf("Freeing %d items...", count / 2);
     80        }
     81       
     82        for (i = count - 1; i >= count / 2; i--)
    6983                slab_free(cache, data[i]);
     84       
     85        if (!quiet) {
     86                printf("done.\n");     
     87                printf("Allocating %d items...", count / 2);
    7088        }
    71         printf("done.\n");     
    72 
    73         printf("Allocating %d items...", count / 2);
     89       
    7490        for (i = count / 2; i < count; i++) {
    7591                data[i] = slab_alloc(cache, 0);
    7692                memsetb((uintptr_t) data[i], size, 0);
    7793        }
    78         printf("done.\n");
    79         printf("Freeing %d items...", count);
    80         for (i = 0; i < count; i++) {
     94       
     95        if (!quiet) {
     96                printf("done.\n");
     97                printf("Freeing %d items...", count);
     98        }
     99       
     100        for (i = 0; i < count; i++)
    81101                slab_free(cache, data[i]);
    82         }
    83         printf("done.\n");     
     102       
     103        if (!quiet)
     104                printf("done.\n");     
    84105        slab_cache_destroy(cache);
    85 
    86         printf("Test complete.\n");
     106       
     107        if (!quiet)
     108                printf("Test complete.\n");
    87109}
    88110
    89 static void testsimple(void)
     111static void testsimple(bool quiet)
    90112{
    91         testit(100, VAL_COUNT);
    92         testit(200, VAL_COUNT);
    93         testit(1024, VAL_COUNT);
    94         testit(2048, 512);
    95         testit(4000, 128);
    96         testit(8192, 128);
    97         testit(16384, 128);
    98         testit(16385, 128);
     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);
    99121}
    100122
     
    106128static slab_cache_t *thr_cache;
    107129static semaphore_t thr_sem;
     130static bool sh_quiet;
    108131
    109132static void slabtest(void *data)
     
    114137        thread_detach(THREAD);
    115138       
    116         printf("Starting thread #%d...\n",THREAD->tid);
     139        if (!sh_quiet)
     140                printf("Starting thread #%d...\n", THREAD->tid);
     141       
    117142        for (j = 0; j < 10; j++) {
    118143                for (i = 0; i < THR_MEM_COUNT; i++)
     
    125150                        slab_free(thr_cache, thr_data[offs][i]);
    126151        }
    127         printf("Thread #%d finished\n", THREAD->tid);
     152       
     153        if (!sh_quiet)
     154                printf("Thread #%d finished\n", THREAD->tid);
     155       
    128156        semaphore_up(&thr_sem);
    129157}
    130158
    131 static void testthreads(void)
     159static void testthreads(bool quiet)
    132160{
    133161        thread_t *t;
    134162        int i;
    135163
    136         thr_cache = slab_cache_create("thread_cache", THR_MEM_SIZE, 0,
    137                                       NULL, NULL,
    138                                       SLAB_CACHE_NOMAGAZINE);
     164        thr_cache = slab_cache_create("thread_cache", THR_MEM_SIZE, 0, NULL, NULL,
     165                                        SLAB_CACHE_NOMAGAZINE);
    139166        semaphore_initialize(&thr_sem, 0);
    140167        for (i = 0; i < THREADS; i++) { 
    141                 if (!(t = thread_create(slabtest, (void *) (unative_t) i, TASK, 0, "slabtest", false)))
    142                         printf("Could not create thread %d\n", i);
    143                 else
     168                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);
     171                } else
    144172                        thread_ready(t);
    145173        }
     
    149177       
    150178        slab_cache_destroy(thr_cache);
    151         printf("Test complete.\n");
    152179       
     180        if (!quiet)
     181                printf("Test complete.\n");
    153182}
    154183
    155184char * test_slab1(bool quiet)
    156185{
    157         testsimple();
    158         testthreads();
     186        sh_quiet = quiet;
     187       
     188        testsimple(quiet);
     189        testthreads(quiet);
    159190       
    160191        return NULL;
Note: See TracChangeset for help on using the changeset viewer.