Changeset 96348adc in mainline for kernel/test/mm/falloc1.c
- Timestamp:
- 2006-12-12T17:24:58Z (19 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 7e13972
- Parents:
- 34db7fa
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/test/mm/falloc1.c
r34db7fa r96348adc 26 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 27 */ 28 28 29 #include <print.h> 29 30 #include <test.h> … … 36 37 #include <align.h> 37 38 38 #ifdef CONFIG_BENCH39 #include <arch/cycle.h>40 #endif41 42 39 #define MAX_FRAMES 1024 43 40 #define MAX_ORDER 8 44 41 #define TEST_RUNS 2 45 42 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]; 43 char * test_falloc1(void) { 44 uintptr_t * frames = (uintptr_t *) malloc(MAX_FRAMES * sizeof(uintptr_t), 0); 45 int results[MAX_ORDER + 1]; 52 46 53 47 int i, order, run; … … 55 49 56 50 ASSERT(TEST_RUNS > 1); 57 ASSERT(frames != NULL) 51 if (frames == NULL) 52 return "Unable to allocate frames"; 58 53 59 54 for (run = 0; run < TEST_RUNS; run++) { … … 65 60 66 61 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"; 68 64 } 69 65 70 if (frames[allocated]) {66 if (frames[allocated]) 71 67 allocated++; 72 }else {68 else { 73 69 printf("done. "); 74 70 break; 75 71 } 76 72 } 77 73 78 74 printf("%d blocks allocated.\n", allocated); 79 75 80 76 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"; 84 79 } else 85 80 results[order] = allocated; 86 81 87 82 printf("Deallocating ... "); 88 for (i = 0; i < allocated; i++) {83 for (i = 0; i < allocated; i++) 89 84 frame_free(KA2PA(frames[i])); 90 }91 85 printf("done.\n"); 92 86 } … … 95 89 free(frames); 96 90 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; 102 92 } 103
Note:
See TracChangeset
for help on using the changeset viewer.