Changeset b0c2075 in mainline for kernel/test
- Timestamp:
- 2013-09-10T17:48:57Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 85147f3
- Parents:
- 86733f3
- Location:
- kernel/test/mm
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/test/mm/falloc1.c
r86733f3 rb0c2075 37 37 #include <align.h> 38 38 39 #define MAX_FRAMES 1024 U39 #define MAX_FRAMES 1024 40 40 #define MAX_ORDER 8 41 41 #define TEST_RUNS 2 … … 51 51 return "Unable to allocate frames"; 52 52 53 unsigned int results[MAX_ORDER + 1]; 53 unsigned int results[MAX_FRAMES + 1]; 54 54 55 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); 56 for (size_t count = 1; count <= MAX_FRAMES; count++) { 57 size_t bytes = FRAMES2SIZE(count); 58 59 TPRINTF("Allocating %zu frames blocks (%zu bytes) ... ", 60 count, bytes); 57 61 58 62 unsigned int allocated = 0; 59 for (unsigned int i = 0; i < (MAX_FRAMES >> order); i++) {63 for (unsigned int i = 0; i < (MAX_FRAMES / count); i++) { 60 64 frames[allocated] = 61 PA2KA(frame_alloc(order, FRAME_ATOMIC, 0)); 62 63 if (ALIGN_UP(frames[allocated], FRAME_SIZE << order) != 64 frames[allocated]) { 65 TPRINTF("Block at address %p (size %u) is not aligned\n", 66 (void *) frames[allocated], (FRAME_SIZE << order) >> 10); 67 return "Test failed"; 68 } 65 PA2KA(frame_alloc(count, FRAME_ATOMIC, 0)); 69 66 70 67 if (frames[allocated]) … … 78 75 TPRINTF("%d blocks allocated.\n", allocated); 79 76 80 if (run ) {81 if (results[ order] != allocated)77 if (run > 0) { 78 if (results[count] != allocated) 82 79 return "Possible frame leak"; 83 80 } else 84 results[ order] = allocated;81 results[count] = allocated; 85 82 86 83 TPRINTF("Deallocating ... "); -
kernel/test/mm/falloc2.c
r86733f3 rb0c2075 40 40 #include <arch.h> 41 41 42 #define MAX_FRAMES 256U 43 #define MAX_ORDER 8 42 #define MAX_FRAMES 256 44 43 45 44 #define THREAD_RUNS 1 … … 66 65 67 66 for (unsigned int run = 0; run < THREAD_RUNS; run++) { 68 for (unsigned int order = 0; order <= MAX_ORDER; order++) { 67 for (size_t count = 1; count <= MAX_FRAMES; count++) { 68 size_t bytes = FRAMES2SIZE(count); 69 69 70 TPRINTF("Thread #%" PRIu64 " (cpu%u): " 70 "Allocating % u frames blocks... \n", THREAD->tid,71 CPU->id, 1 << order);71 "Allocating %zu frames blocks (%zu bytes) ... \n", THREAD->tid, 72 CPU->id, count, bytes); 72 73 73 74 unsigned int allocated = 0; 74 for (unsigned int i = 0; i < (MAX_FRAMES >> order); i++) {75 for (unsigned int i = 0; i < (MAX_FRAMES / count); i++) { 75 76 frames[allocated] = 76 PA2KA(frame_alloc( order, FRAME_ATOMIC, 0));77 PA2KA(frame_alloc(count, FRAME_ATOMIC, 0)); 77 78 if (frames[allocated]) { 78 memsetb((void *) frames[allocated], FRAME_SIZE << order, val);79 memsetb((void *) frames[allocated], bytes, val); 79 80 allocated++; 80 81 } else … … 89 90 90 91 for (unsigned int i = 0; i < allocated; i++) { 91 for (size_t k = 0; k <= (((size_t) FRAME_SIZE << order) - 1); 92 k++) { 92 for (size_t k = 0; k < bytes; k++) { 93 93 if (((uint8_t *) frames[i])[k] != val) { 94 94 TPRINTF("Thread #%" PRIu64 " (cpu%u): " -
kernel/test/mm/mapping1.c
r86733f3 rb0c2075 41 41 const char *test_mapping1(void) 42 42 { 43 uintptr_t page0, page1; 44 uint32_t v; 43 uintptr_t frame = frame_alloc(1, FRAME_NONE, 0); 45 44 46 uintptr_t frame = frame_alloc(ONE_FRAME, FRAME_NONE, 0); 47 48 page0 = km_map(frame, FRAME_SIZE, 45 uintptr_t page0 = km_map(frame, FRAME_SIZE, 49 46 PAGE_READ | PAGE_WRITE | PAGE_CACHEABLE); 50 47 TPRINTF("Virtual address %p mapped to physical address %p.\n", 51 48 (void *) page0, (void *) frame); 52 page1 = km_map(frame, FRAME_SIZE, 49 50 uintptr_t page1 = km_map(frame, FRAME_SIZE, 53 51 PAGE_READ | PAGE_WRITE | PAGE_CACHEABLE); 54 52 TPRINTF("Virtual address %p mapped to physical address %p.\n", … … 62 60 TPRINTF("Reading magic using the second virtual address.\n"); 63 61 64 v = *((uint32_t *) page1);62 uint32_t v = *((uint32_t *) page1); 65 63 66 64 if (v != TEST_MAGIC) {
Note:
See TracChangeset
for help on using the changeset viewer.