Changeset e6a78b9 in mainline for kernel/test


Ignore:
Timestamp:
2012-06-29T15:31:44Z (14 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
9432f08
Parents:
34ab31c0 (diff), 0bbd13e (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge mainline changes.

Location:
kernel/test
Files:
7 edited

Legend:

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

    r34ab31c0 re6a78b9  
    3737#include <align.h>
    3838
    39 #define MAX_FRAMES  1024
     39#define MAX_FRAMES  1024U
    4040#define MAX_ORDER   8
    4141#define TEST_RUNS   2
    4242
    43 const char *test_falloc1(void) {
    44         uintptr_t *frames
    45             = (uintptr_t *) malloc(MAX_FRAMES * sizeof(uintptr_t), 0);
    46         int results[MAX_ORDER + 1];
    47        
    48         int i, order, run;
    49         int allocated;
    50        
     43const char *test_falloc1(void)
     44{
    5145        if (TEST_RUNS < 2)
    5246                return "Test is compiled with TEST_RUNS < 2";
    5347       
     48        uintptr_t *frames = (uintptr_t *)
     49            malloc(MAX_FRAMES * sizeof(uintptr_t), 0);
    5450        if (frames == NULL)
    5551                return "Unable to allocate frames";
    5652       
    57         for (run = 0; run < TEST_RUNS; run++) {
    58                 for (order = 0; order <= MAX_ORDER; order++) {
    59                         TPRINTF("Allocating %d frames blocks ... ", 1 << order);
     53        unsigned int results[MAX_ORDER + 1];
     54        for (unsigned int run = 0; run < TEST_RUNS; run++) {
     55                for (unsigned int order = 0; order <= MAX_ORDER; order++) {
     56                        TPRINTF("Allocating %u frames blocks ... ", 1 << order);
    6057                       
    61                         allocated = 0;
    62                         for (i = 0; i < MAX_FRAMES >> order; i++) {
    63                                 frames[allocated] = (uintptr_t) frame_alloc(order, FRAME_ATOMIC | FRAME_KA);
     58                        unsigned int allocated = 0;
     59                        for (unsigned int i = 0; i < (MAX_FRAMES >> order); i++) {
     60                                frames[allocated] = (uintptr_t)
     61                                    frame_alloc(order, FRAME_ATOMIC | FRAME_KA);
    6462                               
    65                                 if (ALIGN_UP(frames[allocated], FRAME_SIZE << order) != frames[allocated]) {
    66                                         TPRINTF("Block at address %p (size %dK) is not aligned\n",
     63                                if (ALIGN_UP(frames[allocated], FRAME_SIZE << order) !=
     64                                    frames[allocated]) {
     65                                        TPRINTF("Block at address %p (size %u) is not aligned\n",
    6766                                            (void *) frames[allocated], (FRAME_SIZE << order) >> 10);
    6867                                        return "Test failed";
     
    8786                        TPRINTF("Deallocating ... ");
    8887                       
    89                         for (i = 0; i < allocated; i++)
     88                        for (unsigned int i = 0; i < allocated; i++)
    9089                                frame_free(KA2PA(frames[i]));
    9190                       
  • kernel/test/mm/falloc2.c

    r34ab31c0 re6a78b9  
    4040#include <arch.h>
    4141
    42 #define MAX_FRAMES  256
     42#define MAX_FRAMES  256U
    4343#define MAX_ORDER   8
    4444
     
    5151static void falloc(void *arg)
    5252{
    53         int order, run, allocated, i;
    5453        uint8_t val = THREAD->tid % THREADS;
    55         size_t k;
    5654       
    57         void **frames =  (void **) malloc(MAX_FRAMES * sizeof(void *), FRAME_ATOMIC);
     55        void **frames = (void **)
     56            malloc(MAX_FRAMES * sizeof(void *), FRAME_ATOMIC);
    5857        if (frames == NULL) {
    59                 TPRINTF("Thread #%" PRIu64 " (cpu%u): Unable to allocate frames\n", THREAD->tid, CPU->id);
     58                TPRINTF("Thread #%" PRIu64 " (cpu%u): "
     59                    "Unable to allocate frames\n", THREAD->tid, CPU->id);
    6060                atomic_inc(&thread_fail);
    6161                atomic_dec(&thread_count);
     
    6565        thread_detach(THREAD);
    6666       
    67         for (run = 0; run < THREAD_RUNS; run++) {
    68                 for (order = 0; order <= MAX_ORDER; order++) {
    69                         TPRINTF("Thread #%" PRIu64 " (cpu%u): Allocating %d frames blocks ... \n", THREAD->tid, CPU->id, 1 << order);
     67        for (unsigned int run = 0; run < THREAD_RUNS; run++) {
     68                for (unsigned int order = 0; order <= MAX_ORDER; order++) {
     69                        TPRINTF("Thread #%" PRIu64 " (cpu%u): "
     70                            "Allocating %u frames blocks ... \n", THREAD->tid,
     71                            CPU->id, 1 << order);
    7072                       
    71                         allocated = 0;
    72                         for (i = 0; i < (MAX_FRAMES >> order); i++) {
    73                                 frames[allocated] = frame_alloc(order, FRAME_ATOMIC | FRAME_KA);
     73                        unsigned int allocated = 0;
     74                        for (unsigned int i = 0; i < (MAX_FRAMES >> order); i++) {
     75                                frames[allocated] =
     76                                    frame_alloc(order, FRAME_ATOMIC | FRAME_KA);
    7477                                if (frames[allocated]) {
    7578                                        memsetb(frames[allocated], FRAME_SIZE << order, val);
     
    7982                        }
    8083                       
    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);
     84                        TPRINTF("Thread #%" PRIu64 " (cpu%u): "
     85                            "%u blocks allocated.\n", THREAD->tid, CPU->id,
     86                            allocated);
     87                        TPRINTF("Thread #%" PRIu64 " (cpu%u): "
     88                            "Deallocating ... \n", THREAD->tid, CPU->id);
    8389                       
    84                         for (i = 0; i < allocated; i++) {
    85                                 for (k = 0; k <= (((size_t) FRAME_SIZE << order) - 1); k++) {
     90                        for (unsigned int i = 0; i < allocated; i++) {
     91                                for (size_t k = 0; k <= (((size_t) FRAME_SIZE << order) - 1);
     92                                    k++) {
    8693                                        if (((uint8_t *) frames[i])[k] != val) {
    87                                                 TPRINTF("Thread #%" PRIu64 " (cpu%u): Unexpected data (%c) in block %p offset %zu\n",
    88                                                     THREAD->tid, CPU->id, ((char *) frames[i])[k], frames[i], k);
     94                                                TPRINTF("Thread #%" PRIu64 " (cpu%u): "
     95                                                    "Unexpected data (%c) in block %p offset %zu\n",
     96                                                    THREAD->tid, CPU->id, ((char *) frames[i])[k],
     97                                                    frames[i], k);
    8998                                                atomic_inc(&thread_fail);
    9099                                                goto cleanup;
     
    94103                        }
    95104                       
    96                         TPRINTF("Thread #%" PRIu64 " (cpu%u): Finished run.\n", THREAD->tid, CPU->id);
     105                        TPRINTF("Thread #%" PRIu64 " (cpu%u): "
     106                            "Finished run.\n", THREAD->tid, CPU->id);
    97107                }
    98108        }
     
    101111        free(frames);
    102112       
    103         TPRINTF("Thread #%" PRIu64 " (cpu%u): Exiting\n", THREAD->tid, CPU->id);
     113        TPRINTF("Thread #%" PRIu64 " (cpu%u): Exiting\n",
     114            THREAD->tid, CPU->id);
    104115        atomic_dec(&thread_count);
    105116}
     
    107118const char *test_falloc2(void)
    108119{
    109         unsigned int i;
    110        
    111120        atomic_set(&thread_count, THREADS);
    112121        atomic_set(&thread_fail, 0);
    113122       
    114         for (i = 0; i < THREADS; i++) {
    115                 thread_t * thrd = thread_create(falloc, NULL, TASK, 0, "falloc", false);
     123        for (unsigned int i = 0; i < THREADS; i++) {
     124                thread_t *thrd = thread_create(falloc, NULL, TASK,
     125                    THREAD_FLAG_NONE, "falloc2");
    116126                if (!thrd) {
    117127                        TPRINTF("Could not create thread %u\n", i);
     
    122132       
    123133        while (atomic_get(&thread_count) > 0) {
    124                 TPRINTF("Threads left: %" PRIua "\n", atomic_get(&thread_count));
     134                TPRINTF("Threads left: %" PRIua "\n",
     135                    atomic_get(&thread_count));
    125136                thread_sleep(1);
    126137        }
  • kernel/test/mm/slab1.c

    r34ab31c0 re6a78b9  
    155155       
    156156        semaphore_initialize(&thr_sem, 0);
    157         for (i = 0; i < THREADS; i++) { 
    158                 if (!(t = thread_create(slabtest, (void *) (sysarg_t) i, TASK, 0, "slabtest", false))) {
     157        for (i = 0; i < THREADS; i++) {
     158                if (!(t = thread_create(slabtest, (void *) (sysarg_t) i, TASK, THREAD_FLAG_NONE, "slabtest"))) {
    159159                        TPRINTF("Could not create thread %d\n", i);
    160160                } else
  • kernel/test/mm/slab2.c

    r34ab31c0 re6a78b9  
    5252        void *olddata1 = NULL, *olddata2 = NULL;
    5353       
    54         cache1 = slab_cache_create("cache1_tst", ITEM_SIZE, 0, NULL, NULL, 0);
    55         cache2 = slab_cache_create("cache2_tst", ITEM_SIZE, 0, NULL, NULL, 0);
     54        cache1 = slab_cache_create("test_cache1", ITEM_SIZE, 0, NULL, NULL, 0);
     55        cache2 = slab_cache_create("test_cache2", ITEM_SIZE, 0, NULL, NULL, 0);
    5656       
    5757        TPRINTF("Allocating...");
     
    210210        thr_cache = slab_cache_create("thread_cache", size, 0, NULL, NULL, 0);
    211211        semaphore_initialize(&thr_sem,0);
    212         for (i = 0; i < THREADS; i++) { 
    213                 if (!(t = thread_create(slabtest, NULL, TASK, 0, "slabtest", false))) {
     212        for (i = 0; i < THREADS; i++) {
     213                if (!(t = thread_create(slabtest, NULL, TASK, THREAD_FLAG_NONE, "slabtest"))) {
    214214                        TPRINTF("Could not create thread %d\n", i);
    215215                } else
  • kernel/test/synch/semaphore1.c

    r34ab31c0 re6a78b9  
    9393                for (j = 0; j < (CONSUMERS + PRODUCERS) / 2; j++) {
    9494                        for (k = 0; k < i; k++) {
    95                                 thrd = thread_create(consumer, NULL, TASK, 0, "consumer", false);
     95                                thrd = thread_create(consumer, NULL, TASK,
     96                                    THREAD_FLAG_NONE, "consumer");
    9697                                if (thrd)
    9798                                        thread_ready(thrd);
     
    100101                        }
    101102                        for (k = 0; k < (4 - i); k++) {
    102                                 thrd = thread_create(producer, NULL, TASK, 0, "producer", false);
     103                                thrd = thread_create(producer, NULL, TASK,
     104                                    THREAD_FLAG_NONE, "producer");
    103105                                if (thrd)
    104106                                        thread_ready(thrd);
  • kernel/test/synch/semaphore2.c

    r34ab31c0 re6a78b9  
    9393        TPRINTF("Creating %" PRIu32 " consumers\n", k);
    9494        for (i = 0; i < k; i++) {
    95                 thrd = thread_create(consumer, NULL, TASK, 0, "consumer", false);
     95                thrd = thread_create(consumer, NULL, TASK,
     96                    THREAD_FLAG_NONE, "consumer");
    9697                if (thrd)
    9798                        thread_ready(thrd);
  • kernel/test/thread/thread1.c

    r34ab31c0 re6a78b9  
    6363        for (i = 0; i < THREADS; i++) {
    6464                thread_t *t;
    65                 if (!(t = thread_create(threadtest, NULL, TASK, 0, "threadtest", false))) {
     65                if (!(t = thread_create(threadtest, NULL, TASK,
     66                    THREAD_FLAG_NONE, "threadtest"))) {
    6667                        TPRINTF("Could not create thread %d\n", i);
    6768                        break;
Note: See TracChangeset for help on using the changeset viewer.