Changeset cb01e1e in mainline for kernel/test/mm/falloc1.c


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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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       
Note: See TracChangeset for help on using the changeset viewer.