Changeset 96348adc in mainline for kernel/test/mm/falloc1.c


Ignore:
Timestamp:
2006-12-12T17:24:58Z (19 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
7e13972
Parents:
34db7fa
Message:

cleanup tests

File:
1 edited

Legend:

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

    r34db7fa r96348adc  
    2626 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2727 */
     28
    2829#include <print.h>
    2930#include <test.h>
     
    3637#include <align.h>
    3738
    38 #ifdef CONFIG_BENCH
    39 #include <arch/cycle.h>
    40 #endif
    41 
    4239#define MAX_FRAMES 1024
    4340#define MAX_ORDER 8
    4441#define TEST_RUNS 2
    4542
    46 void test_falloc1(void) {
    47 #ifdef CONFIG_BENCH
    48         uint64_t t0 = get_cycle();
    49 #endif
    50         uintptr_t * frames = (uintptr_t *) malloc(MAX_FRAMES*sizeof(uintptr_t), 0);
    51         int results[MAX_ORDER+1];
     43char * test_falloc1(void) {
     44        uintptr_t * frames = (uintptr_t *) malloc(MAX_FRAMES * sizeof(uintptr_t), 0);
     45        int results[MAX_ORDER + 1];
    5246       
    5347        int i, order, run;
     
    5549
    5650        ASSERT(TEST_RUNS > 1);
    57         ASSERT(frames != NULL)
     51        if (frames == NULL)
     52                return "Unable to allocate frames";
    5853
    5954        for (run = 0; run < TEST_RUNS; run++) {
     
    6560                               
    6661                                if (ALIGN_UP(frames[allocated], FRAME_SIZE << order) != frames[allocated]) {
    67                                         panic("Test failed. Block at address %p (size %dK) is not aligned\n", frames[allocated], (FRAME_SIZE << order) >> 10);
     62                                        printf("Block at address %p (size %dK) is not aligned\n", frames[allocated], (FRAME_SIZE << order) >> 10);
     63                                        return "Test failed";
    6864                                }
    6965                               
    70                                 if (frames[allocated]) {
     66                                if (frames[allocated])
    7167                                        allocated++;
    72                                 } else {
     68                                else {
    7369                                        printf("done. ");
    7470                                        break;
    7571                                }
    7672                        }
    77                
     73                       
    7874                        printf("%d blocks allocated.\n", allocated);
    7975               
    8076                        if (run) {
    81                                 if (results[order] != allocated) {
    82                                         panic("Test failed. Frame leak possible.\n");
    83                                 }
     77                                if (results[order] != allocated)
     78                                        return "Possible frame leak";
    8479                        } else
    8580                                results[order] = allocated;
    8681                       
    8782                        printf("Deallocating ... ");
    88                         for (i = 0; i < allocated; i++) {
     83                        for (i = 0; i < allocated; i++)
    8984                                frame_free(KA2PA(frames[i]));
    90                         }
    9185                        printf("done.\n");
    9286                }
     
    9589        free(frames);
    9690       
    97         printf("Test passed.\n");
    98 #ifdef CONFIG_BENCH
    99         uint64_t dt = get_cycle() - t0;
    100         printf("Time: %.*d cycles\n", sizeof(dt) * 2, dt);
    101 #endif
     91        return NULL;
    10292}
    103 
Note: See TracChangeset for help on using the changeset viewer.